Dockerfile
820 bytes
| 1 | # syntax=docker/dockerfile:1 |
|---|---|
| 2 | |
| 3 | # --- Build stage --- |
| 4 | FROM node:22-alpine AS build |
| 5 | WORKDIR /app |
| 6 | |
| 7 | # Vite bakes VITE_* env vars into the bundle at build time. |
| 8 | # Pass the backend URL as a build arg so it can be overridden per environment |
| 9 | # (local docker compose, CI, VPS deploy, ...) without rebaking the Dockerfile. |
| 10 | ARG VITE_API_BASE_URL=http://localhost:90/api/v1/ |
| 11 | ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} |
| 12 | |
| 13 | COPY package*.json ./ |
| 14 | RUN npm ci |
| 15 | |
| 16 | COPY . . |
| 17 | RUN npm run build |
| 18 | |
| 19 | # --- Production stage --- |
| 20 | FROM nginx:alpine AS production |
| 21 | COPY --from=build /app/dist /usr/share/nginx/html |
| 22 | COPY <<'EOF' /etc/nginx/conf.d/default.conf |
| 23 | server { |
| 24 | listen 80; |
| 25 | server_name _; |
| 26 | root /usr/share/nginx/html; |
| 27 | index index.html; |
| 28 | |
| 29 | location / { |
| 30 | try_files $uri $uri/ /index.html; |
| 31 | } |
| 32 | } |
| 33 | EOF |
| 34 | |
| 35 | EXPOSE 80 |
| 36 | CMD ["nginx", "-g", "daemon off;"] |
| 37 | |