infra: Add multi-stage frontend build to Docker
Nginx container now builds the Vue frontend in a Node stage instead of mounting local dist/ files. This means: - No need to commit dist/ or build locally before deploying - docker compose up --build handles everything end-to-end - Removed obsolete compose version key Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
21
docker/Dockerfile.nginx
Normal file
21
docker/Dockerfile.nginx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Multi-stage build: compile Vue frontend, serve with nginx
|
||||||
|
# Stage 1: Build the frontend
|
||||||
|
FROM node:22-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
# Cache dependencies — copy manifests first
|
||||||
|
COPY package.json package-lock.json* ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Copy source and build
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Serve with nginx
|
||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Copy built frontend
|
||||||
|
COPY --from=builder /build/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
@@ -61,13 +59,14 @@ services:
|
|||||||
- "8088:3000"
|
- "8088:3000"
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:alpine
|
build:
|
||||||
|
context: ../frontend
|
||||||
|
dockerfile: ../docker/Dockerfile.nginx
|
||||||
container_name: corrosion-nginx
|
container_name: corrosion-nginx
|
||||||
ports:
|
ports:
|
||||||
- "8087:80"
|
- "8087:80"
|
||||||
volumes:
|
volumes:
|
||||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
- ../frontend/dist:/usr/share/nginx/html:ro
|
|
||||||
- map_data:/data/maps:ro
|
- map_data:/data/maps:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
- api
|
- api
|
||||||
|
|||||||
Reference in New Issue
Block a user