Skip to content

Instantly share code, notes, and snippets.

@nemanjam
Created December 15, 2022 18:18
Show Gist options
  • Save nemanjam/674a78fbf01f5162915059bf34172f4d to your computer and use it in GitHub Desktop.
Save nemanjam/674a78fbf01f5162915059bf34172f4d to your computer and use it in GitHub Desktop.
# 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