-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
38 lines (31 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
## Build environment. Resulting build in /app/build
FROM node:lts-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
# Avoid JS heap out of memory when building
ARG NODE_OPTIONS=--max-old-space-size=4096
# Backend location defaults to what is in .env file when the image was built.
# Install dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
# Copy application files and build
COPY . ./
RUN npm run build
## Prod environment.
FROM nginx:stable-alpine as prod
LABEL org.opencontainers.image.source="https://github.com/weso/wikishape"
WORKDIR /usr/share/nginx/html
# Add bash
RUN apk add --no-cache bash
# Copy custom nginx config (react routing, compression...)
COPY nginx/*.conf /etc/nginx/conf.d/
# Copy react app build and files needed to set environment
COPY --from=build /app/build .
# Script to make ENV vars available to the app
COPY env.sh .
COPY .env .
RUN chmod +x env.sh
# Run
EXPOSE 80
CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""]