Dockercommit

This commit is contained in:
mukesh13
2025-06-23 17:02:45 +05:30
parent 2119c55e06
commit 0805181211
10 changed files with 39 additions and 36 deletions

View File

@ -1,24 +1,18 @@
# syntax=docker/dockerfile:1.4
# Build stage
FROM node:lts AS build
FROM node:18-alpine AS build
WORKDIR /app
# Set environment variables to help with sharp installation
ENV SHARP_IGNORE_GLOBAL_LIBVIPS=1
ENV npm_config_sharp_binary_host="https://npmjs.org/mirrors/sharp"
ENV npm_config_sharp_libvips_binary_host="https://npmjs.org/mirrors/sharp-libvips"
# Install build dependencies
RUN apk add --no-cache python3 make g++
# Copy package files
COPY package.json package-lock.json ./
# Install dependencies with legacy peer deps and increased timeout
# Use --no-optional to skip optional dependencies that might cause issues
RUN npm config set fetch-timeout 600000 && \
npm config set fetch-retry-mintimeout 10000 && \
npm config set fetch-retry-maxtimeout 60000 && \
npm install --legacy-peer-deps --no-optional --verbose
# Install dependencies
RUN npm install --legacy-peer-deps
# Copy source code
COPY . .
@ -26,17 +20,15 @@ COPY . .
# Build the Gatsby app
RUN npm run build
# Production stage with Nginx
# Production stage
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 nginx config
RUN echo 'server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf
# Copy built Gatsby files (builds to 'public' directory)
# Copy built files
COPY --from=build /app/public /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]