From d2a70e641f28df43233b4348a214757a69e2736f Mon Sep 17 00:00:00 2001 From: Motzik20 Date: Mon, 5 Jan 2026 21:48:26 +0100 Subject: [PATCH] fix: prod docker compose failiing to build --- backend/Dockerfile | 9 +++++++-- docker-compose.prod.yml | 34 ++-------------------------------- frontend/.gitignore | 1 + frontend/Dockerfile | 4 +++- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 19f1185..0476340 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -19,10 +19,15 @@ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload FROM base AS prod RUN addgroup --system appgroup && adduser --system --group appuser -RUN poetry install --without dev--no-interaction --no-ansi +RUN poetry install --without dev --no-interaction --no-ansi COPY ./app ./app COPY alembic.ini ./ + +RUN printf '#!/bin/bash\nset -e\necho "Running database migrations..."\npoetry run alembic upgrade head\necho "Starting server..."\nexec "$@"\n' > /backend/entrypoint.sh && chmod +x /backend/entrypoint.sh RUN chown -R appuser:appgroup /backend +# Set HOME for appuser and ensure Poetry doesn't create virtualenvs +ENV HOME=/tmp +ENV POETRY_VIRTUALENVS_CREATE=false USER appuser EXPOSE 8000 -CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file +ENTRYPOINT ["/backend/entrypoint.sh"] \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 9d7a26d..d194d42 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -5,18 +5,9 @@ services: build: target: prod command: - [ - "/bin/bash", - "./scripts/start.sh", - "uvicorn", - "app.main:app", - "--host", - "0.0.0.0", - "--port", - "8000", - ] + ["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] environment: - CORS_ORIGINS: ${CORS_ORIGINS:-} + CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:3000,http://127.0.0.1:3000} restart: always celery-worker: @@ -26,27 +17,6 @@ services: ["poetry", "run", "celery", "-A", "app.celery_app", "worker", "--loglevel=info"] restart: always - flower: - build: - context: ./backend - target: prod - env_file: - - ./backend/.env - environment: - DATABASE_URL: postgresql+psycopg://${POSTGRES_USER:-chrono}:${POSTGRES_PASSWORD:-chrono}@db:5432/${POSTGRES_DB:-chrono} - REDIS_URL: ${REDIS_URL:-redis://redis:6379/0} - command: - ["poetry", "run", "celery", "-A", "app.celery_app", "flower", "--port=5555"] - depends_on: - db: - condition: service_healthy - redis: - condition: service_healthy - working_dir: /backend - ports: - - "5555:5555" - restart: always - frontend: build: target: prod diff --git a/frontend/.gitignore b/frontend/.gitignore index 5ef6a52..487e060 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -9,6 +9,7 @@ !.yarn/plugins !.yarn/releases !.yarn/versions +.pnpm-store # testing /coverage diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 473325c..d8646bb 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -4,6 +4,8 @@ WORKDIR /app RUN corepack enable && corepack prepare pnpm@latest --activate +RUN pnpm config set store-dir /tmp/pnpm-store + COPY package.json pnpm-lock.yaml* ./ # Development stage @@ -21,7 +23,7 @@ ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL RUN pnpm build FROM base AS prod -RUN addgroup -S appgroup && adduser -S -G appgroup +RUN addgroup -S appgroup && adduser -S -G appgroup appuser RUN pnpm install --frozen-lockfile --prod COPY --from=builder /app/.next ./.next COPY --from=builder /app/public ./public