From 1fe672d293eb357b8e5048c9756b97f195d7f844 Mon Sep 17 00:00:00 2001 From: Giovani Rodriguez Date: Thu, 24 Jul 2025 17:24:00 +0000 Subject: [PATCH] fix: correct how Dockerfile copies dirs --- backend/Dockerfile | 12 +++++++++--- frontend/Dockerfile | 12 +++++++++--- generate_configs.py | 16 +++++++--------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 628cc31..ae2d6da 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -2,9 +2,15 @@ FROM python:3.11-slim WORKDIR /app -COPY requirements.txt . +# Copy requirements first +COPY backend/requirements.txt . + RUN pip install --no-cache-dir -r requirements.txt -COPY . . +# ✅ Copy the entire backend directory as /app/backend +COPY backend/ ./backend -CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] +# ✅ Set PYTHONPATH to include /app +ENV PYTHONPATH=/app + +CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/frontend/Dockerfile b/frontend/Dockerfile index d54402b..2a6d039 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,8 +1,14 @@ -FROM node:20-alpine AS builder +# --- Build React app --- +FROM node:22-alpine AS builder WORKDIR /app -COPY . . -RUN npm install && npm run build +COPY frontend/package*.json ./ +RUN npm install + +COPY frontend/ ./ +RUN npm run build + +# --- Serve with Nginx --- FROM nginx:alpine COPY --from=builder /app/build /usr/share/nginx/html diff --git a/generate_configs.py b/generate_configs.py index d55f0fc..f814ac7 100644 --- a/generate_configs.py +++ b/generate_configs.py @@ -18,7 +18,7 @@ while True: db_user = "minxa" db_password = secrets.token_urlsafe(16) db_name = "minxadb" -db_host = "minxa-db" +db_host = "db" db_port = 5432 hashids_salt = secrets.token_urlsafe(32) @@ -53,10 +53,8 @@ frontend_env_path.write_text(frontend_env) print(f"✅ frontend/.env written") # === Generate docker-compose.generated.yml === # -compose_yml = f"""version: "3.9" - -services: - minxa-db: +compose_yml = f"""services: + db: image: postgres:16 environment: POSTGRES_USER: {db_user} @@ -72,26 +70,26 @@ services: networks: - appnet - minxa-backend: + backend: build: context: ./backend env_file: - ./backend/.env depends_on: - minxa-db: + db: condition: service_healthy ports: - "8000:8000" networks: - appnet - minxa-frontend: + frontend: build: context: ./frontend env_file: - ./frontend/.env depends_on: - - minxa-backend + - backend ports: - "3000:80" networks: