الملفات
dockerfile/Dockerfile
2025-09-08 10:18:08 +00:00

42 أسطر
867 B
Docker

# Build stage
FROM node:18-alpine AS builder
WORKDIR /app
# Copy package files
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
# Install dependencies
RUN \
if [ -f yarn.lock ]; then yarn install; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else npm install; \
fi
# Copy source code
COPY . .
# Build the app
RUN npm run build
# Production stage
FROM nginx:alpine
# Copy nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Create the html directory if it doesn't exist
RUN mkdir -p /usr/share/nginx/html
# Remove any existing files in html directory
RUN rm -rf /usr/share/nginx/html/*
# Copy built app from builder stage
COPY --from=builder /app/.next /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]