-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile.api
49 lines (39 loc) · 1.49 KB
/
Dockerfile.api
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
###
# BUILD STAGE
###
FROM node:16-alpine AS build
ENV NODE_ENV production
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
# python3, make, and g++ are needed for building node-gyp (itself required by a bunch of our dependencies)
RUN apk update && apk add --no-cache python3 make g++ libc6-compat
RUN mkdir -p \
/home/node/app/ \
/home/node/app/packages/api \
/home/node/app/packages/frontend/common \
&& chown -R node:node /home/node/app/
USER node
WORKDIR /home/node/app/
COPY --chown=node:node packages/api/package.json packages/api/.sequelizerc ./packages/api/
COPY --chown=node:node package.json yarn.lock .yarnrc.yml ./
COPY --chown=node:node .yarn ./.yarn/
RUN yarn install --silent && yarn cache clean
ADD ./packages/api ./packages/api/
ADD --chown=node:node ./packages/frontend/common ./packages/frontend/common/
WORKDIR /home/node/app/packages/api/
RUN yarn build
###
# PRODUCTION STAGE
###
FROM node:16-alpine AS production
ENV NODE_ENV production
RUN mkdir -p \
/home/node/app/ \
&& chown -R node:node /home/node/app/
USER node
WORKDIR /home/node/app/
COPY --chown=node:node package.json ./
COPY --from=build --chown=node:node /home/node/app/node_modules ./node_modules
COPY --from=build --chown=node:node /home/node/app/packages/api/dist ./packages/
COPY --chown=node:node packages/api/package.json ./packages/api/
WORKDIR /home/node/app/packages/api
ENTRYPOINT ["yarn", "serve"]