forked from johnuberbacher/invoice-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NORTHFLANK] updated Dockerfile contents
- Loading branch information
1 parent
227816c
commit 6a5e50d
Showing
1 changed file
with
9 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;"] |