Skip to content

Commit

Permalink
[NORTHFLANK] updated Dockerfile contents
Browse files Browse the repository at this point in the history
  • Loading branch information
old-local-github-syndica[bot] authored Apr 4, 2023
1 parent 227816c commit 6a5e50d
Showing 1 changed file with 9 additions and 53 deletions.
62 changes: 9 additions & 53 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,57 +1,13 @@
# syntax=docker/dockerfile:1.4

# 1. For build React app
FROM node:16 AS development

# Set working directory
FROM node:16 AS builder
WORKDIR /app

#
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json

# Same as npm install
RUN npm ci

COPY . /app

ENV CI=true
ENV PORT=3000

CMD [ "npm", "start" ]

FROM development AS build

COPY package*.json ./
RUN npm install
COPY . .
ENV BUILD_PATH './build'
RUN npm run build

# 2. For Nginx setup
FROM nginx:alpine

# Copy config nginx
RUN echo "server {" > /etc/nginx/conf.d/default.conf
RUN echo "" >> /etc/nginx/conf.d/default.conf
RUN echo " listen 80;" >> /etc/nginx/conf.d/default.conf
RUN echo "" >> /etc/nginx/conf.d/default.conf
RUN echo " location / {" >> /etc/nginx/conf.d/default.conf
RUN echo " root /usr/share/nginx/html;" >> /etc/nginx/conf.d/default.conf
RUN echo " index index.html index.htm;" >> /etc/nginx/conf.d/default.conf
RUN echo " try_files $uri /index.html =404;" >> /etc/nginx/conf.d/default.conf
RUN echo " }" >> /etc/nginx/conf.d/default.conf
RUN echo "" >> /etc/nginx/conf.d/default.conf
RUN echo " error_page 500 502 503 504 /50x.html;" >> /etc/nginx/conf.d/default.conf
RUN echo "" >> /etc/nginx/conf.d/default.conf
RUN echo " location = /50x.html {" >> /etc/nginx/conf.d/default.conf
RUN echo " root /usr/share/nginx/html;" >> /etc/nginx/conf.d/default.conf
RUN echo " }" >> /etc/nginx/conf.d/default.conf
RUN echo "}" >> /etc/nginx/conf.d/default.conf

FROM nginx:alpine AS prod
WORKDIR /usr/share/nginx/html

# Remove default nginx static assets
RUN rm -rf ./*

# Copy static assets from builder stage
COPY --from=build /app/build .

# Containers run nginx with global directives and daemon off
ENTRYPOINT ["nginx", "-g", "daemon off;"]
COPY --from=builder /app/build .
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]

0 comments on commit 6a5e50d

Please sign in to comment.