Skip to content

perf(platform): build the backend image once instead of eight times - #14457

Draft
Bentlybro wants to merge 1 commit into
devfrom
bently/perf-backend-image-built-once
Draft

perf(platform): build the backend image once instead of eight times#14457
Bentlybro wants to merge 1 commit into
devfrom
bently/perf-backend-image-built-once

Conversation

@Bentlybro

Copy link
Copy Markdown
Member

Why / What / How

Why: docker compose build on the platform spends most of its time exporting the same image over and over. Eight services (rest_server, executor, copilot_executor, websocket_server, database_manager, scheduler_server, notification_server, platform_linking_manager) declare byte-identical builds — same context, same Dockerfile, target: server, no differing build args — and differ only in the command each container runs. Compose has no way to know they are the same image, so it builds it, then exports it once per service.

From a full-stack build, the slowest steps are not compiling or downloading:

#80 DONE 2023.8s  [rest_server]          exporting to image
#74 DONE 2019.9s  [notification_server]  exporting to image
#78 DONE 2019.5s  [scheduler_server]     exporting to image
#75 DONE 2019.4s  [copilot_executor]     exporting to image
#77 DONE 1822.4s  [executor]             exporting to image
#79 DONE 1487.9s  [database_manager]     exporting to image

Roughly 33 minutes each, writing the same ~3.7 GB of layers and contending for the same disk.

What: gives those eight services one image: name, so compose builds and exports the image a single time.

How: one line per service. Nothing else changes — each container still runs its own command from that image, which is exactly what it already did; they were identical images with eight different auto-generated names.

Changes 🏗️

  • autogpt_platform/docker-compose.platform.yml: the eight target: server services now share image: autogpt_platform-backend:latest.

Agents and large language models used

Claude Code with Claude Fable 5.1

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • Full cold deploy-pr dev (wipe all images and build cache, docker compose build then up -d) on a 12-core/32 GB VM, before and after: 56m18s → 32m33s, slowest single step 2023s → 762s
    • Stack reaches READY afterwards: all 15 containers up, frontend serving on :3000, backend /docs responding
    • docker compose config resolves; every target: server service reports the same image, and each keeps its own distinct command
    • platform_linking_manager (the one behind profiles: ["bot"]) still resolves correctly

A caveat on the timing, since it matters: the two runs were on two identically specced VMs rather than a single-machine A/B, and the dev commit moved between them. Treat the wall-clock as indicative; the export collapse from eight to one is the mechanism, and that part is directly visible in the build output above.

For configuration changes:

  • .env.default is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)

Eight services declare byte-identical builds -- same context, same Dockerfile, target: server, no
differing build args -- and differ only in the command each container runs. Compose has no way to
know they are the same image, so it builds and then exports that image once per service.

The export is where the time goes. From a docker compose build of the full stack:

  #80 DONE 2023.8s  [rest_server]          exporting to image
  #74 DONE 2019.9s  [notification_server]  exporting to image
  #78 DONE 2019.5s  [scheduler_server]     exporting to image
  #75 DONE 2019.4s  [copilot_executor]     exporting to image

Roughly 33 minutes each, writing the same ~3.7 GB of layers and contending for the same disk. With
one image name those eight exports become one, and the slowest step in the equivalent build fell to
762s.

Behaviour is unchanged: each service still runs its own command from the same image, which is what
it already did in practice.

Measured on two identically specced VMs (12 cores, 32 GB), cold build and start of the whole stack:
56m18s before, 32m33s after. Not a single-machine A/B, and the dev commit moved between the runs, so
treat the wall-clock as indicative and the export collapse as the mechanism.
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added cla: signed CLA signed by all contributors size/s labels Sep 9, 2026
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.51%. Comparing base (f58b082) to head (8cf2b37).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #14457   +/-   ##
=======================================
  Coverage   81.51%   81.51%           
=======================================
  Files        3561     3561           
  Lines      266076   266075    -1     
  Branches    24637    24636    -1     
=======================================
+ Hits       216882   216886    +4     
+ Misses      43835    43743   -92     
- Partials     5359     5446   +87     
Flag Coverage Δ
platform-frontend 60.93% <ø> (-0.02%) ⬇️
platform-frontend-e2e 28.37% <ø> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 86.48% <ø> (ø)
Platform Frontend 63.24% <ø> (+0.01%) ⬆️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: signed CLA signed by all contributors size/s

Projects

Status: 🆕 Needs initial review

Development

Successfully merging this pull request may close these issues.

1 participant