-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (30 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
51 lines (30 loc) · 1.27 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
# syntax=docker/dockerfile:1.6 # enables cache mounts etc.
# The base image is the first cache layer. It is rarely changing.
FROM node:22.15.1-bullseye-slim AS base
RUN corepack enable
# The deps image is the second cache layer. It separates the final runtime from
# the build layer.
FROM base AS deps
COPY --from=oven/bun:1.2.21-debian /usr/local/bin/bun /usr/local/bin/bun
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 build-essential && \
ln -s /usr/bin/python3 /usr/bin/python
# The install image is the third cache layer. It only changes when lock files
# change.
FROM deps AS install
WORKDIR /usr/src/app
COPY package.json bun.lock .
RUN --mount=type=cache,target=/root/.bun bun install --frozen-lockfile
# The build image is the fourth image layer. It always changes with any source
# code changes.
FROM install AS build
COPY . .
RUN --mount=type=cache,target=/root/.bun bun run build
# The runtime image is the fifth image layer. It contains all runtime
# dependencies to execute the NodeJs process.
FROM base AS runtime
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/.next/standalone ./
COPY --from=build /usr/src/app/.next/static ./.next/static
COPY --from=build /usr/src/app/public ./public
CMD ["node", "server.js"]