-
Notifications
You must be signed in to change notification settings - Fork 37
/
Dockerfile
59 lines (41 loc) · 1.14 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM node:22-alpine3.20 AS base
ENV DIR /app
WORKDIR $DIR
ARG NPM_TOKEN
FROM base AS dev
ENV NODE_ENV=development
ENV CI=true
RUN npm install -g [email protected]
COPY package.json pnpm-lock.yaml ./
RUN echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ".npmrc" && \
pnpm install --frozen-lockfile && \
rm -f .npmrc
COPY tsconfig*.json .
COPY .swcrc .
COPY nodemon.json .
COPY src src
EXPOSE $PORT
CMD ["node", "--run", "dev"]
FROM base AS build
ENV CI=true
RUN apk update && apk add --no-cache dumb-init=1.2.5-r3 && npm install -g [email protected]
COPY package.json pnpm-lock.yaml ./
RUN echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ".npmrc" && \
pnpm install --frozen-lockfile && \
rm -f .npmrc
COPY tsconfig*.json .
COPY .swcrc .
COPY src src
RUN node --run build && \
pnpm prune --prod
FROM base AS production
ENV NODE_ENV=production
ENV USER=node
COPY --from=build /usr/bin/dumb-init /usr/bin/dumb-init
COPY --from=build $DIR/package.json .
COPY --from=build $DIR/pnpm-lock.yaml .
COPY --from=build $DIR/node_modules node_modules
COPY --from=build $DIR/dist dist
USER $USER
EXPOSE $PORT
CMD ["dumb-init", "node", "dist/main.js"]