Skip to content

Instantly share code, notes, and snippets.

@devenes
Created March 13, 2023 14:46
Show Gist options
  • Save devenes/8eaefac3ba729dd6f8962a7e2a6f2a4c to your computer and use it in GitHub Desktop.
Save devenes/8eaefac3ba729dd6f8962a7e2a6f2a4c to your computer and use it in GitHub Desktop.
# Use a multi-stage build to optimize image size
FROM node:14-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
FROM nginx:alpine
LABEL maintainer="Your Name <youremail@example.com>"
# Install necessary packages
RUN apk add --no-cache --update \
curl \
openssl \
supervisor
# Copy files from build stage
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
COPY default.conf /etc/nginx/conf.d/default.conf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Set up SSL certificate
RUN mkdir -p /etc/nginx/ssl
RUN openssl req -x509 -newkey rsa:4096 -keyout /etc/nginx/ssl/nginx.key \
-out /etc/nginx/ssl/nginx.crt -days 365 -nodes -subj "/CN=localhost"
# Start supervisor to run multiple processes
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment