Skip to content

Commit 0fc2495

Browse files
CoderYellowclaude
andcommitted
build: mirrored images, Docker dependency-layer caching, opt-in binary release
- test and builder images now pull from ghcr.io/openprojectx/dockerhub mirrors (rustfs, k3s, rust) - Dockerfile builds dependencies against dummy sources in a separate layer keyed on Cargo.toml, so source-only changes reuse the cached deps layer via the buildx GHA cache - GitHub release binary is now opt-in (repository variable RELEASE_BINARY=true); release always attaches crds.yaml Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent a825cbc commit 0fc2495

6 files changed

Lines changed: 30 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,24 @@ jobs:
4444
contents: write
4545
steps:
4646
- uses: actions/checkout@v4
47+
# Binary artifact is opt-in: set the repository variable
48+
# RELEASE_BINARY=true to build and attach it.
4749
- uses: dtolnay/rust-toolchain@stable
50+
if: vars.RELEASE_BINARY == 'true'
4851
- uses: Swatinem/rust-cache@v2
52+
if: vars.RELEASE_BINARY == 'true'
4953
- name: Build release binary
54+
if: vars.RELEASE_BINARY == 'true'
5055
run: |
5156
cargo build --release --bin rustfs-operator
5257
cp target/release/rustfs-operator rustfs-operator-linux-amd64
5358
- uses: softprops/action-gh-release@v2
5459
with:
5560
generate_release_notes: true
61+
# the glob matches nothing when the binary step is skipped
5662
files: |
5763
deploy/crds.yaml
58-
rustfs-operator-linux-amd64
64+
rustfs-operator-linux-amd64*
5965
6066
charts:
6167
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustfs-operator"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2024"
55
rust-version = "1.92"
66
license = "MIT OR Apache-2.0"

Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
FROM rust:1.97.0-trixie AS builder
1+
FROM ghcr.io/openprojectx/dockerhub/library/rust:1.97.0-trixie AS builder
22
WORKDIR /build
3+
4+
# Dependency layer: build all dependencies against dummy sources so the
5+
# layer is keyed on Cargo.toml only and survives source-code changes
6+
# (persisted across CI runs by the buildx GHA cache).
37
COPY Cargo.toml ./
8+
RUN mkdir src \
9+
&& echo 'fn main() {}' > src/main.rs \
10+
&& touch src/lib.rs \
11+
&& cargo build --release --bin rustfs-operator \
12+
&& rm -rf src
13+
414
COPY src ./src
5-
RUN cargo build --release --bin rustfs-operator
15+
# touch so cargo rebuilds the crate itself against the real sources
16+
RUN touch src/main.rs src/lib.rs \
17+
&& cargo build --release --bin rustfs-operator
618

719
FROM debian:trixie-slim
820
RUN apt-get update \

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ cargo run --release -- run
6666
Push a `v*` tag. The release workflow builds and pushes
6767
`ghcr.io/openprojectx/rustfs-operator:<version>`, packages the Helm chart to
6868
the `gh-pages` chart repository, and creates a GitHub release with the CRD
69-
manifest and a linux-amd64 binary attached.
69+
manifest attached. Set the repository variable `RELEASE_BINARY=true` to also
70+
build and attach a linux-amd64 binary.
7071

7172
## Behavior notes
7273

tests/common/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use testcontainers::core::{IntoContainerPort, WaitFor};
77
use testcontainers::runners::AsyncRunner;
88
use testcontainers::{ContainerAsync, GenericImage, ImageExt};
99

10-
pub const RUSTFS_IMAGE: (&str, &str) = ("rustfs/rustfs", "1.0.0-beta.8");
10+
pub const RUSTFS_IMAGE: (&str, &str) = (
11+
"ghcr.io/openprojectx/dockerhub/rustfs/rustfs",
12+
"1.0.0-beta.8",
13+
);
1114

1215
/// Container tests talk to 127.0.0.1; a system proxy must not intercept
1316
/// those connections (kube also refuses proxy env vars unless its proxy

tests/e2e_k3s.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use rustfs_operator::crd::{
2626
use rustfs_operator::provider::RustFs;
2727
use rustfs_operator::reconcile;
2828

29+
const K3S_IMAGE: &str = "ghcr.io/openprojectx/dockerhub/rancher/k3s";
2930
const K3S_TAG: &str = "v1.34.9-k3s1";
3031
const NS: &str = "default";
3132

@@ -86,6 +87,7 @@ async fn operator_reconciles_crs_against_rustfs() {
8687
let conf_dir = tempfile::tempdir().expect("tempdir");
8788
let k3s = K3s::default()
8889
.with_conf_mount(conf_dir.path())
90+
.with_name(K3S_IMAGE)
8991
.with_tag(K3S_TAG)
9092
.with_privileged(true)
9193
.with_userns_mode("host")

0 commit comments

Comments
 (0)