feat: Build fully static binary

This commit is contained in:
2026-06-19 05:57:30 +02:00
parent d353fa9759
commit 361d799377
4 changed files with 12 additions and 4 deletions
+3
View File
@@ -1,2 +1,5 @@
[env] [env]
RUST_LOG = "automation=debug" RUST_LOG = "automation=debug"
[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "link-arg=-lc"]
+2
View File
@@ -2,3 +2,5 @@
.env .env
# Use the rust environment provided by the container # Use the rust environment provided by the container
rust-toolchain.toml rust-toolchain.toml
Dockerfile
docker-bake.hcl
+4 -3
View File
@@ -1,5 +1,4 @@
FROM rust:1.95 AS base FROM rust:1.95-alpine AS base
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN cargo install cargo-chef --locked --version 0.1.71 && \ RUN cargo install cargo-chef --locked --version 0.1.71 && \
cargo install cargo-auditable --locked --version 0.6.6 cargo install cargo-auditable --locked --version 0.6.6
WORKDIR /app WORKDIR /app
@@ -10,6 +9,7 @@ COPY . .
RUN cargo chef prepare --recipe-path recipe.json RUN cargo chef prepare --recipe-path recipe.json
FROM base AS builder 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! # HACK: Now we can use unstable feature while on stable rust!
ENV RUSTC_BOOTSTRAP=1 ENV RUSTC_BOOTSTRAP=1
COPY --from=planner /app/recipe.json recipe.json COPY --from=planner /app/recipe.json recipe.json
@@ -20,7 +20,8 @@ ARG RELEASE_VERSION
ENV RELEASE_VERSION=${RELEASE_VERSION} ENV RELEASE_VERSION=${RELEASE_VERSION}
RUN cargo auditable build --release RUN cargo auditable build --release
FROM gcr.io/distroless/cc-debian13:nonroot AS runtime
FROM gcr.io/distroless/static-debian13:nonroot AS runtime
COPY --from=builder /app/target/release/automation /app/automation COPY --from=builder /app/target/release/automation /app/automation
ENV AUTOMATION__ENTRYPOINT=/app/config/config.lua ENV AUTOMATION__ENTRYPOINT=/app/config/config.lua
ENV LUA_PATH="/app/?.lua;;" ENV LUA_PATH="/app/?.lua;;"
+3 -1
View File
@@ -5,7 +5,9 @@ group "default" {
targets = ["automation"] targets = ["automation"]
} }
target "docker-metadata-action" {} target "docker-metadata-action" {
tags = []
}
target "automation" { target "automation" {
inherits = ["docker-metadata-action"] inherits = ["docker-metadata-action"]