-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile
49 lines (37 loc) · 1.03 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
# SERVER BUILD
FROM node as server-build
WORKDIR /app
# install Dev dependencies needed for build, e.g., Babel
# if package.json doesn't change, this will be pulled from cache
COPY ./server/package.json .
RUN npm install --dev --silent
COPY ./server ./
RUN npm run build
# CLIENT BUILD
FROM node as client-build
WORKDIR /app
# if package.json doesn't change, this will be pulled from cache
COPY ./client/package.json .
RUN npm install --silent
COPY ./client ./
RUN npm run build
# COMBINED BUILD
FROM node
WORKDIR /home/node/app
# install prod dependencies only to reduce image size
COPY ./server/package.json .
RUN npm install --prod --silent
COPY --from=server-build /app/build .
# copy React app to public, corresponding to Express static config
RUN mkdir ./public
COPY --from=client-build /app/build ./public/
# production environment
COPY .env .
ENV PATH /home/node/app/node_modules/.bin:$PATH
ENV NODE_ENV=production
ENV PORT=80
EXPOSE 80
# don't run as root
# RUN chown -R node:node ./build
# USER node
ENTRYPOINT ["node","./index.js"]