forked from chaunnt/TemplateReactJS
/
Dockerfile
34 lines (26 loc) · 1.02 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
# Create image based on the official Node image from dockerhub
FROM node:12.22 as cache-image
# Bundle app source
COPY . /usr/src/app/
WORKDIR /usr/src/app
RUN yarn install
# Build frontend
FROM cache-image as builder
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN yarn build
# PROD environment
# Create image based on the official NGINX image from dockerhub
FROM nginx:1.16.0-alpine as deploy-image
## Set timezones
RUN cp /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtime
# Get all the builded code to root folder
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
# Copy nginx template to container
COPY --from=builder /usr/src/app/ops/config/nginx.template.conf /etc/nginx/nginx.conf
COPY --from=builder /usr/src/app/ops/config/default.template.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /usr/src/app/start-container.sh /etc/nginx/start-container.sh
RUN chmod +x /etc/nginx/start-container.sh
RUN mkdir -p /usr/share/nginx/html/media
## Serve the app
CMD [ "/bin/sh", "-c", "/etc/nginx/start-container.sh" ]