-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathDockerfile
59 lines (38 loc) · 1.01 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
48
49
50
51
52
53
54
55
56
57
58
59
########
# BASE #
########
FROM node:dubnium-alpine AS base
RUN mkdir /app/ && chown node:node /app/
WORKDIR /app/
USER node
# try to take advtange of caching for large files
COPY ./src/client/assets/ ./src/client/assets/
COPY ./package.json ./package-lock.json ./
RUN npm ci
COPY ./ ./
#########
# BUILD #
#########
FROM node:dubnium-alpine AS build
RUN mkdir /app/ && chown node:node /app/
WORKDIR /app/
COPY --from=base /app/ ./
# this step takes super long and has to be run for every little change, so it's part of its own step
RUN npm run build:prod
RUN npm prune --production
# so the COPY below doesn't fail if we don't have a .env
RUN touch ./.env
#########
# FINAL #
#########
FROM node:dubnium-alpine
RUN mkdir /app/ && chown node:node /app/
WORKDIR /app/
USER node
ENV NODE_ENV production
COPY --from=build /app/.env ./.env
COPY --from=build /app/node_modules/ ./node_modules/
COPY --from=build /app/dist/ ./dist/
COPY --from=build /app/package.json ./package.json
EXPOSE 3000
CMD ["npm", "start"]