aset Dockerfile

This commit is contained in:
2025-04-09 11:48:48 +03:30
parent 6ec8b08618
commit aaecf79c82
5 changed files with 80 additions and 38 deletions
+21 -12
View File
@@ -3,30 +3,39 @@ FROM node:22-alpine AS builder
WORKDIR /app
# Install system dependencies (if needed)
RUN apk add --no-cache python3 make g++
# Install system dependencies for native modules
RUN apk add --no-cache python3 make g++ git
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm i --force
RUN npm install --force
# Copy source code
COPY . .
# Build React app
# Build Next.js application
RUN npm run build
# Production stage
FROM nginx:1.25-alpine
FROM node:22-alpine AS production
# Copy nginx config
COPY docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /app
# Copy build artifacts
COPY --from=builder /app/build /usr/share/nginx/html
# Enable production mode
ENV NODE_ENV production
# Expose and run
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# Install dependencies for production (curl for health checks)
RUN apk add --no-cache curl
# Copy built assets from builder
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
# Expose the Next.js port
EXPOSE 3000
# Start the server
CMD ["node", "server.js"]