-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
41 lines (29 loc) · 938 Bytes
/
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
### Stage 1 - the build process
# Base image
FROM node:alpine as builder
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /app/package.json
RUN npm install --production --silent
COPY . ./
# build app
RUN npm run build
### Stage 2 - the production environment
FROM nginx:alpine
# Copy built frontend to be served by nginx
COPY --from=builder /app/build /usr/share/nginx/html/
# Copy nginx.conf to fix nginx/react-router conflict
COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
# Copy .env file and shell script to container
WORKDIR /usr/share/nginx/html
COPY ./env.sh .env ./
# Add bash
RUN apk add --no-cache bash
# Make our shell script executable
RUN chmod +x env.sh
# Start nginx server
EXPOSE 8080
CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""]