Example repository: a Rust service with cargo, CI and an image
  • Rust 76.7%
  • Dockerfile 23.3%
Find a file
Sander van Thillo 443fbde3bb
All checks were successful
CI / test (push) Successful in 24s
CI / format (push) Successful in 26s
CI / lint (push) Successful in 26s
CI / image (push) Successful in 54s
feat: example repository for rust with CI
2026-11-13 21:29:51 +01:00
.forgejo feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00
src feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00
.dockerignore feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00
.editorconfig feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00
.gitignore feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00
Cargo.lock feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00
Cargo.toml feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00
Dockerfile feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00
README.md feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00
renovate.json feat: example repository for rust with CI 2026-11-13 21:29:51 +01:00

$REPO_OWNER/$REPO_NAME

An HTTP service in Rust, with only the standard library. Replace the server with a framework such as axum when the service grows.

Start

You need Rust 1.100 or newer.

cargo run                    # listens on 0.0.0.0:8080; set ADDR to change it
curl localhost:8080/healthz
Command What it does
cargo fmt Format
cargo clippy --all-targets -- -D warnings Lint
cargo test Tests

Pipeline

.forgejo/workflows/ci.yml is the complete pipeline. Copy it and change it as you need.

Event What happens
Pull request rustfmt, clippy and the tests in parallel, then the image is built without a push
Push to main The same, and the image is pushed as <short sha>-main-<run number>
Tag vX.Y.Z Also the image X.Y.Z

The checks run on the label default, without root. The image build needs Docker, so it runs on the label vm. The image is code.digitaledienst.overheid.nl/$REPO_OWNER/$REPO_NAME and has an SBOM. It runs as uid 65532 on port 8080, without a shell. The push uses the organisation secrets REGISTRY_USER and REGISTRY_TOKEN.

Files

File Purpose
Cargo.toml, Cargo.lock The package and the exact versions of the dependencies
Dockerfile Build with cargo, run in distroless as uid 65532
renovate.json The shared Renovate presets, and the tags of the actions of forgejo/ci-components
.forgejo/template The files in which Forgejo fills in the name of a new repository