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