-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (40 loc) · 1.2 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (40 loc) · 1.2 KB
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
60
61
62
63
64
65
#
# Backend for Development
#
FROM node:12 AS development-backend
RUN mkdir -p /srv/todo/backend &&\
mkdir -p /srv/todo/storage &&\
chown -R node:node /srv/todo
USER node
WORKDIR /srv/todo/storage
COPY --chown=node:node storage/package.json storage/package-lock.json ./
RUN npm install --quiet
WORKDIR /srv/todo/backend
COPY --chown=node:node backend/package.json backend/package-lock.json ./
RUN npm install --quiet
#
# Frontend for Development
#
FROM node:12 AS development-frontend
RUN mkdir -p /srv/todo/frontend/dist && chown -R node:node /srv/todo
USER node
WORKDIR /srv/todo/frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm install --quiet
#
# Frontend Build for Production
#
FROM development-frontend AS build-frontend
COPY frontend .
RUN npm run build
#
# Backend for Production
#
FROM node:12-slim AS production
USER node
WORKDIR /srv/todo/backend
COPY --from=development-backend --chown=root:root /srv/todo/backend/node_modules ./node_modules
COPY --from=development-backend --chown=root:root /srv/todo/storage/node_modules ../storage/node_modules
COPY --from=build-frontend --chown=root:root /srv/todo/frontend/dist ./dist
COPY . .
CMD ["node", "server.js"]