Skip to content

Commit

Permalink
🎉 You're nearly ready to build and deploy your application to Northflank
Browse files Browse the repository at this point in the history
  • Loading branch information
old-local-github-syndica[bot] authored Apr 3, 2023
1 parent 38ad636 commit b78ae98
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# syntax=docker/dockerfile:1.4

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

# Set working directory
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

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

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;"]

0 comments on commit b78ae98

Please sign in to comment.