-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
40 lines (28 loc) · 907 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
# Base
FROM node:18-alpine as base
# Builder
FROM base as builder
# Install yarn.
RUN apk add --update --no-cache yarn
WORKDIR /home/node
# Copy all files required for installing dependencies.
COPY --chown=node:node .yarn/ .yarn/
COPY --chown=node:node ["package.json", "yarn.lock", ".yarnrc.yml", "./"]
# Install all dependencies.
RUN yarn
# Copy all files required for building.
COPY --chown=node:node . .
# Build and remove dev dependencies
RUN yarn build && yarn workspaces focus --production
# Final image
FROM base
USER node
WORKDIR /home/node
ENV NODE_ENV=production
EXPOSE 27200/tcp
# Copy only required files from builder to final image.
COPY --from=builder --chown=node:node /home/node/node_modules/ ./node_modules/
COPY --from=builder --chown=node:node /home/node/package.json ./
COPY --from=builder --chown=node:node /home/node/dist/ ./dist/
WORKDIR /home/node
CMD ["yarn", "start"]