diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..89f8a2a42 --- /dev/null +++ b/.dockerignore @@ -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__ diff --git a/.github/workflows/autogpt-docker-cache-clean.yml b/.github/workflows/autogpt-docker-cache-clean.yml index 57ead411d..c665b1d73 100644 --- a/.github/workflows/autogpt-docker-cache-clean.yml +++ b/.github/workflows/autogpt-docker-cache-clean.yml @@ -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 diff --git a/.github/workflows/autogpt-docker-ci.yml b/.github/workflows/autogpt-docker-ci.yml index e9948f354..7620eed63 100644 --- a/.github/workflows/autogpt-docker-ci.yml +++ b/.github/workflows/autogpt-docker-ci.yml @@ -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 }}, diff --git a/.github/workflows/autogpt-docker-release.yml b/.github/workflows/autogpt-docker-release.yml index 8610967eb..7fd554f36 100644 --- a/.github/workflows/autogpt-docker-release.yml +++ b/.github/workflows/autogpt-docker-release.yml @@ -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 diff --git a/autogpt/Dockerfile b/Dockerfile.autogpt similarity index 78% rename from autogpt/Dockerfile rename to Dockerfile.autogpt index 147debf85..f86cee48d 100644 --- a/autogpt/Dockerfile +++ b/Dockerfile.autogpt @@ -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 diff --git a/autogpt/.dockerignore b/autogpt/.dockerignore deleted file mode 100644 index a8dddfad5..000000000 --- a/autogpt/.dockerignore +++ /dev/null @@ -1,13 +0,0 @@ -.* -**/.venv* -**/__pycache__ -*.template -*.yaml -*.yml - -data/* -logs/* -agbenchmark_config/logs/* -agbenchmark_config/reports/* - -*.png diff --git a/autogpt/docker-compose.yml b/autogpt/docker-compose.yml index 281c8f697..0782375e5 100644 --- a/autogpt/docker-compose.yml +++ b/autogpt/docker-compose.yml @@ -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"]