fix(agent): Unbreak docker builds after repo restructure (#7164)

- Move `autogpt/Dockerfile` to `Dockerfile.autogpt`
  - Write new selective `.dockerignore` (in repo root) to keep build context clean
  - Amend `autogpt/docker-compose.yml` and all `autogpt-docker-*.yml` workflows accordingly

- Include `forge/` in docker build context so it can be used as a path dependency

- Include `frontend/` in docker builds
This commit is contained in:
Reinier van der Leer 2024-05-22 18:11:16 +02:00 committed by GitHub
parent e16d58af0c
commit 5292736779
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 55 additions and 36 deletions

28
.dockerignore Normal file
View File

@ -0,0 +1,28 @@
# Ignore everything by default, selectively add things to context
*
# AutoGPT
!autogpt/autogpt/
!autogpt/pyproject.toml
!autogpt/poetry.lock
!autogpt/README.md
!autogpt/tests/
# Benchmark
!benchmark/agbenchmark/
!benchmark/pyproject.toml
!benchmark/poetry.lock
!benchmark/README.md
# Forge
!forge/forge/
!forge/pyproject.toml
!forge/poetry.lock
!forge/README.md
# Frontend
!frontend/build/web/
# Explicitly re-ignore some folders
.*
**/__pycache__

View File

@ -25,7 +25,7 @@ jobs:
name: Build image
uses: docker/build-push-action@v5
with:
context: autogpt
file: Dockerfile.autogpt
build-args: BUILD_TYPE=${{ matrix.build-type }}
load: true # save to docker images
# use GHA cache as read-only

View File

@ -49,7 +49,7 @@ jobs:
name: Build image
uses: docker/build-push-action@v5
with:
context: autogpt
file: Dockerfile.autogpt
build-args: BUILD_TYPE=${{ matrix.build-type }}
tags: ${{ env.IMAGE_NAME }}
labels: GIT_REVISION=${{ github.sha }}
@ -84,7 +84,6 @@ jobs:
vars_json: ${{ toJSON(vars) }}
run: .github/workflows/scripts/docker-ci-summary.sh >> $GITHUB_STEP_SUMMARY
working-directory: ./
continue-on-error: true
test:
@ -119,7 +118,7 @@ jobs:
name: Build image
uses: docker/build-push-action@v5
with:
context: autogpt
file: Dockerfile.autogpt
build-args: BUILD_TYPE=dev # include pytest
tags: >
${{ env.IMAGE_NAME }},

View File

@ -10,10 +10,6 @@ on:
type: boolean
description: 'Build from scratch, without using cached layers'
defaults:
run:
working-directory: autogpt
env:
IMAGE_NAME: auto-gpt
DEPLOY_IMAGE_NAME: ${{ secrets.DOCKER_USER }}/auto-gpt
@ -48,7 +44,7 @@ jobs:
name: Build image
uses: docker/build-push-action@v5
with:
context: autogpt
file: Dockerfile.autogpt
build-args: BUILD_TYPE=release
load: true # save to docker images
# push: true # TODO: uncomment when this issue is fixed: https://github.com/moby/buildkit/issues/1555
@ -87,5 +83,4 @@ jobs:
vars_json: ${{ toJSON(vars) }}
run: .github/workflows/scripts/docker-release-summary.sh >> $GITHUB_STEP_SUMMARY
working-directory: ./
continue-on-error: true

View File

@ -28,8 +28,14 @@ RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="$POETRY_HOME/bin:$PATH"
RUN poetry config installer.max-workers 10
WORKDIR /app
COPY pyproject.toml poetry.lock ./
WORKDIR /app/autogpt
COPY autogpt/pyproject.toml autogpt/poetry.lock ./
# Include forge so it can be used as a path dependency
COPY forge/ ../forge
# Include frontend
COPY frontend/ ../frontend
# Set the entrypoint
ENTRYPOINT ["poetry", "run", "autogpt"]
@ -39,16 +45,16 @@ CMD []
FROM autogpt-base as autogpt-dev
RUN poetry install --no-cache --no-root \
&& rm -rf $(poetry env info --path)/src
ONBUILD COPY . ./
ONBUILD COPY autogpt/ ./
# release build -> include bare minimum
FROM autogpt-base as autogpt-release
RUN poetry install --no-cache --no-root --without dev \
&& rm -rf $(poetry env info --path)/src
ONBUILD COPY autogpt/ ./autogpt
ONBUILD COPY scripts/ ./scripts
ONBUILD COPY plugins/ ./plugins
ONBUILD COPY README.md ./README.md
ONBUILD COPY autogpt/autogpt/ ./autogpt
ONBUILD COPY autogpt/scripts/ ./scripts
ONBUILD COPY autogpt/plugins/ ./plugins
ONBUILD COPY autogpt/README.md ./README.md
ONBUILD RUN mkdir ./data
FROM autogpt-${BUILD_TYPE} AS autogpt

View File

@ -1,13 +0,0 @@
.*
**/.venv*
**/__pycache__
*.template
*.yaml
*.yml
data/*
logs/*
agbenchmark_config/logs/*
agbenchmark_config/reports/*
*.png

View File

@ -6,20 +6,24 @@ version: "3.9"
services:
auto-gpt:
build: ./
build:
context: ../
dockerfile: Dockerfile.autogpt
env_file:
- .env
ports:
- "8000:8000"
volumes:
- ./:/app
- ./:/app/autogpt/
- ./docker-compose.yml:/app/docker-compose.yml:ro
- ./Dockerfile:/app/Dockerfile:ro
# - ./Dockerfile:/app/Dockerfile:ro
profiles: ["exclude-from-up"]
# Only for TESTING purposes. Run with: docker compose run --build --rm autogpt-test
autogpt-test:
build: ./
build:
context: ../
dockerfile: Dockerfile.autogpt
env_file:
- .env
environment:
@ -29,8 +33,8 @@ services:
entrypoint: ["poetry", "run"]
command: ["pytest", "-v"]
volumes:
- ./autogpt:/app/autogpt
- ./tests:/app/tests
- ./autogpt:/app/autogpt/autogpt
- ./tests:/app/autogpt/tests
depends_on:
- minio
profiles: ["exclude-from-up"]