From 22fce19050e18f5619a7f44a49f85753c4a17d93 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 21 Nov 2025 11:58:56 +0000 Subject: [PATCH] fix: Resolve Docker build failures for frontend and backend Backend fixes: - Add g++ and build-essential for complete C++ compilation support - Upgrade pip, setuptools, and wheel before installing dependencies - Ensures psutil and other packages with native extensions build correctly Frontend fixes: - Add build arguments for NEXT_PUBLIC_API_URL and NEXT_PUBLIC_WS_URL - Pass environment variables during Docker build stage - Set default values to prevent undefined destination in Next.js rewrites - Configure docker-compose to pass build arguments to frontend service These changes resolve: - psutil build failure: "ERROR: Failed building wheel for psutil" - Next.js build error: "Invalid rewrite found" with undefined destination --- backend/Dockerfile | 5 +++++ docker-compose.yml | 3 +++ frontend/Dockerfile | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/backend/Dockerfile b/backend/Dockerfile index 2854a57..7fe7d5f 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -6,11 +6,16 @@ WORKDIR /app # Install system dependencies for building Python packages RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ + g++ \ python3-dev \ + build-essential \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install dependencies COPY requirements.txt . +# Upgrade pip and setuptools first +RUN pip install --no-cache-dir --upgrade pip setuptools wheel +# Install dependencies with user flag RUN pip install --no-cache-dir --user -r requirements.txt # Production stage diff --git a/docker-compose.yml b/docker-compose.yml index c905968..389b23e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,6 +30,9 @@ services: build: context: ./frontend dockerfile: Dockerfile + args: + - NEXT_PUBLIC_API_URL=http://localhost:8000 + - NEXT_PUBLIC_WS_URL=ws://localhost:8000 container_name: bot-dashboard-frontend ports: - "3000:3000" diff --git a/frontend/Dockerfile b/frontend/Dockerfile index e5402db..77b35fd 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -16,6 +16,14 @@ COPY . . ENV NEXT_TELEMETRY_DISABLED 1 ENV NODE_ENV production +# Accept build arguments for API URLs +ARG NEXT_PUBLIC_API_URL=http://localhost:8000 +ARG NEXT_PUBLIC_WS_URL=ws://localhost:8000 + +# Set environment variables for Next.js build +ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL +ENV NEXT_PUBLIC_WS_URL=$NEXT_PUBLIC_WS_URL + # Build the application RUN npm run build @@ -46,4 +54,8 @@ EXPOSE 3000 ENV PORT 3000 ENV HOSTNAME "0.0.0.0" +# Runtime environment variables (can be overridden by docker-compose) +ENV NEXT_PUBLIC_API_URL=http://localhost:8000 +ENV NEXT_PUBLIC_WS_URL=ws://localhost:8000 + CMD ["node", "server.js"] -- 2.49.1