-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
47 lines (41 loc) · 1.19 KB
/
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
43
44
45
46
47
# base image
FROM node:12-alpine as base
EXPOSE 9999
ENV NODE_ENV=development
ENV PATH=/app/node_modules/.bin:$PATH
WORKDIR /app
# development image
FROM base as dev
ENV NODE_ENV=development
RUN apk add --no-cache python3 make g++
# development tests
FROM base as test
# install git for jest watch
RUN apk add --no-cache git
RUN apk add --no-cache python3 make g++
# Builder for ci
FROM base as ci-builder
ENV NODE_ENV=development
COPY package*.json yarn.lock /app/
RUN apk add --no-cache python3 make g++
RUN yarn install --frozen-lockfile && yarn cache clean
# CI tests
FROM test as ci
COPY --from=ci-builder /app/package.json /app/yarn.lock /app/
COPY --from=ci-builder /app/node_modules /app/node_modules
COPY . .
# Builder for production
FROM base as prod-builder
ENV NODE_ENV=production
COPY package*.json yarn.lock /app/
RUN apk add --no-cache python3 make g++
RUN yarn install --frozen-lockfile && yarn cache clean
# Production image build
FROM base as prod
ENV NODE_ENV=production
COPY --from=prod-builder /app/node_modules /app/node_modules
COPY ./dist /app/dist
COPY production-entrypoint.sh package.json /app/
RUN chmod +x /app/production-entrypoint.sh
USER node
CMD ["node", "/app/dist/index.js"]