Dockerupdate
This commit is contained in:
24
Dockerfile
24
Dockerfile
@ -1,18 +1,17 @@
|
||||
# syntax=docker/dockerfile:1.4
|
||||
|
||||
# Use Alpine - no apt-get, much faster!
|
||||
FROM node:18-alpine AS development
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build tools with apk (seconds vs minutes)
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
# Copy package files first for better layer caching
|
||||
COPY package.json package-lock.json* ./
|
||||
# Copy package files
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --legacy-peer-deps --no-optional
|
||||
# Install dependencies
|
||||
RUN npm ci --legacy-peer-deps
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
@ -29,10 +28,17 @@ RUN npm run build
|
||||
# Production stage
|
||||
FROM nginx:alpine AS production
|
||||
|
||||
# Copy nginx config if it exists, otherwise use default
|
||||
COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf 2>/dev/null || echo "Using default nginx config"
|
||||
WORKDIR /usr/share/nginx/html
|
||||
|
||||
# Remove default nginx files
|
||||
RUN rm -rf ./*
|
||||
|
||||
# Copy built app
|
||||
COPY --from=build /app/build /usr/share/nginx/html
|
||||
COPY --from=build /app/build .
|
||||
|
||||
# Copy nginx config if it exists
|
||||
COPY .nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
||||
Reference in New Issue
Block a user