42 lines
894 B
Docker
42 lines
894 B
Docker
# Stage 1: Build the Vue SPA application
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy dependency definitions
|
|
COPY package*.json ./
|
|
|
|
# Install all dependencies (including devDependencies required for Vite build)
|
|
RUN npm ci
|
|
|
|
# Pass build arguments for environment variables
|
|
ARG VITE_API_URL=""
|
|
ARG VITE_ENV=production
|
|
|
|
ENV VITE_API_URL=$VITE_API_URL
|
|
ENV VITE_ENV=$VITE_ENV
|
|
|
|
# Copy application source files
|
|
COPY . .
|
|
|
|
# Build production static bundle
|
|
RUN npm run build
|
|
|
|
# Stage 2: Serve application with Nginx
|
|
FROM nginx:alpine AS runner
|
|
|
|
# Remove default nginx static assets
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
# Copy custom nginx configuration
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Copy compiled assets from the builder stage
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Expose web server port
|
|
EXPOSE 80
|
|
|
|
# Run nginx in foreground
|
|
CMD ["nginx", "-g", "daemon off;"]
|