Example repository: a Rust service with cargo, CI and an image
- Rust 76.7%
- Dockerfile 23.3%
| .forgejo | ||
| src | ||
| .dockerignore | ||
| .editorconfig | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| Dockerfile | ||
| README.md | ||
| renovate.json | ||
$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 |