Dockerupdate

This commit is contained in:
mukesh13
2025-06-23 21:55:13 +05:30
parent f4d6fb3075
commit fb0fbf8597

View File

@ -1,33 +1,38 @@
# Create this base image once and reuse
# docker build -f Dockerfile.base -t my-node-base .
# syntax=docker/dockerfile:1.4
# === Dockerfile.base (build once) ===
# FROM node:18-alpine
# RUN apk add --no-cache python3 make g++ vips-dev
# WORKDIR /app
# Use Alpine - no apt-get, much faster!
FROM node:18-alpine AS development
# === Main Dockerfile (super fast) ===
FROM my-node-base AS development
WORKDIR /app
# Copy package files
COPY package.json package-lock.json ./
# Install build tools with apk (seconds vs minutes)
RUN apk add --no-cache python3 make g++
# Install deps with cache
RUN --mount=type=cache,target=/root/.npm \
npm ci --legacy-peer-deps
# Copy package files first for better layer caching
COPY package.json package-lock.json* ./
# Copy source
# Install dependencies
RUN npm ci --legacy-peer-deps --no-optional
# Copy source code
COPY . .
ENV CI=true PORT=3000
ENV CI=true
ENV PORT=3000
CMD ["npm", "start"]
# Build stage
FROM development AS build
RUN npm run build
# Production
FROM nginx:alpine
COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf
# 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"
# Copy built app
COPY --from=build /app/build /usr/share/nginx/html
ENTRYPOINT ["nginx", "-g", "daemon off;"]