forked from dinushchathurya/e-commerce-site
-
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.
🎉 You're nearly ready to build and deploy your application to Northflank
- Loading branch information
1 parent
38ad636
commit b78ae98
Showing
1 changed file
with
58 additions
and
0 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 |
---|---|---|
@@ -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;"] |