From 9d4dcbd9e0667ff83cc5a7e58ce8bdd57d42068a Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Mon, 16 Feb 2026 14:46:38 +0100 Subject: [PATCH] fix(backend/docker): Make `server` last (= default) build stage Without specifying an explicit build target it would build the `migrate` stage because it is the last stage in the Dockerfile. This caused deployment failures. - Follow-up to #12124 and 074be7ae --- autogpt_platform/backend/Dockerfile | 66 +++++++++++++++-------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/autogpt_platform/backend/Dockerfile b/autogpt_platform/backend/Dockerfile index 6037ed656f..2a9696d3e5 100644 --- a/autogpt_platform/backend/Dockerfile +++ b/autogpt_platform/backend/Dockerfile @@ -53,6 +53,38 @@ COPY autogpt_platform/backend/backend/data/partial_types.py ./backend/data/parti COPY autogpt_platform/backend/gen_prisma_types_stub.py ./ RUN poetry run prisma generate && poetry run gen-prisma-stub +# =============================== DB MIGRATOR =============================== # + +# Lightweight migrate stage - only needs Prisma CLI, not full Python environment +FROM debian:13-slim AS migrate + +WORKDIR /app/autogpt_platform/backend + +ENV DEBIAN_FRONTEND=noninteractive + +# Install only what's needed for prisma migrate: Node.js and minimal Python for prisma-python +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3.13 \ + python3-pip \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Copy Node.js from builder (needed for Prisma CLI) +COPY --from=builder /usr/bin/node /usr/bin/node +COPY --from=builder /usr/lib/node_modules /usr/lib/node_modules +COPY --from=builder /usr/bin/npm /usr/bin/npm + +# Copy Prisma binaries +COPY --from=builder /root/.cache/prisma-python/binaries /root/.cache/prisma-python/binaries + +# Install prisma-client-py directly (much smaller than copying full venv) +RUN pip3 install prisma>=0.15.0 --break-system-packages + +COPY autogpt_platform/backend/schema.prisma ./ +COPY autogpt_platform/backend/backend/data/partial_types.py ./backend/data/partial_types.py +COPY autogpt_platform/backend/gen_prisma_types_stub.py ./ +COPY autogpt_platform/backend/migrations ./migrations + # ============================== BACKEND SERVER ============================== # FROM debian:13-slim AS server @@ -100,41 +132,11 @@ COPY autogpt_platform/backend/poetry.lock autogpt_platform/backend/pyproject.tom # Copy backend code + docs (for Copilot docs search) COPY autogpt_platform/backend ./ COPY docs /app/docs +# Install the project package to create entry point scripts in .venv/bin/ +# (e.g., rest, executor, ws, db, scheduler, notification - see [tool.poetry.scripts]) RUN POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true \ poetry install --no-ansi --only-root ENV PORT=8000 CMD ["rest"] - -# =============================== DB MIGRATOR =============================== # - -# Lightweight migrate stage - only needs Prisma CLI, not full Python environment -FROM debian:13-slim AS migrate - -WORKDIR /app/autogpt_platform/backend - -ENV DEBIAN_FRONTEND=noninteractive - -# Install only what's needed for prisma migrate: Node.js and minimal Python for prisma-python -RUN apt-get update && apt-get install -y --no-install-recommends \ - python3.13 \ - python3-pip \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -# Copy Node.js from builder (needed for Prisma CLI) -COPY --from=builder /usr/bin/node /usr/bin/node -COPY --from=builder /usr/lib/node_modules /usr/lib/node_modules -COPY --from=builder /usr/bin/npm /usr/bin/npm - -# Copy Prisma binaries -COPY --from=builder /root/.cache/prisma-python/binaries /root/.cache/prisma-python/binaries - -# Install prisma-client-py directly (much smaller than copying full venv) -RUN pip3 install prisma>=0.15.0 --break-system-packages - -COPY autogpt_platform/backend/schema.prisma ./ -COPY autogpt_platform/backend/backend/data/partial_types.py ./backend/data/partial_types.py -COPY autogpt_platform/backend/gen_prisma_types_stub.py ./ -COPY autogpt_platform/backend/migrations ./migrations