Attempt #2 to fix CORS issue and docker build.

This commit is contained in:
Karmaa
2025-02-22 00:24:47 -06:00
parent 946f5daaa9
commit 1addd43039

View File

@@ -1,30 +1,32 @@
# Use Node.js base image for building frontend # Build everything in one stage
FROM --platform=$BUILDPLATFORM node:18-alpine AS builder FROM --platform=$BUILDPLATFORM node:18-alpine AS builder
# Install dependencies # Install nginx and dependencies
RUN apk add --no-cache npm RUN apk add --no-cache nginx npm
# Set working directory
WORKDIR /app WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install
# Copy project files and build frontend # Copy the entire project (frontend and backend)
COPY ./ ./ COPY ./ ./
# Build the frontend
RUN npm run build RUN npm run build
# Final stage with nginx # Configure nginx
FROM --platform=$TARGETPLATFORM nginx:alpine
# Copy built frontend from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy nginx config
COPY docker/nginx.conf /etc/nginx/nginx.conf COPY docker/nginx.conf /etc/nginx/nginx.conf
# Copy built frontend to nginx's web directory
COPY ./dist /usr/share/nginx/html
# Expose necessary ports # Expose necessary ports
EXPOSE 8080 EXPOSE 8080
EXPOSE 8081 EXPOSE 8081
# Use entrypoint.sh to start backend and nginx # Use entrypoint.sh to run both the backend and nginx
COPY --from=builder /app/src/backend/entrypoint.sh /app/src/backend/entrypoint.sh
RUN chmod +x /app/src/backend/entrypoint.sh RUN chmod +x /app/src/backend/entrypoint.sh
ENTRYPOINT ["/app/src/backend/entrypoint.sh"] ENTRYPOINT ["/app/src/backend/entrypoint.sh"]