
All checks were successful
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Successful in 1m20s
58 lines
1.1 KiB
Docker
58 lines
1.1 KiB
Docker
# Multi-stage build for production
|
|
FROM node:23-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 . .
|
|
|
|
# Set environment variables for build
|
|
ARG VITE_API_URL
|
|
ENV VITE_API_URL=${VITE_API_URL}
|
|
|
|
# Build the application
|
|
RUN npm run build-only
|
|
|
|
# Production stage
|
|
FROM nginx:alpine
|
|
|
|
# Copy built assets from build stage
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
|
|
# Copy nginx configuration for SPA routing
|
|
RUN echo 'server { \
|
|
listen 80; \
|
|
location / { \
|
|
root /usr/share/nginx/html; \
|
|
index index.html; \
|
|
try_files $uri $uri/ /index.html; \
|
|
} \
|
|
}' > /etc/nginx/conf.d/default.conf
|
|
|
|
# Expose port 80
|
|
EXPOSE 80
|
|
|
|
# Start nginx
|
|
CMD ["nginx", "-g", "daemon off;"] |