From 609e0a82ca7b7a1cc43f6577fb0c73f6106f0998 Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Mon, 6 Jan 2025 16:27:49 +0100 Subject: [PATCH] fix docker build issues - fix .dockerignore - fixes .venv being erroneously copied over from local - fixes build context bloat (300MB -> 2.5MB) - fix warnings about entrypoint script not being installed - workaround for Poetry bug where `packages.[i].format` is now suddenly required --- .dockerignore | 56 +++++++++++++++++-------- autogpt_platform/backend/Dockerfile | 18 ++++---- autogpt_platform/backend/pyproject.toml | 2 +- autogpt_platform/market/Dockerfile | 15 ++++--- 4 files changed, 55 insertions(+), 36 deletions(-) diff --git a/.dockerignore b/.dockerignore index 0cf6b446c3b7..2690d1a74071 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,40 +1,60 @@ # Ignore everything by default, selectively add things to context -classic/run - -# AutoGPT +* + +# Platform - Libs +!autogpt_platform/autogpt_libs/autogpt_libs/ +!autogpt_platform/autogpt_libs/pyproject.toml +!autogpt_platform/autogpt_libs/poetry.lock +!autogpt_platform/autogpt_libs/README.md + +# Platform - Backend +!autogpt_platform/backend/backend/ +!autogpt_platform/backend/schema.prisma +!autogpt_platform/backend/pyproject.toml +!autogpt_platform/backend/poetry.lock +!autogpt_platform/backend/README.md + +# Platform - Market +!autogpt_platform/market/market/ +!autogpt_platform/market/scripts.py +!autogpt_platform/market/schema.prisma +!autogpt_platform/market/pyproject.toml +!autogpt_platform/market/poetry.lock +!autogpt_platform/market/README.md + +# Platform - Frontend +!autogpt_platform/frontend/src/ +!autogpt_platform/frontend/public/ +!autogpt_platform/frontend/package.json +!autogpt_platform/frontend/yarn.lock +!autogpt_platform/frontend/tsconfig.json +!autogpt_platform/frontend/README.md +## config +!autogpt_platform/frontend/*.config.* +!autogpt_platform/frontend/.env.* + +# Classic - AutoGPT !classic/original_autogpt/autogpt/ !classic/original_autogpt/pyproject.toml !classic/original_autogpt/poetry.lock !classic/original_autogpt/README.md !classic/original_autogpt/tests/ -# Benchmark +# Classic - Benchmark !classic/benchmark/agbenchmark/ !classic/benchmark/pyproject.toml !classic/benchmark/poetry.lock !classic/benchmark/README.md -# Forge +# Classic - Forge !classic/forge/ !classic/forge/pyproject.toml !classic/forge/poetry.lock !classic/forge/README.md -# Frontend +# Classic - Frontend !classic/frontend/build/web/ -# Platform -!autogpt_platform/ - # Explicitly re-ignore some folders .* **/__pycache__ - -autogpt_platform/frontend/.next/ -autogpt_platform/frontend/node_modules -autogpt_platform/frontend/.env.example -autogpt_platform/frontend/.env.local -autogpt_platform/backend/.env -autogpt_platform/backend/.venv/ - -autogpt_platform/market/.env diff --git a/autogpt_platform/backend/Dockerfile b/autogpt_platform/backend/Dockerfile index 22b9d9bb0bd0..91a136026557 100644 --- a/autogpt_platform/backend/Dockerfile +++ b/autogpt_platform/backend/Dockerfile @@ -17,12 +17,11 @@ RUN apt-get install -y libz-dev RUN apt-get install -y libssl-dev RUN apt-get install -y postgresql-client -ENV POETRY_VERSION=1.8.3 ENV POETRY_HOME=/opt/poetry ENV POETRY_NO_INTERACTION=1 ENV POETRY_VIRTUALENVS_CREATE=false ENV PATH=/opt/poetry/bin:$PATH - + # Upgrade pip and setuptools to fix security vulnerabilities RUN pip3 install --upgrade pip setuptools @@ -32,25 +31,21 @@ RUN pip3 install poetry COPY autogpt_platform/autogpt_libs /app/autogpt_platform/autogpt_libs COPY autogpt_platform/backend/poetry.lock autogpt_platform/backend/pyproject.toml /app/autogpt_platform/backend/ WORKDIR /app/autogpt_platform/backend -RUN poetry config virtualenvs.create false \ - && poetry install --no-interaction --no-ansi +RUN poetry install --no-ansi --no-root # Generate Prisma client COPY autogpt_platform/backend/schema.prisma ./ -RUN poetry config virtualenvs.create false \ - && poetry run prisma generate +RUN poetry run prisma generate FROM python:3.11.10-slim-bookworm AS server_dependencies WORKDIR /app -ENV POETRY_VERSION=1.8.3 -ENV POETRY_HOME=/opt/poetry -ENV POETRY_NO_INTERACTION=1 -ENV POETRY_VIRTUALENVS_CREATE=false +ENV POETRY_HOME=/opt/poetry \ + POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_CREATE=false ENV PATH=/opt/poetry/bin:$PATH - # Upgrade pip and setuptools to fix security vulnerabilities RUN pip3 install --upgrade pip setuptools @@ -76,6 +71,7 @@ WORKDIR /app/autogpt_platform/backend FROM server_dependencies AS server COPY autogpt_platform/backend /app/autogpt_platform/backend +RUN poetry install --no-ansi --only-root ENV DATABASE_URL="" ENV PORT=8000 diff --git a/autogpt_platform/backend/pyproject.toml b/autogpt_platform/backend/pyproject.toml index 2637dc6ef85f..f03f9b8ae995 100644 --- a/autogpt_platform/backend/pyproject.toml +++ b/autogpt_platform/backend/pyproject.toml @@ -4,7 +4,7 @@ version = "0.3.4" description = "A platform for building AI-powered agentic workflows" authors = ["AutoGPT "] readme = "README.md" -packages = [{ include = "backend" }] +packages = [{ include = "backend", format = "sdist" }] [tool.poetry.dependencies] diff --git a/autogpt_platform/market/Dockerfile b/autogpt_platform/market/Dockerfile index dbd12565db3c..bf6598d75ed6 100644 --- a/autogpt_platform/market/Dockerfile +++ b/autogpt_platform/market/Dockerfile @@ -16,8 +16,7 @@ RUN apt-get install -y libpq5 RUN apt-get install -y libz-dev RUN apt-get install -y libssl-dev -ENV POETRY_VERSION=1.8.3 \ - POETRY_HOME="/opt/poetry" \ +ENV POETRY_HOME="/opt/poetry" \ POETRY_NO_INTERACTION=1 \ POETRY_VIRTUALENVS_CREATE=false ENV PATH="$POETRY_HOME/bin:$PATH" @@ -31,18 +30,22 @@ RUN pip3 install poetry COPY autogpt_platform/autogpt_libs /app/autogpt_platform/autogpt_libs COPY autogpt_platform/market/poetry.lock autogpt_platform/market/pyproject.toml /app/autogpt_platform/market/ WORKDIR /app/autogpt_platform/market -RUN poetry config virtualenvs.create false \ - && poetry install --no-interaction --no-ansi +RUN poetry install --no-ansi --no-root # Generate Prisma client COPY autogpt_platform/market /app/autogpt_platform/market -RUN poetry config virtualenvs.create false \ - && poetry run prisma generate +RUN poetry install --no-ansi && \ + poetry run prisma generate FROM python:3.11.10-slim-bookworm AS server_dependencies WORKDIR /app +ENV POETRY_HOME="/opt/poetry" \ + POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_CREATE=false +ENV PATH="$POETRY_HOME/bin:$PATH" + # Upgrade pip and setuptools to fix security vulnerabilities RUN pip3 install --upgrade pip setuptools