generated from JDIZM/node-express-firebase-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (30 loc) · 910 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM node:20-alpine AS base
ENV PNPM_VERSION=9.1.0
RUN npm install -g pnpm@$PNPM_VERSION
WORKDIR /app
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV}
# install deps first so we can cache them
COPY package*.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY . .
RUN mkdir dist
RUN pnpm build
FROM base AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 express
RUN adduser --system --uid 1001 express
COPY --from=builder --chown=express:express /app/node_modules /app/node_modules
COPY --from=builder --chown=express:express /app/dist /app/dist
COPY --from=builder --chown=express:express /app/package.json /app/package.json
USER express
EXPOSE 4000
FROM runner AS dev
WORKDIR /app
COPY --from=builder --chown=express:express /app/.env /app/.env
CMD ["node", "./dist/server.mjs"]
FROM runner AS prod
WORKDIR /app
CMD ["node", "./dist/server.mjs"]