2024-12-28 16:30:48 +01:00
|
|
|
|
# =========== 1) Build stage ===========
|
2025-12-26 08:45:47 +01:00
|
|
|
|
FROM node:22-alpine AS build
|
2024-12-28 16:30:48 +01:00
|
|
|
|
|
2026-01-01 14:02:38 +01:00
|
|
|
|
# Accept build arguments for Vite environment variables
|
|
|
|
|
|
ARG VITE_API_URL
|
|
|
|
|
|
ARG VITE_BASE_URL
|
|
|
|
|
|
ARG VITE_API_PORT
|
|
|
|
|
|
|
|
|
|
|
|
# Set them as environment variables for the build process
|
|
|
|
|
|
ENV VITE_API_URL=$VITE_API_URL
|
|
|
|
|
|
ENV VITE_BASE_URL=$VITE_BASE_URL
|
|
|
|
|
|
ENV VITE_API_PORT=$VITE_API_PORT
|
|
|
|
|
|
|
2024-12-28 16:30:48 +01:00
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
|
2025-12-26 08:45:47 +01:00
|
|
|
|
# Copy package files
|
2024-12-28 16:30:48 +01:00
|
|
|
|
COPY package*.json ./
|
2026-01-24 18:49:06 +01:00
|
|
|
|
#COPY /nginx.conf ./nginx.conf
|
2025-12-26 08:45:47 +01:00
|
|
|
|
|
|
|
|
|
|
# Install dependencies
|
2024-12-28 16:30:48 +01:00
|
|
|
|
RUN npm install
|
|
|
|
|
|
|
|
|
|
|
|
# Copy the rest of the frontend code
|
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
# Build the production bundle
|
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
|
|
# =========== 2) Serve stage ===========
|
|
|
|
|
|
FROM nginx:alpine
|
|
|
|
|
|
|
|
|
|
|
|
# Copy production build to Nginx html folder.
|
|
|
|
|
|
# Adjust /usr/src/app/build -> /usr/src/app/dist if you’re using Angular/Vue
|
2025-01-03 15:51:41 +01:00
|
|
|
|
#COPY --from=build /usr/src/app/build /usr/share/nginx/html
|
2025-12-26 08:45:47 +01:00
|
|
|
|
COPY --from=build /usr/src/app/dist /usr/share/nginx/html
|
2026-01-24 15:46:09 +01:00
|
|
|
|
# Copy custom nginx configuration for SPA routing
|
2026-01-24 18:49:06 +01:00
|
|
|
|
COPY --from=build /usr/src/app/nginx.conf /etc/nginx/conf.d/default.conf
|
2024-12-28 16:30:48 +01:00
|
|
|
|
# Expose HTTP port
|
|
|
|
|
|
EXPOSE 80
|
|
|
|
|
|
|
|
|
|
|
|
# Run Nginx in foreground
|
|
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|