Files
tuxmate/Dockerfile
NIJAT a97779fa3b fix: use static export for both CF Pages and Docker
- Set output: 'export' in next.config.ts (creates /out directory)
- Replaced Node.js standalone Dockerfile with nginx serving static files
- Updated docker-compose.yml for nginx (port 80)
- Both CF Pages and Docker now use the same static build
2025-12-29 18:40:07 +04:00

48 lines
1.1 KiB
Docker

# Stage 1: Build the application
FROM node:20-alpine AS builder
WORKDIR /app
# Disable Next.js telemetry during build
ENV NEXT_TELEMETRY_DISABLED=1
# Copy package files
COPY package.json package-lock.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build Next.js application (static export to /app/out)
RUN npm run build
# Stage 2: Serve static files with nginx
FROM nginx:alpine AS runner
# Copy custom nginx config for SPA routing
RUN echo 'server { \
listen 80; \
listen [::]:80; \
root /usr/share/nginx/html; \
index index.html; \
location / { \
try_files $uri $uri/ $uri.html /index.html; \
} \
location /_next/static/ { \
expires 1y; \
add_header Cache-Control "public, immutable"; \
} \
gzip on; \
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript; \
}' > /etc/nginx/conf.d/default.conf
# Copy static files from builder
COPY --from=builder /app/out /usr/share/nginx/html
# Expose port
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]