Compare commits
13 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
964b0be064 | ||
|
|
3aa1abe175 | ||
|
|
b83f9e95b6 | ||
|
|
1ea007d330 | ||
|
|
ebb05ed9c1 | ||
|
|
c108a39f2c | ||
|
|
2312315f34 | ||
|
|
2e55c72522 | ||
|
|
423ddc7870 | ||
|
|
168b674efe | ||
|
|
e6555bd873 | ||
|
|
d904689b38 | ||
|
|
97b1d580e3 |
5 changed files with 130 additions and 58 deletions
123
.github/workflows/deploy.yml
vendored
123
.github/workflows/deploy.yml
vendored
|
|
@ -1,25 +1,53 @@
|
||||||
name: Deploy
|
name: Build & Publish
|
||||||
|
# Fork build pipeline for the "zo" forge (git.ziemlichoptimal.de/moby/brewlog).
|
||||||
|
# On every push to `dev` this checks the code, then builds the container and
|
||||||
|
# publishes it to this forge's own container registry. The moby homelab
|
||||||
|
# (git.ziemlichoptimal.de/moby/cluster-moby) deploys the resulting image via
|
||||||
|
# Flux GitOps — this pipeline does NOT deploy anything itself (the upstream
|
||||||
|
# Fly.io deploy step was removed).
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main"]
|
branches: ["dev"]
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
# The registry push uses a PAT with `write:package` scope, supplied via the
|
||||||
|
# REGISTRY_USER / REGISTRY_TOKEN Actions secrets (same as moby/uberbau_xyz and
|
||||||
|
# moby/claude-code). Forgejo's auto GITHUB_TOKEN lacks org package-write, so a
|
||||||
|
# push authenticated with it 401s (reqPackageAccess). `contents: read` keeps the
|
||||||
|
# Kaniko git-context clone (over the auto token) working; `packages: write` is
|
||||||
|
# belt-and-suspenders on the auto token.
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
# This forge's built-in container registry, same host as the git server.
|
||||||
|
REGISTRY: git.ziemlichoptimal.de
|
||||||
|
IMAGE: git.ziemlichoptimal.de/moby/brewlog
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
name: Check
|
name: Check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install mise
|
# The repo's mise.toml pulls the whole dev toolchain (tailwind, cargo-watch,
|
||||||
uses: jdx/mise-action@v4
|
# flyctl, shellcheck, ...), and mise resolves most of those via the GitHub
|
||||||
|
# API — which 401s on this runner (it has no github.com token), failing the
|
||||||
|
# entire install. CI only needs the pinned Rust toolchain, so install it
|
||||||
|
# directly via mise (rust resolves through rustup, no GitHub API).
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
uses: https://github.com/jdx/mise-action@v2
|
||||||
|
with:
|
||||||
|
install_args: rust
|
||||||
|
|
||||||
- name: Cache Cargo artifacts
|
- name: Cache Cargo artifacts
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry/index/
|
~/.cargo/registry/index/
|
||||||
|
|
@ -31,11 +59,10 @@ jobs:
|
||||||
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-
|
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-
|
||||||
cargo-${{ runner.os }}-
|
cargo-${{ runner.os }}-
|
||||||
|
|
||||||
|
# No sudo on the node:20-bookworm runner image (job runs as root). mold is
|
||||||
|
# required by .cargo/config.toml's linker flag (-fuse-ld=mold).
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: sudo apt-get update && sudo apt-get install -y clang lld mold libssl-dev pkg-config
|
run: apt-get update && apt-get install -y --no-install-recommends clang lld mold pkg-config
|
||||||
|
|
||||||
- name: Ensure Rust components
|
|
||||||
run: rustup component add rustfmt clippy
|
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: cargo fmt -- --check
|
run: cargo fmt -- --check
|
||||||
|
|
@ -46,44 +73,46 @@ jobs:
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test -- --show-output
|
run: cargo test -- --show-output
|
||||||
|
|
||||||
deploy:
|
build:
|
||||||
name: Deploy
|
name: Build & Publish
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [check]
|
needs: [check]
|
||||||
|
# Build the image DAEMONLESS with Kaniko — no Docker, no buildx, no
|
||||||
|
# privileged DinD. The job runs *inside* the Kaniko executor image, which
|
||||||
|
# builds the Dockerfile and pushes straight to the forge registry.
|
||||||
|
container:
|
||||||
|
image: gcr.io/kaniko-project/executor:v1.24.0-debug
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
# The kaniko -debug image is busybox-only (no bash).
|
||||||
|
shell: sh
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Build and push (Kaniko)
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Install mise
|
|
||||||
uses: jdx/mise-action@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v4
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v4
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract version from Cargo.toml
|
|
||||||
id: version
|
|
||||||
run: echo "version=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2)" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Build and push container
|
|
||||||
uses: docker/build-push-action@v7
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
ghcr.io/jnsgruk/brewlog:${{ github.sha }}
|
|
||||||
ghcr.io/jnsgruk/brewlog:latest
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
- name: Deploy to Fly.io
|
|
||||||
run: |
|
|
||||||
flyctl deploy -i "ghcr.io/jnsgruk/brewlog:${{ github.sha }}"
|
|
||||||
env:
|
env:
|
||||||
FLY_ACCESS_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
# Registry push uses a PAT with write:package scope (Forgejo's auto
|
||||||
|
# GITHUB_TOKEN lacks org package-write -> 401 reqPackageAccess).
|
||||||
|
FORGE_USER: ${{ secrets.REGISTRY_USER }}
|
||||||
|
FORGE_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
# Kaniko clones the `--context` git URL over the auto token (read).
|
||||||
|
GIT_USERNAME: ${{ github.actor }}
|
||||||
|
GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
# Registry auth for the push (docker config.json format).
|
||||||
|
AUTH=$(printf '%s:%s' "$FORGE_USER" "$FORGE_TOKEN" | base64 | tr -d '\n')
|
||||||
|
mkdir -p /kaniko/.docker
|
||||||
|
printf '{"auths":{"%s":{"auth":"%s"}}}' "$REGISTRY" "$AUTH" > /kaniko/.docker/config.json
|
||||||
|
# Kaniko clones the context itself (this job has no node for JS actions
|
||||||
|
# like checkout). `dev` is the moving branch tag; the commit SHA is the
|
||||||
|
# immutable ref the moby Deployment pins by digest.
|
||||||
|
# The runtime stage is `FROM scratch` + `COPY /rootfs /`, so Kaniko
|
||||||
|
# rebuilds the container root. The act runner bind-mounts /var/run/act
|
||||||
|
# into the job container; Kaniko can't unlink that busy mount while
|
||||||
|
# laying down the rootfs (unlinkat ... device or resource busy), so
|
||||||
|
# ignore it. It is a runner artifact and must not be in the image.
|
||||||
|
/kaniko/executor \
|
||||||
|
--context "git://${REGISTRY}/moby/brewlog.git#refs/heads/dev" \
|
||||||
|
--dockerfile Dockerfile \
|
||||||
|
--ignore-path=/var/run/act \
|
||||||
|
--destination "${IMAGE}:${GITHUB_SHA}" \
|
||||||
|
--destination "${IMAGE}:dev"
|
||||||
|
|
|
||||||
14
.github/workflows/push.yml
vendored
14
.github/workflows/push.yml
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
name: CI
|
name: CI
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ["main"]
|
branches: ["dev"]
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|
@ -13,13 +13,13 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install mise
|
- name: Install mise
|
||||||
uses: jdx/mise-action@v4
|
uses: https://github.com/jdx/mise-action@v2
|
||||||
|
|
||||||
- name: Cache Cargo artifacts
|
- name: Cache Cargo artifacts
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry/index/
|
~/.cargo/registry/index/
|
||||||
|
|
@ -51,13 +51,13 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install mise
|
- name: Install mise
|
||||||
uses: jdx/mise-action@v4
|
uses: https://github.com/jdx/mise-action@v2
|
||||||
|
|
||||||
- name: Cache Cargo artifacts
|
- name: Cache Cargo artifacts
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry/index/
|
~/.cargo/registry/index/
|
||||||
|
|
|
||||||
15
Dockerfile
15
Dockerfile
|
|
@ -30,9 +30,10 @@ RUN mkdir -p /usr/local/bin \
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
# NB: no `RUN --mount=type=cache` here on purpose. The CI image builder is
|
||||||
--mount=type=cache,target=/app/target \
|
# Kaniko (daemonless, no Docker/BuildKit), which does not support BuildKit cache
|
||||||
cargo build --release --locked \
|
# mounts — it errors on them. Keep this RUN plain. See README "CI / build".
|
||||||
|
RUN cargo build --release --locked \
|
||||||
&& mkdir -p /out \
|
&& mkdir -p /out \
|
||||||
&& cp target/release/brewlog /out/brewlog
|
&& cp target/release/brewlog /out/brewlog
|
||||||
|
|
||||||
|
|
@ -61,6 +62,14 @@ RUN useradd --root /rootfs -u 1000 -U -M -s /bin/false brewlog \
|
||||||
&& mkdir -p /rootfs/home/brewlog /rootfs/data \
|
&& mkdir -p /rootfs/home/brewlog /rootfs/data \
|
||||||
&& chown 1000:1000 /rootfs/home/brewlog /rootfs/data
|
&& chown 1000:1000 /rootfs/home/brewlog /rootfs/data
|
||||||
|
|
||||||
|
# chisel's base-files ships /var/run as a symlink to /run. When the CI builder
|
||||||
|
# (Kaniko) lays this rootfs onto `/` for the scratch stage, replacing that
|
||||||
|
# symlink forces a RemoveAll of the destination /var/run — which on the Forgejo
|
||||||
|
# act runner is a directory holding a busy /var/run/act bind-mount, so the copy
|
||||||
|
# fails with "unlinkat /var/run/act: device or resource busy". The runtime image
|
||||||
|
# does not need /var/run, so drop the symlink to avoid the collision.
|
||||||
|
RUN rm -rf /rootfs/var/run
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Runtime — scratch with chisel rootfs
|
# Runtime — scratch with chisel rootfs
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
34
README.md
34
README.md
|
|
@ -147,9 +147,12 @@ sudo apt install -y clang mold pkg-config libssl-dev \
|
||||||
mise trust
|
mise trust
|
||||||
mise install # Install all dev tools
|
mise install # Install all dev tools
|
||||||
mise run install-e2e # Install Chrome for Testing + ChromeDriver
|
mise run install-e2e # Install Chrome for Testing + ChromeDriver
|
||||||
|
uv tool install prek # Install prek (git hook runner) as a standalone tool
|
||||||
prek install # Install git hooks
|
prek install # Install git hooks
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> **Note:** `prek` is a standalone binary installed via [`uv`](https://docs.astral.sh/uv/) and must be on `PATH`. If it is missing, `prek run -av` cannot invoke `cargo fmt -- --check` and reports `failed to run cargo fmt -- --check` — this is the missing `prek`/toolchain, not a formatting error. Installing `prek` resolves it.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
@ -162,6 +165,37 @@ cargo build # Build
|
||||||
|
|
||||||
See [CLAUDE.md](CLAUDE.md) for architecture, code patterns, and development conventions.
|
See [CLAUDE.md](CLAUDE.md) for architecture, code patterns, and development conventions.
|
||||||
|
|
||||||
|
## CI / build pipeline (this fork)
|
||||||
|
|
||||||
|
This fork lives on the **zo** Forgejo forge
|
||||||
|
(`git.ziemlichoptimal.de/uberbau/brewlog`, default branch **`dev`**) and is
|
||||||
|
deployed to the **moby** homelab via Flux GitOps. `.github/workflows/deploy.yml`
|
||||||
|
runs on every push to `dev`: it lints/tests (`check`), then builds and publishes
|
||||||
|
the container image to the forge's own registry as
|
||||||
|
`git.ziemlichoptimal.de/uberbau/brewlog:{dev,<sha>}`. The moby deployment pins
|
||||||
|
that image by digest and bumps it per release.
|
||||||
|
|
||||||
|
The build is **daemonless — it does not use Docker**. It runs
|
||||||
|
[Kaniko](https://github.com/GoogleContainerTools/kaniko) as the job container,
|
||||||
|
building the `Dockerfile` (context pulled straight from git) and pushing to the
|
||||||
|
registry. No `docker`, no buildx, no privileged Docker-in-Docker.
|
||||||
|
|
||||||
|
### Gotchas (learned the hard way)
|
||||||
|
|
||||||
|
- **Kaniko does not support BuildKit `RUN --mount=type=cache`.** The build fails
|
||||||
|
on it. Keep every `RUN` in the `Dockerfile` plain — no BuildKit cache mounts.
|
||||||
|
(This is why the Rust build layer is a plain `cargo build`; we have been bitten
|
||||||
|
by this before, so do not "re-add caching" to the Dockerfile.)
|
||||||
|
- **The forge's Actions runner is node20-only.** Pin JS actions to their node20
|
||||||
|
generation (`actions/checkout@v4`, `actions/cache@v4`, and if you reintroduce
|
||||||
|
docker actions, `@v3`/`@v6`) — the newer `@v5/@v6/@v7` releases declare
|
||||||
|
`runs.using: node24`, which the runner rejects (`must be one of [… node20 …]`).
|
||||||
|
- **Reference actions by full `github.com` URL**
|
||||||
|
(`uses: https://github.com/owner/repo@ref`). The runner's default action
|
||||||
|
mirror (`code.forgejo.org`) is incomplete/flaky and aborts clones mid-run.
|
||||||
|
- The `check` job installs only Rust via mise (`install_args: rust`); the full
|
||||||
|
`mise.toml` toolchain pulls tools from the GitHub API, which 401s on the runner.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[Apache License 2.0](LICENSE)
|
[Apache License 2.0](LICENSE)
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ pub async fn create_token(client: &BrewlogClient, cmd: CreateTokenCommand) -> Re
|
||||||
result = rx => {
|
result = rx => {
|
||||||
result.context("callback server closed without receiving a token")?
|
result.context("callback server closed without receiving a token")?
|
||||||
}
|
}
|
||||||
() = tokio::time::sleep(std::time::Duration::from_secs(120)) => {
|
() = tokio::time::sleep(std::time::Duration::from_mins(2)) => {
|
||||||
return Err(anyhow!("timed out waiting for browser authentication (2 minutes)"));
|
return Err(anyhow!("timed out waiting for browser authentication (2 minutes)"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue