33 lines
955 B
Docker
33 lines
955 B
Docker
# syntax=docker/dockerfile:1
|
|
#
|
|
# React portal: Vite build in node, served by nginx with the SPA history fallback.
|
|
# Context is ./frontend.
|
|
#
|
|
# docker build -t hrms-frontend:local ./frontend
|
|
|
|
FROM node:22-alpine AS build
|
|
|
|
WORKDIR /src
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
|
|
# Empty VITE_API_BASE = same-origin requests. nginx.conf proxies API paths to
|
|
# backend-api:8000, so a LAN IP baked into the bundle can no longer send the
|
|
# browser to a different listener than the one serving the SPA (the localhost
|
|
# vs 127.0.0.1 vs Docker split that emptied /jobs).
|
|
# Override with --build-arg VITE_API_BASE=https://api.example.com only when the
|
|
# API is intentionally on another origin.
|
|
ARG VITE_API_BASE=
|
|
RUN printf 'VITE_API_BASE=%s\n' "$VITE_API_BASE" > .env.production.local \
|
|
&& npm run build
|
|
|
|
FROM nginx:1.27-alpine
|
|
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY --from=build /src/dist /usr/share/nginx/html
|
|
|
|
EXPOSE 80
|