7eb44a7ae6
CORS prevented from loading
41 lines
934 B
Docker
41 lines
934 B
Docker
# =========== 1) Build stage ===========
|
||
FROM node:22-alpine AS build
|
||
|
||
# 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
|
||
|
||
WORKDIR /usr/src/app
|
||
|
||
# Copy package files
|
||
COPY package*.json ./
|
||
|
||
# Install dependencies
|
||
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
|
||
#COPY --from=build /usr/src/app/build /usr/share/nginx/html
|
||
COPY --from=build /usr/src/app/dist /usr/share/nginx/html
|
||
|
||
# Expose HTTP port
|
||
EXPOSE 80
|
||
|
||
# Run Nginx in foreground
|
||
CMD ["nginx", "-g", "daemon off;"]
|