fix: correct how Dockerfile copies dirs

This commit is contained in:
2025-07-24 17:24:00 +00:00
parent 3eb1522525
commit 1fe672d293
3 changed files with 25 additions and 15 deletions

View File

@@ -2,9 +2,15 @@ FROM python:3.11-slim
WORKDIR /app WORKDIR /app
COPY requirements.txt . # Copy requirements first
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r 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"]

View File

@@ -1,8 +1,14 @@
FROM node:20-alpine AS builder # --- Build React app ---
FROM node:22-alpine AS builder
WORKDIR /app 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 FROM nginx:alpine
COPY --from=builder /app/build /usr/share/nginx/html COPY --from=builder /app/build /usr/share/nginx/html

View File

@@ -18,7 +18,7 @@ while True:
db_user = "minxa" db_user = "minxa"
db_password = secrets.token_urlsafe(16) db_password = secrets.token_urlsafe(16)
db_name = "minxadb" db_name = "minxadb"
db_host = "minxa-db" db_host = "db"
db_port = 5432 db_port = 5432
hashids_salt = secrets.token_urlsafe(32) hashids_salt = secrets.token_urlsafe(32)
@@ -53,10 +53,8 @@ frontend_env_path.write_text(frontend_env)
print(f"✅ frontend/.env written") print(f"✅ frontend/.env written")
# === Generate docker-compose.generated.yml === # # === Generate docker-compose.generated.yml === #
compose_yml = f"""version: "3.9" compose_yml = f"""services:
db:
services:
minxa-db:
image: postgres:16 image: postgres:16
environment: environment:
POSTGRES_USER: {db_user} POSTGRES_USER: {db_user}
@@ -72,26 +70,26 @@ services:
networks: networks:
- appnet - appnet
minxa-backend: backend:
build: build:
context: ./backend context: ./backend
env_file: env_file:
- ./backend/.env - ./backend/.env
depends_on: depends_on:
minxa-db: db:
condition: service_healthy condition: service_healthy
ports: ports:
- "8000:8000" - "8000:8000"
networks: networks:
- appnet - appnet
minxa-frontend: frontend:
build: build:
context: ./frontend context: ./frontend
env_file: env_file:
- ./frontend/.env - ./frontend/.env
depends_on: depends_on:
- minxa-backend - backend
ports: ports:
- "3000:80" - "3000:80"
networks: networks: