2025-11-09 07:13:31 -09:00
|
|
|
# Use `just buildimg` to build this, or:
|
|
|
|
|
#
|
|
|
|
|
# buildah build --skip-unused-stages=false -t chunkah .
|
|
|
|
|
|
2026-05-27 17:12:21 -08:00
|
|
|
ARG BASE=quay.io/fedora/fedora-minimal:44
|
2026-01-29 07:43:20 -09:00
|
|
|
ARG DNF_FLAGS="-y --setopt=install_weak_deps=False"
|
2026-03-03 10:49:05 -09:00
|
|
|
ARG CACHE_ID=chunkah-target
|
2025-11-09 07:13:31 -09:00
|
|
|
|
|
|
|
|
FROM ${BASE} AS builder
|
2026-01-29 07:43:20 -09:00
|
|
|
ARG DNF_FLAGS
|
2026-03-03 10:49:05 -09:00
|
|
|
ARG CACHE_ID
|
2025-11-09 07:13:31 -09:00
|
|
|
RUN --mount=type=cache,rw,id=dnf,target=/var/cache/libdnf5 \
|
2026-01-30 12:00:21 -09:00
|
|
|
dnf install ${DNF_FLAGS} cargo rust pkg-config openssl-devel zlib-devel
|
2025-11-09 07:13:31 -09:00
|
|
|
WORKDIR /build
|
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
|
|
|
COPY src ./src
|
|
|
|
|
RUN --mount=type=cache,rw,id=cargo,target=/root/.cargo \
|
2026-03-03 10:49:05 -09:00
|
|
|
--mount=type=cache,rw,id=${CACHE_ID},target=/build/target \
|
2025-11-09 07:13:31 -09:00
|
|
|
cargo build --release && cp /build/target/release/chunkah /usr/bin
|
|
|
|
|
|
2026-05-01 06:11:46 -08:00
|
|
|
# XXX: Temporary hack until Fedora learns to read PQC sigs from el10 images.
|
|
|
|
|
FROM quay.io/centos/centos:stream10 AS c10s
|
|
|
|
|
RUN dnf download -y --repo baseos rpm-sequoia --destdir=/rpms
|
2026-05-27 16:40:32 -08:00
|
|
|
RUN cp /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial-SHA256 /rpms/
|
2026-05-01 06:11:46 -08:00
|
|
|
|
2025-11-09 07:13:31 -09:00
|
|
|
FROM ${BASE} AS rootfs
|
2026-01-29 07:43:20 -09:00
|
|
|
ARG DNF_FLAGS
|
2025-11-09 07:13:31 -09:00
|
|
|
RUN --mount=type=cache,id=dnf,target=/mnt \
|
|
|
|
|
cp -a /mnt /var/cache/libdnf5 && \
|
2026-03-02 07:44:32 -09:00
|
|
|
dnf install ${DNF_FLAGS} openssl zlib && rm -rf /var/cache/*
|
2026-05-01 06:11:46 -08:00
|
|
|
COPY --from=c10s /rpms/ /tmp/rpms/
|
2026-05-27 16:40:32 -08:00
|
|
|
RUN rpm --import /tmp/rpms/RPM-GPG-KEY-centosofficial-SHA256 && \
|
|
|
|
|
rpm --checksig /tmp/rpms/rpm-sequoia-*.rpm && \
|
|
|
|
|
rpm -Uvh --oldpackage /tmp/rpms/rpm-sequoia-*.rpm && rm -rf /tmp/rpms
|
2025-11-09 07:13:31 -09:00
|
|
|
COPY --from=builder /usr/bin/chunkah /usr/bin/chunkah
|
2026-03-02 08:00:43 -09:00
|
|
|
# Repeat inline config below for the `--no-chunk` flow. See related XXX below.
|
|
|
|
|
ENTRYPOINT ["/usr/bin/chunkah"]
|
|
|
|
|
ENV CHUNKAH_ROOTFS=/chunkah
|
|
|
|
|
WORKDIR /srv
|
2025-11-09 07:13:31 -09:00
|
|
|
|
|
|
|
|
FROM rootfs AS rechunk
|
2026-03-02 07:45:13 -09:00
|
|
|
ARG DNF_FLAGS
|
|
|
|
|
RUN --mount=type=cache,rw,id=dnf,target=/var/cache/libdnf5 \
|
|
|
|
|
dnf install ${DNF_FLAGS} sqlite
|
2025-11-09 07:13:31 -09:00
|
|
|
COPY --from=rootfs / /rootfs
|
2026-03-02 07:45:13 -09:00
|
|
|
RUN for db in /rootfs/var/lib/rpm/rpmdb.sqlite \
|
|
|
|
|
/rootfs/usr/lib/sysimage/libdnf5/transaction_history.sqlite \
|
|
|
|
|
/rootfs/var/lib/dnf/history.sqlite; do \
|
|
|
|
|
if [ -f "${db}" ]; then sqlite3 "${db}" "PRAGMA journal_mode = DELETE;"; fi; \
|
|
|
|
|
done
|
2026-03-02 08:00:43 -09:00
|
|
|
## XXX: Work around https://github.com/containers/buildah/issues/6652 for
|
|
|
|
|
## our own image for now by just passing a config manually rather than using
|
|
|
|
|
## Containerfile directives in the final stage.
|
2025-11-09 07:13:31 -09:00
|
|
|
RUN --mount=type=bind,target=/run/src,rw \
|
2026-03-02 08:00:43 -09:00
|
|
|
chunkah build --rootfs /rootfs \
|
|
|
|
|
--config-str '{"Config": {"Entrypoint": ["/usr/bin/chunkah"], "Env": ["CHUNKAH_ROOTFS=/chunkah"], "WorkingDir": "/srv"}}' \
|
2026-04-22 14:52:55 -08:00
|
|
|
--output oci:/run/src/out
|
2025-11-09 07:13:31 -09:00
|
|
|
|
2026-04-22 14:52:55 -08:00
|
|
|
FROM oci:out
|