Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (45 loc) · 1.74 KB
/
Copy pathDockerfile
File metadata and controls
72 lines (45 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# syntax = docker/dockerfile:1
# Adjust BUN_VERSION as desired
FROM oven/bun:slim AS base
LABEL fly_launch_runtime="Next.js"
# Next.js app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV="production"
# Install system dependencies
FROM base AS deps-system
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3 && \
rm -rf /var/lib/apt/lists/*
# Install node modules
FROM deps-system AS deps
COPY bun.lock package.json ./
RUN --mount=type=cache,target=/root/.bun/install/cache \
bun install --frozen-lockfile
# Copy pongo config (separate layer for config changes)
FROM deps AS pongo-config
COPY pongo ./pongo
# Build application
FROM pongo-config AS build
COPY . .
RUN --mount=type=cache,target=/root/.bun/install/cache \
--mount=type=cache,target=/app/.next/cache \
bun next build --experimental-build-mode compile
# Production dependencies only
FROM deps-system AS production-deps
COPY bun.lock package.json ./
RUN --mount=type=cache,target=/root/.bun/install/cache \
bun install --frozen-lockfile
# Final stage for app image
FROM base
# Copy production dependencies
COPY --from=production-deps /app/node_modules ./node_modules
# Copy everything from build
COPY --from=build /app ./
# The ENTRYPOINT instruction sets the executable that will always run when the container starts.
# The CMD instruction provides default arguments to the ENTRYPOINT, or supplies a default command if ENTRYPOINT is not set.
# If both are used, CMD's values are passed as arguments to ENTRYPOINT.
# In this example, ENTRYPOINT runs the entrypoint script, and CMD runs the app server.
ENTRYPOINT [ "/app/docker-entrypoint.js" ]
EXPOSE 3000
CMD [ "bun", "run", "start" ]