Created
January 8, 2024 07:58
-
-
Save Kasun002/a1726b6439417c820394e330900311e6 to your computer and use it in GitHub Desktop.
This is an example of deploying a React app's production build to an Nginx server. If you're deploying inside a cloud instance (such as AWS EC2), this method helps reduce the resources used on the server.
This file contains hidden or 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
FROM node:18 AS build | |
WORKDIR /opt/{your app name} | |
COPY package*.json ./ | |
RUN npm install | |
COPY . . | |
RUN npm run build --build-arg CACHEBUST=${CACHEBUST} | |
FROM nginx:latest | |
COPY --from=build /opt/{your app name}/build /usr/share/nginx/html | |
EXPOSE 81 | |
COPY nginx.conf /etc/nginx/nginx.conf | |
CMD ["nginx", "-g", "daemon off;"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment