From 0ef3f33746845e4efeee4283401679ccac1852df Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Fri, 19 Jun 2026 05:57:30 +0200 Subject: [PATCH] feat: Build fully static binary --- .cargo/config.toml | 3 +++ .dockerignore | 2 ++ Dockerfile | 7 ++++--- docker-bake.hcl | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 69d2c54..61e35b2 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,5 @@ [env] RUST_LOG = "automation=debug" + +[target.x86_64-unknown-linux-musl] +rustflags = ["-C", "link-arg=-lc"] diff --git a/.dockerignore b/.dockerignore index ac9867e..56919ad 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,5 @@ .env # Use the rust environment provided by the container rust-toolchain.toml +Dockerfile +docker-bake.hcl diff --git a/Dockerfile b/Dockerfile index 9572b91..dd6e080 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -FROM rust:1.95 AS base -ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse +FROM rust:1.95-alpine AS base RUN cargo install cargo-chef --locked --version 0.1.71 && \ cargo install cargo-auditable --locked --version 0.6.6 WORKDIR /app @@ -10,6 +9,7 @@ COPY . . RUN cargo chef prepare --recipe-path recipe.json FROM base AS builder +RUN apk add --no-cache g++=15.2.0-r2 cmake=4.1.3-r0 make=4.4.1-r3 # HACK: Now we can use unstable feature while on stable rust! ENV RUSTC_BOOTSTRAP=1 COPY --from=planner /app/recipe.json recipe.json @@ -20,7 +20,8 @@ ARG RELEASE_VERSION ENV RELEASE_VERSION=${RELEASE_VERSION} RUN cargo auditable build --release -FROM gcr.io/distroless/cc-debian13:nonroot AS runtime + +FROM scratch AS runtime COPY --from=builder /app/target/release/automation /app/automation ENV AUTOMATION__ENTRYPOINT=/app/config/config.lua ENV LUA_PATH="/app/?.lua;;" diff --git a/docker-bake.hcl b/docker-bake.hcl index ff12c92..b87b391 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -5,7 +5,9 @@ group "default" { targets = ["automation"] } -target "docker-metadata-action" {} +target "docker-metadata-action" { + tags = [] +} target "automation" { inherits = ["docker-metadata-action"]