-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
38 lines (28 loc) · 880 Bytes
/
Dockerfile
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
FROM node:20-alpine AS deps
ENV TZ=Asia/Tokyo
ENV NODE_ENV=production
WORKDIR /opt/app
COPY package.json .
COPY pnpm-lock.yaml .
RUN npm install -g pnpm
RUN pnpm install --frozen-lockfile
#--------------------------------------------------
FROM node:20-alpine AS build
ENV TZ=Asia/Tokyo
WORKDIR /opt/app
COPY package.json .
COPY pnpm-lock.yaml .
RUN npm install -g pnpm
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm run build
#--------------------------------------------------
FROM gcr.io/distroless/nodejs20-debian12:nonroot AS runner
ENV TZ=Asia/Tokyo
ENV NODE_ENV=production
WORKDIR /opt/app
COPY --from=deps --chown=nonroot:nonroot /opt/app/node_modules ./node_modules
COPY --from=build --chown=nonroot:nonroot /opt/app/build ./build
COPY --from=build --chown=nonroot:nonroot /opt/app/.env .
USER nonroot
ENTRYPOINT ["/nodejs/bin/node", "build/src/main.js"]