This repository has been archived by the owner on Nov 21, 2022. It is now read-only.
forked from tot-ra/graphql-schema-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.CI
47 lines (42 loc) · 1.63 KB
/
Dockerfile.CI
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
# 1. BUILD FRONTEND source with webpack
FROM node:16-alpine as builder-frontend
ARG env=production
ENV npm_config_cache=/tmp/.npm
WORKDIR /app
COPY git_src/package.json git_src/package-lock.json ./
RUN npm install
COPY git_src/webpack.config.js git_src/babel.config.js git_src/tsconfig.json git_src/.eslintrc git_src/.editorconfig ./
COPY git_src/client ./client
RUN npm run build-frontend
# 2. BUILD BACKEND source from .ts, uses dev-dependencies
FROM node:16-alpine as builder-backend
ARG env=production
ENV npm_config_cache=/tmp/.npm
WORKDIR /app
COPY git_src/package.json git_src/package-lock.json git_src/tsconfig.json git_src/webpack.config.js ./
RUN npm install
COPY git_src/src ./src
RUN npm run build-backend
# 3. BUILD FINAL IMAGE
FROM node:16-alpine
ARG env=production
ENV NODE_ENV=${env}
RUN mkdir -p /app && \
chown nobody:nobody /app
WORKDIR /app
COPY --chown=nobody:nobody --from=builder-frontend /app/dist /app/dist
COPY --chown=nobody:nobody --from=builder-backend /app/app /app/app
# 3.1 copy only required files
COPY --chown=nobody:nobody git_src/migrations /app/migrations
COPY --chown=nobody:nobody git_src/container-health.js /app/container-health.js
COPY --chown=nobody:nobody git_src/knexfile.js /app/knexfile.js
COPY --chown=nobody:nobody git_src/package.json /app/package.json
COPY --chown=nobody:nobody git_src/package-lock.json /app/package-lock.json
# 3.2 install production dependencies only. Cleanup cache after that
RUN mkdir -p /.npm && \
npm ci && \
rm -rf /.npm
USER nobody
HEALTHCHECK --interval=10s --timeout=5s --start-period=10s --retries=3 CMD [ "node", "container-health.js" ]
EXPOSE 3000
CMD ["node", "app/schema-registry.js"]