Skip to content

Instantly share code, notes, and snippets.

@regner
Created November 22, 2022 13:34
Show Gist options
  • Save regner/888ca194c64c5b28667580f79db412b9 to your computer and use it in GitHub Desktop.
Save regner/888ca194c64c5b28667580f79db412b9 to your computer and use it in GitHub Desktop.
# Build image
FROM node:16-bullseye as build
# Set working directory for easy copy from later
WORKDIR /app
# Copy everything else over so we can build
COPY . .
# Install Node packages
# We use yarn because npm is actually unable to resolve the dependency graph.
RUN yarn install
# Build the dashboard
RUN yarn build
# Deployment image
FROM nginx:1.21.3
ARG version_info
# Set working directory to nginx asset directory
WORKDIR /usr/share/nginx/html
# Remove default nginx static assets
RUN rm -rf ./*
COPY --from=build /app/config/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/build .
# Runtime static config
ENV REACT_APP_VERSION_INFO=${version_info}
server {
listen 80;
large_client_header_buffers 4 64k;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment