Files
ai-rpg/deploy/Dockerfile.frontend

33 lines
998 B
Docker
Raw Permalink Normal View History

2026-06-20 19:13:05 +03:00
# Build stage
FROM node:20-alpine AS build
WORKDIR /app
2026-06-20 22:21:47 +03:00
# Bake the API base URL into the Vite bundle at build time.
# Default is the relative "/api" — works when the app is served from the same
# origin as the /api reverse proxy (nginx in front of the backend).
ARG VITE_API_BASE_URL=/api
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
# Copy frontend manifest first for better layer caching
2026-06-20 19:13:05 +03:00
COPY frontend/package*.json ./
RUN npm install
2026-06-20 22:21:47 +03:00
# Copy the rest of the frontend source and build
2026-06-20 19:13:05 +03:00
COPY frontend/ .
RUN npm run build
2026-06-20 22:21:47 +03:00
# -------------------------------------------------------------------
# Serve stage — nginx
# -------------------------------------------------------------------
2026-06-20 19:13:05 +03:00
FROM nginx:1.24-alpine
2026-06-20 22:21:47 +03:00
# Copy built static assets from the build stage
2026-06-20 19:13:05 +03:00
COPY --from=build /app/dist /usr/share/nginx/html
2026-06-20 22:21:47 +03:00
# Copy nginx config (path is relative to the build context, which is the project root)
2026-06-20 19:13:05 +03:00
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
2026-06-20 22:21:47 +03:00
2026-06-20 19:13:05 +03:00
EXPOSE 80
2026-06-20 22:21:47 +03:00
2026-06-20 19:13:05 +03:00
CMD ["nginx", "-g", "daemon off;"]