forked from lawalletio/module-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (25 loc) · 920 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
FROM node:18-alpine AS base
RUN ["addgroup", "--system", "--gid", "1001", "nodejs"]
RUN ["adduser" , "--system", "--uid", "1001", "nodejs"]
FROM base AS dependencies
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN ["apk", "add", "--no-cache", "libc6-compat"]
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN ["npm", "i", "-g", "pnpm"]
RUN ["pnpm", "i", "--frozen-lockfile", "--prod"]
FROM base AS build
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
RUN ["npm", "i", "-g", "@swc/cli@^0.1.62"]
RUN ["npm", "run", "build"]
FROM base AS runner
WORKDIR /app
COPY --from=build --chown=nodejs:nodejs /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
USER nodejs
ENV NODE_ENV production
ENV PORT 3000
EXPOSE 3000
ENTRYPOINT ["node", "dist/index.js"]