# syntax=docker/dockerfile:1.4 # Build stage FROM node:lts AS build WORKDIR /app # Copy package files COPY package.json package-lock.json ./ # Install dependencies with legacy peer deps to handle @reach/router conflict RUN npm ci --legacy-peer-deps # Copy source code COPY . . # Build the Gatsby app RUN npm run build # Production stage with Nginx FROM nginx:alpine AS production # Create simple nginx config for Gatsby with client-side routing support RUN echo 'server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { expires 1y; add_header Cache-Control "public, immutable"; } }' > /etc/nginx/conf.d/default.conf # Copy built Gatsby files (builds to 'public' directory) COPY --from=build /app/public /usr/share/nginx/html # Expose port 80 EXPOSE 80 # Start nginx CMD ["nginx", "-g", "daemon off;"]