Skip to content

Commit 5292736

Browse files
authored
fix(agent): Unbreak docker builds after repo restructure (Significant-Gravitas#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
1 parent e16d58a commit 5292736

File tree

7 files changed

+55
-36
lines changed

7 files changed

+55
-36
lines changed

.dockerignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Ignore everything by default, selectively add things to context
2+
*
3+
4+
# AutoGPT
5+
!autogpt/autogpt/
6+
!autogpt/pyproject.toml
7+
!autogpt/poetry.lock
8+
!autogpt/README.md
9+
!autogpt/tests/
10+
11+
# Benchmark
12+
!benchmark/agbenchmark/
13+
!benchmark/pyproject.toml
14+
!benchmark/poetry.lock
15+
!benchmark/README.md
16+
17+
# Forge
18+
!forge/forge/
19+
!forge/pyproject.toml
20+
!forge/poetry.lock
21+
!forge/README.md
22+
23+
# Frontend
24+
!frontend/build/web/
25+
26+
# Explicitly re-ignore some folders
27+
.*
28+
**/__pycache__

.github/workflows/autogpt-docker-cache-clean.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
name: Build image
2626
uses: docker/build-push-action@v5
2727
with:
28-
context: autogpt
28+
file: Dockerfile.autogpt
2929
build-args: BUILD_TYPE=${{ matrix.build-type }}
3030
load: true # save to docker images
3131
# use GHA cache as read-only

.github/workflows/autogpt-docker-ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
name: Build image
5050
uses: docker/build-push-action@v5
5151
with:
52-
context: autogpt
52+
file: Dockerfile.autogpt
5353
build-args: BUILD_TYPE=${{ matrix.build-type }}
5454
tags: ${{ env.IMAGE_NAME }}
5555
labels: GIT_REVISION=${{ github.sha }}
@@ -84,7 +84,6 @@ jobs:
8484
vars_json: ${{ toJSON(vars) }}
8585

8686
run: .github/workflows/scripts/docker-ci-summary.sh >> $GITHUB_STEP_SUMMARY
87-
working-directory: ./
8887
continue-on-error: true
8988

9089
test:
@@ -119,7 +118,7 @@ jobs:
119118
name: Build image
120119
uses: docker/build-push-action@v5
121120
with:
122-
context: autogpt
121+
file: Dockerfile.autogpt
123122
build-args: BUILD_TYPE=dev # include pytest
124123
tags: >
125124
${{ env.IMAGE_NAME }},

.github/workflows/autogpt-docker-release.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ on:
1010
type: boolean
1111
description: 'Build from scratch, without using cached layers'
1212

13-
defaults:
14-
run:
15-
working-directory: autogpt
16-
1713
env:
1814
IMAGE_NAME: auto-gpt
1915
DEPLOY_IMAGE_NAME: ${{ secrets.DOCKER_USER }}/auto-gpt
@@ -48,7 +44,7 @@ jobs:
4844
name: Build image
4945
uses: docker/build-push-action@v5
5046
with:
51-
context: autogpt
47+
file: Dockerfile.autogpt
5248
build-args: BUILD_TYPE=release
5349
load: true # save to docker images
5450
# push: true # TODO: uncomment when this issue is fixed: https://github.com/moby/buildkit/issues/1555
@@ -87,5 +83,4 @@ jobs:
8783
vars_json: ${{ toJSON(vars) }}
8884

8985
run: .github/workflows/scripts/docker-release-summary.sh >> $GITHUB_STEP_SUMMARY
90-
working-directory: ./
9186
continue-on-error: true

autogpt/Dockerfile renamed to Dockerfile.autogpt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ RUN curl -sSL https://install.python-poetry.org | python3 -
2828
ENV PATH="$POETRY_HOME/bin:$PATH"
2929
RUN poetry config installer.max-workers 10
3030

31-
WORKDIR /app
32-
COPY pyproject.toml poetry.lock ./
31+
WORKDIR /app/autogpt
32+
COPY autogpt/pyproject.toml autogpt/poetry.lock ./
33+
34+
# Include forge so it can be used as a path dependency
35+
COPY forge/ ../forge
36+
37+
# Include frontend
38+
COPY frontend/ ../frontend
3339

3440
# Set the entrypoint
3541
ENTRYPOINT ["poetry", "run", "autogpt"]
@@ -39,16 +45,16 @@ CMD []
3945
FROM autogpt-base as autogpt-dev
4046
RUN poetry install --no-cache --no-root \
4147
&& rm -rf $(poetry env info --path)/src
42-
ONBUILD COPY . ./
48+
ONBUILD COPY autogpt/ ./
4349

4450
# release build -> include bare minimum
4551
FROM autogpt-base as autogpt-release
4652
RUN poetry install --no-cache --no-root --without dev \
4753
&& rm -rf $(poetry env info --path)/src
48-
ONBUILD COPY autogpt/ ./autogpt
49-
ONBUILD COPY scripts/ ./scripts
50-
ONBUILD COPY plugins/ ./plugins
51-
ONBUILD COPY README.md ./README.md
54+
ONBUILD COPY autogpt/autogpt/ ./autogpt
55+
ONBUILD COPY autogpt/scripts/ ./scripts
56+
ONBUILD COPY autogpt/plugins/ ./plugins
57+
ONBUILD COPY autogpt/README.md ./README.md
5258
ONBUILD RUN mkdir ./data
5359

5460
FROM autogpt-${BUILD_TYPE} AS autogpt

autogpt/.dockerignore

Lines changed: 0 additions & 13 deletions
This file was deleted.

autogpt/docker-compose.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@ version: "3.9"
66

77
services:
88
auto-gpt:
9-
build: ./
9+
build:
10+
context: ../
11+
dockerfile: Dockerfile.autogpt
1012
env_file:
1113
- .env
1214
ports:
1315
- "8000:8000"
1416
volumes:
15-
- ./:/app
17+
- ./:/app/autogpt/
1618
- ./docker-compose.yml:/app/docker-compose.yml:ro
17-
- ./Dockerfile:/app/Dockerfile:ro
19+
# - ./Dockerfile:/app/Dockerfile:ro
1820
profiles: ["exclude-from-up"]
1921

2022
# Only for TESTING purposes. Run with: docker compose run --build --rm autogpt-test
2123
autogpt-test:
22-
build: ./
24+
build:
25+
context: ../
26+
dockerfile: Dockerfile.autogpt
2327
env_file:
2428
- .env
2529
environment:
@@ -29,8 +33,8 @@ services:
2933
entrypoint: ["poetry", "run"]
3034
command: ["pytest", "-v"]
3135
volumes:
32-
- ./autogpt:/app/autogpt
33-
- ./tests:/app/tests
36+
- ./autogpt:/app/autogpt/autogpt
37+
- ./tests:/app/autogpt/tests
3438
depends_on:
3539
- minio
3640
profiles: ["exclude-from-up"]

0 commit comments

Comments
 (0)