mitlist/fe/Dockerfile.prod
mohamad cb51186830 feat: Add production deployment configuration and environment setup
- Introduced `docker-compose.prod.yml` to define services for production deployment, including PostgreSQL, FastAPI backend, frontend, and Redis.
- Created `env.production.template` to outline necessary environment variables for production, ensuring sensitive data is not committed.
- Added `PRODUCTION.md` as a deployment guide detailing the setup process using Docker Compose and Gitea Actions for CI/CD.
- Implemented Gitea workflows for build, test, and deployment processes to streamline production updates.
- Updated backend and frontend Dockerfiles for optimized production builds and configurations.
- Enhanced application settings to support environment-specific configurations, including CORS and health checks.
2025-05-28 08:23:22 +02:00

68 lines
1.5 KiB
Docker

# Multi-stage build for production
FROM node:24-alpine AS base
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production && npm cache clean --force
# Development stage
FROM base AS development
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["npm", "run", "dev"]
# Build stage
FROM base AS build
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies (including devDependencies)
RUN npm ci
# Copy source code
COPY . .
# Build arguments for environment variables
ARG VITE_API_URL
ARG VITE_SENTRY_DSN
ARG VITE_ROUTER_MODE=history
# Set environment variables for build
ENV VITE_API_URL=$VITE_API_URL
ENV VITE_SENTRY_DSN=$VITE_SENTRY_DSN
ENV VITE_ROUTER_MODE=$VITE_ROUTER_MODE
ENV NODE_ENV=production
# Build the application
RUN npm run build
# Production stage
FROM node:24-alpine AS production # Using node image to use serve
# Install serve globally
RUN npm install -g serve
# Set working directory
WORKDIR /app
# Copy built assets from build stage
COPY --from=build /app/dist .
# Create a default static.json for serve to handle SPA routing
RUN echo '{ \n "rewrites": [ \n { "source": "**", "destination": "/index.html" } \n ] \n}' > static.json
# Expose port 3000 (serve default)
EXPOSE 3000
# Health check (optional, depends on serve capabilities or custom health endpoint)
# HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
# CMD curl -f http://localhost:3000/ || exit 1
# Start serve
CMD ["serve", "-s", ".", "-l", "3000"]