ci: fix Dockerfile for Rust + correct Forgejo runner labels
Build & Push Memory Image / build-push (push) Failing after 14s
Build and Push / Test (push) Failing after 5m22s
Build and Push / Build and push image (push) Skipped

Issues fixed:
- Dockerfile was Python/Uvicorn (wrong for Rust project)
  - Changed to multi-stage Rust build (rust:1.81 → debian:bookworm-slim)
  - Correct binary name: mem (not mem-cli)
  - Added proper health check with curl

- CI runner labels were incorrect (rust/golang → docker)
  - Changed test job to: runs-on: docker with rust:1.81-bookworm container
  - Changed build job to: runs-on: docker

- Docker build config was broken
  - Switched to standard actions (setup-buildx, login, build-push)
  - Added Cargo caching (registry, git, target)
  - Added format + clippy checks
  - Simplified login/build/push flow

Ready for CI/CD pipeline restart.
This commit is contained in:
2026-09-05 14:07:11 -07:00
parent ba31227bee
commit 43c8f7ff14
2 changed files with 72 additions and 77 deletions
+54 -44
View File
@@ -13,46 +13,54 @@ env:
jobs:
test:
name: Test
runs-on: rust
container: rust:1-bookworm
runs-on: docker
container:
image: rust:1.81-bookworm
steps:
- name: Install node (required by JS-based actions)
run: apt-get update && apt-get install -y --no-install-recommends nodejs
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
- name: Cache cargo
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
path: ~/.cargo/registry
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-
cargo-registry-
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: cargo-git-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-git-
- name: Cache build target
uses: actions/cache@v4
with:
path: target
key: cargo-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-target-
- name: Run tests
run: cargo test --all
run: cargo test --all --verbose
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all -- -D warnings
build:
name: Build and push image
runs-on: golang
name: Build and Push Image
runs-on: docker
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
container:
image: docker:27-cli
volumes:
- /docker-certs/client:/docker-certs/client:ro
env:
DOCKER_HOST: tcp://localhost:2376
DOCKER_TLS_VERIFY: "1"
DOCKER_CERT_PATH: /docker-certs/client
steps:
- name: Install node (required by JS-based actions)
run: apk add --no-cache nodejs git
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
- name: Get short SHA
id: sha
@@ -60,21 +68,23 @@ jobs:
SHORT_SHA=$(git rev-parse --short HEAD)
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Registry login
run: |
echo "${REGISTRY_PAT}" | docker login "${REGISTRY}" \
--username rock --password-stdin
env:
REGISTRY_PAT: ${{ secrets.REGISTRY_PAT }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: rock
password: ${{ secrets.REGISTRY_PAT }}
- name: Build
run: |
docker build \
-t "${IMAGE}:${{ steps.sha.outputs.short_sha }}" \
-t "${IMAGE}:latest" \
.
- name: Push
run: |
docker push "${IMAGE}:${{ steps.sha.outputs.short_sha }}"
docker push "${IMAGE}:latest"
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.IMAGE }}:${{ steps.sha.outputs.short_sha }}
${{ env.IMAGE }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max