Docker update
This commit is contained in:
12
Dockerfile
12
Dockerfile
@ -1,20 +1,18 @@
|
|||||||
# Build stage
|
|
||||||
FROM node:18 AS build
|
FROM node:18 AS build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy only package files first (better caching)
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install --legacy-peer-deps
|
|
||||||
|
|
||||||
|
# This layer will be cached if package.json doesn't change
|
||||||
|
RUN npm ci --legacy-peer-deps
|
||||||
|
|
||||||
|
# Copy source code (this changes more often)
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Production stage
|
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
COPY --from=build /app/public /usr/share/nginx/html
|
COPY --from=build /app/public /usr/share/nginx/html
|
||||||
|
|
||||||
# Fix for Gatsby client-side routing
|
|
||||||
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
|
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
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
Reference in New Issue
Block a user