-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (27 loc) · 923 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
FROM node:16-alpine AS deps
# 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
# set work directory
WORKDIR /usr/src
# copy over package.json and yarn.lock files
COPY package.json yarn.lock ./
RUN yarn --frozen-lockfile
# Rebuild the source code only when needed
FROM deps as builder
WORKDIR /usr/src
COPY . .
RUN yarn build
# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /usr/src
ENV NODE_ENV production
# COPY --from=builder /usr/src/.env ./.env
COPY --from=builder /usr/src/dist ./dist
COPY --from=builder /usr/src/node_modules ./node_modules
COPY --from=builder /usr/src/package.json ./package.json
RUN addgroup -g 1001 -S api
RUN adduser -S api -u 1001
RUN chown -R api:api /usr/src/dist
USER api
EXPOSE 8000
CMD ["yarn", "start"]