# syntax=docker/dockerfile:1
#
# scropple, packaged as a .deb and an .rpm (the gitgud CLI's recipe):
#
# docker buildx build --target packages \
# --output type=local,dest=./dist --file packaging/Dockerfile .
#
# Two builds, because a Rust binary is linked against the glibc of what
# compiled it: the .deb on Debian trixie, the .rpm on EL9 (the oldest
# glibc in the rpm world worth shipping to; it runs on current Fedora and
# openSUSE too). Dependencies compile from Cargo.toml + Cargo.lock alone
# first, so that layer survives in the registry cache across commits.
# cmake and a C toolchain: aws-lc-sys (rustls) is compiled.
ARG RUST_VERSION=1.98
ARG PKG_VERSION=
ARG RPM_RELEASE=1
ARG MAINTAINER=
ARG SUITES="trixie forky"
# ── .deb, on Debian trixie ───────────────────────────────────────────
FROM docker.io/rust:${RUST_VERSION}-trixie AS deb-builder
# dpkg-dev: dpkg-shlibdeps, behind cargo-deb's `$auto` dependencies.
RUN apt-get update \
&& apt-get install -y --no-install-recommends cmake perl pkg-config dpkg-dev \
&& rm -rf /var/lib/apt/lists/* \
&& rustup component add rustfmt clippy \
&& cargo install --locked cargo-deb
WORKDIR /src
# Dependencies first, against stubs: everything but this crate.
COPY Cargo.toml Cargo.lock ./
RUN mkdir -p src examples \
&& echo 'fn main() {}' > src/main.rs \
&& touch src/lib.rs \
&& echo 'fn main() {}' > examples/fake_player.rs \
&& cargo build --release --locked \
&& rm -rf src examples target/release/scropple target/release/deps/scropple* target/release/deps/libscropple* target/release/.fingerprint/scropple-*
COPY . .
ARG PKG_VERSION
ARG MAINTAINER
ARG SUITES
ARG SOURCE_DATE_EPOCH
# The checks run here: a package isn't worth building from a tree that
# fails them. One .deb per suite, the same bytes under a different
# version suffix (a trixie build runs on forky).
RUN set -eux; \
mkdir -p /out; \
cargo fmt --check; \
cargo clippy --all-targets --locked -- -D warnings; \
cargo test --locked; \
for suite in $SUITES; do \
set --; \
if [ -n "$PKG_VERSION" ]; then set -- --deb-version "${PKG_VERSION}+${suite}"; fi; \
if [ -n "$MAINTAINER" ]; then set -- "$@" --maintainer "$MAINTAINER"; fi; \
cargo deb --locked "$@"; \
cp target/debian/*.deb /out/; \
rm -f target/debian/*.deb; \
done; \
for package in /out/*.deb; do \
dpkg-deb -f "$package" Depends | grep -q libc6 \
|| { echo "$package declares no library dependencies — is dpkg-dev installed?" >&2; exit 1; }; \
done; \
ls -l /out
# ── .rpm, on EL9 ─────────────────────────────────────────────────────
# The toolchain is copied from the Debian image rather than downloaded:
# EL9's curl can't load a CA file on the forge's runner (see gitgud's
# cli/Dockerfile). Official rust builds target glibc 2.17, so they run here.
FROM docker.io/rust:${RUST_VERSION}-trixie AS toolchain
FROM docker.io/rockylinux/rockylinux:9 AS rpm-builder
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:${PATH}
COPY --from=toolchain /usr/local/rustup /usr/local/rustup
COPY --from=toolchain /usr/local/cargo /usr/local/cargo
COPY --from=toolchain /etc/ssl/certs/ca-certificates.crt /etc/pki/ca-trust/scropple-ca-bundle.pem
ENV CURL_CA_BUNDLE=/etc/pki/ca-trust/scropple-ca-bundle.pem \
SSL_CERT_FILE=/etc/pki/ca-trust/scropple-ca-bundle.pem \
CARGO_HTTP_CAINFO=/etc/pki/ca-trust/scropple-ca-bundle.pem
RUN set -eux; \
dnf -y install gcc gcc-c++ make cmake perl; \
dnf clean all; \
cargo install --locked cargo-generate-rpm
WORKDIR /src
COPY Cargo.toml Cargo.lock ./
RUN mkdir -p src examples \
&& echo 'fn main() {}' > src/main.rs \
&& touch src/lib.rs \
&& echo 'fn main() {}' > examples/fake_player.rs \
&& cargo build --release --locked \
&& rm -rf src examples target/release/scropple target/release/deps/scropple* target/release/deps/libscropple* target/release/.fingerprint/scropple-*
COPY . .
ARG RPM_RELEASE
# cargo-generate-rpm clamps mtimes and the build time to it.
ARG SOURCE_DATE_EPOCH
# The CI stamp goes in the release: `0.ci…` sorts before `1`, so a later
# tagged x.y.z-1 upgrades over it.
RUN set -eux; \
cargo build --release --locked; \
cargo generate-rpm --set-metadata "release = \"${RPM_RELEASE}\""; \
mkdir -p /out; \
cp target/generate-rpm/*.rpm /out/; \
ls -l /out
# ── what CI collects ─────────────────────────────────────────────────
FROM scratch AS packages
COPY --from=deb-builder /out/ /
COPY --from=rpm-builder /out/ /
neiam
/scropple-linux
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
4.8 KiB · text
History
0463cca