Skip to content

Feature/admin bake endpoint - #286

Merged
vsilent merged 2 commits into
devfrom
feature/admin-bake-endpoint
Oct 15, 2026
Merged

vsilent merged 2 commits into
devfrom
feature/admin-bake-endpoint

Conversation

@vsilent

@vsilent vsilent commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces support for a new "bake job" feature, which allows the system to initiate and track "bake" operations through the API and a new bake binary. The changes include database schema migrations, backend logic, and updates to Docker and build workflows to incorporate the new binary. Additionally, helper utilities and models are added to support the new functionality.

Bake Job Feature Implementation:

  • Database schema and migrations:

    • Adds a new bake_job table for tracking bake jobs, including fields for stack, version, deployment, server info, status, and error reporting. Associated Casbin rules are inserted for API access, and a down migration is provided for cleanup. [1] [2]
  • Backend logic and models:

    • Introduces the BakeJob struct in src/models/bake_job.rs and exposes it in the models module. [1] [2] [3]
    • Implements database access functions for bake jobs in src/db/bake_job.rs, including creation, fetching, status updates, and concurrency checks. [1] [2]
  • Helper utilities:

    • Adds src/helpers/bake_job.rs with functions to validate stack directories, check the status of compose services, and verify health URLs, including comprehensive tests.
    • Exposes the new helper module in src/helpers/mod.rs.
    • Makes PLATFORM_INSTALL_DIRS public for use in helpers.

Docker and Build Workflow Updates:

  • Dockerfile and build process:
    • Updates the Dockerfile and GitHub Actions workflow to build, copy, and include the new bake binary in the application image and deployment artifacts. [1] [2] [3] [4] [5] [6]

robotizeit and others added 2 commits October 15, 2026 11:00
bake turns a deployed build box into a Quick Deploy snapshot. It was not in
the image, so every bake meant compiling it by hand and `docker cp` into the
running container. CI now compiles it with the other release binaries,
archives and unpacks it, and both Dockerfile paths (prebuilt from CI and the
local builder stage) copy it to /app/bake.

tests/image_binaries_contract.rs checks every image binary on both paths
(failed for bake before this change).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012TKZy6f5shPzM9WLdswH6f
POST /api/admin/bake {deployment_id, stack, health_url} bakes a deployed
build box into a Quick Deploy snapshot; GET /api/admin/bake/{id} reports
the job. Admins only (group_admin, admin_service), like template approval.

What the bake binary needs typed by hand comes from stacker itself: the
server row of the deployment's project (IP, SSH user and port), its SSH
key in Vault, and the latest approved version of the template with its
config_contract. Refused at once, with no job recorded and the box
untouched: unknown deployment, not exactly one server, a template that is
not approved, no or unusable contract, a health URL that is not on the
box, a box Hetzner does not know in the platform's project, a bake of the
same box already running.

The job (202 + id, status in the new bake_job table) then checks the
health URL, finds the stack's directory with `docker compose ls` and
requires every service up (`docker compose ps`), and runs the existing
chain unchanged: finalize_build_box, run_bake, baked_snapshot::record.
The build box is never removed.

Tests: helpers::bake_job (7, written failing first); tests/admin_bake.rs
(refusals, accepted job, status, non-admin refused; a mutation that drops
the Hetzner lookup fails it). lib + route matrix 2270 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012TKZy6f5shPzM9WLdswH6f
@vsilent
vsilent merged commit be4bced into dev Oct 15, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants