From 0297701829680e44bd766b360234c067803df2d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bot=20of=20Thomas=20G=C3=BCttler?= Date: Tue, 9 Jun 2026 21:31:45 +0200 Subject: [PATCH] ci: automate dev container build via devcontainer.json + workflow (#553) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #552 ## Summary - Add `.devcontainer/devcontainer.json` pointing at `../Dockerfile.dev` so VS Code / Codespaces / any devcontainer-aware tool can build the dev environment directly from source. - Add `.forgejo/workflows/publish-dev-container.yml` that rebuilds `Dockerfile.dev` and pushes it to `codeberg.org/guettli/sharedinbox-dev` whenever `Dockerfile.dev`, the devcontainer config, or the workflow itself changes on `main`. The image is tagged both `:latest` and with the short commit SHA for pinnable references. - The workflow uses the built-in `FORGEJO_TOKEN` to log in to Codeberg's container registry — no extra secrets required. ## Notes - No existing references to `ghcr.io/guettli/sharedinbox-dev` were found in the repo, so issue step 3 (updating image references) is a no-op here. - `workflow_dispatch` is also enabled so the image can be rebuilt manually if needed. ## Verification - `python3 -c "import json; json.load(...)"` parses the devcontainer config. - `python3 -c "import yaml; yaml.safe_load(...)"` parses the workflow. - Triggers (paths filter) match the source files the issue identifies as drift risks. Co-authored-by: Thomas Güttler Reviewed-on: https://codeberg.org/guettli/sharedinbox/pulls/553 --- .devcontainer/devcontainer.json | 10 +++++ .forgejo/workflows/publish-dev-container.yml | 44 ++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .forgejo/workflows/publish-dev-container.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c3180d5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,10 @@ +{ + "name": "SharedInbox Dev", + "build": { + "dockerfile": "../Dockerfile.dev", + "context": ".." + }, + "workspaceFolder": "/src", + "workspaceMount": "source=${localWorkspaceFolder},target=/src,type=bind,consistency=cached", + "remoteUser": "ci" +} diff --git a/.forgejo/workflows/publish-dev-container.yml b/.forgejo/workflows/publish-dev-container.yml new file mode 100644 index 0000000..501835c --- /dev/null +++ b/.forgejo/workflows/publish-dev-container.yml @@ -0,0 +1,44 @@ +name: Publish Dev Container + +on: + push: + branches: [main] + paths: + - 'Dockerfile.dev' + - '.devcontainer/devcontainer.json' + - '.forgejo/workflows/publish-dev-container.yml' + workflow_dispatch: + +jobs: + publish: + name: Build & Push sharedinbox-dev + runs-on: ubuntu-latest + timeout-minutes: 30 + env: + REGISTRY: codeberg.org + IMAGE: codeberg.org/guettli/sharedinbox-dev + + steps: + - uses: actions/checkout@v4 + + - name: Log in to Codeberg container registry + env: + FORGEJO_TOKEN: ${{ github.token }} + run: | + echo "$FORGEJO_TOKEN" \ + | docker login "$REGISTRY" -u "${{ github.actor }}" --password-stdin + + - name: Build image + run: | + SHORT_SHA="${GITHUB_SHA:0:7}" + docker build \ + -t "$IMAGE:latest" \ + -t "$IMAGE:$SHORT_SHA" \ + -f Dockerfile.dev \ + . + + - name: Push image + run: | + SHORT_SHA="${GITHUB_SHA:0:7}" + docker push "$IMAGE:latest" + docker push "$IMAGE:$SHORT_SHA"