-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
42 lines (29 loc) · 848 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
# Install dependencies only when needed
# Stage 0
FROM node:16-alpine AS deps
WORKDIR /
COPY package.json ./
RUN yarn install --frozen-lockfile
#############################################
# Rebuild the source code only when needed
# Stage 1
FROM node:16-alpine AS builder
WORKDIR /
COPY . .
COPY --from=deps /node_modules ./node_modules
RUN yarn build
#############################################
# Production image, copy only production files
# Stage 2
FROM node:16-alpine AS prod
WORKDIR /
RUN addgroup -g 1001 -S nodejs
RUN adduser -S server -u 1001
COPY --from=builder --chown=server:nodejs /dist ./dist
COPY --from=builder /node_modules ./node_modules
COPY --from=builder /package.json ./package.json
COPY --from=builder /.env ./.env
USER server
EXPOSE 6969
CMD ["yarn", "start"]
#############################################