Created
December 15, 2022 18:18
-
-
Save nemanjam/674a78fbf01f5162915059bf34172f4d to your computer and use it in GitHub Desktop.
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
# Stage 1: Build the Node.js app | |
FROM node:12 AS build | |
WORKDIR /app | |
COPY . /app | |
RUN npm install | |
RUN npm run build | |
# Stage 2: Run the app using PM2 and a lightweight Node.js image | |
FROM node:12-slim | |
RUN npm install pm2 -g | |
WORKDIR /app | |
COPY --from=build /app/build /app | |
COPY --from=build /app/package.json /app | |
RUN npm install --production | |
EXPOSE 3000 | |
CMD ["pm2-runtime", "start", "ecosystem.config.js"] | |
# Stage 3: Serve the app using NGINX | |
FROM nginx:1.19 | |
COPY --from=build /app/build /usr/share/nginx/html | |
EXPOSE 80 | |
CMD ["nginx", "-g", "daemon off;"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment