Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reproducible builds for Debian #248

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions 2.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
FROM debian:bookworm-slim

ADD --chmod=0755 --checksum=sha256:4e7e6536b206488b2414d1fa2272e8bbf17fbe7d11e5648eb51284c8fa96b0a9 \
https://raw.githubusercontent.com/reproducible-containers/repro-sources-list.sh/v0.1.1/repro-sources-list.sh \
/usr/local/bin/repro-sources-list.sh

# SOURCE_DATE_EPOCH is consumed by repro-sources-list.sh and build scripts
ARG SOURCE_DATE_EPOCH

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
#RUN groupadd -r www-data && useradd -r --create-home -g www-data www-data

Expand All @@ -11,7 +18,20 @@ WORKDIR $HTTPD_PREFIX

# install httpd runtime dependencies
# https://httpd.apache.org/docs/2.4/install.html#requirements
RUN set -eux; \
#
# When the secret "enable-repro-sources-list" is supplied,
# /etc/apt is reconfigured to use `snapshot[-cloudflare].debian.org/archive/debian/<SOURCE_DATE_EPOCH>` to
# reproduce packages. Disabled by default due to the slowness.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note: while snapshot[-cloudflare].debian.org is quite slow, snapshot.ubuntu.com for Ubuntu seems fast enough to adopt as the default)

https://ubuntu.com/blog/ubuntu-snapshots-on-azure-ensuring-predictability-and-consistency-in-cloud-deployments

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR is still not acceptable, I'd like to open a PR to add the Ubuntu variant with the fast snapshot.ubuntu.com.

# This is treated as a "secret" to hide it from build history for the reproducibility of the OCI config blob,
# but its content is not confidential and can be just /dev/null.
RUN \
--mount=type=cache,target=/var/cache/apt \
--mount=type=secret,id=enable-repro-sources-list,target=/mnt/enable-repro-sources-list \
set -eux; \
if [ -e /mnt/enable-repro-sources-list ]; then \
cp -a /etc/apt /etc/apt.bak; \
repro-sources-list.sh; \
fi; \
apt-get update; \
apt-get install -y --no-install-recommends \
# https://github.com/docker-library/httpd/issues/214
Expand All @@ -20,7 +40,13 @@ RUN set -eux; \
# https://github.com/docker-library/httpd/issues/209
libldap-common \
; \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* ; \
if [ -e /mnt/enable-repro-sources-list ]; then \
rm -rf /etc/apt; \
mv /etc/apt.bak /etc/apt; \
fi; \
# clean up for reproducibility
rm -rf /var/log/* /var/cache/ldconfig/aux-cache

ENV HTTPD_VERSION 2.4.58
ENV HTTPD_SHA256 fa16d72a078210a54c47dd5bef2f8b9b8a01d94909a51453956b3ec6442ea4c5
Expand All @@ -29,8 +55,15 @@ ENV HTTPD_SHA256 fa16d72a078210a54c47dd5bef2f8b9b8a01d94909a51453956b3ec6442ea4c
ENV HTTPD_PATCHES=""

# see https://httpd.apache.org/docs/2.4/install.html#requirements
RUN set -eux; \
RUN \
--mount=type=cache,target=/var/cache/apt \
--mount=type=secret,id=enable-repro-sources-list,target=/mnt/enable-repro-sources-list \
set -eux; \
\
if [ -e /mnt/enable-repro-sources-list ]; then \
cp -a /etc/apt /etc/apt.bak; \
repro-sources-list.sh; \
fi; \
# mod_http2 mod_lua mod_proxy_html mod_xml2enc
# https://anonscm.debian.org/cgit/pkg-apache/apache2.git/tree/debian/control?id=adb6f181257af28ee67af15fc49d2699a0080d4c
savedAptMark="$(apt-mark showmanual)"; \
Expand All @@ -56,6 +89,10 @@ RUN set -eux; \
zlib1g-dev \
; \
rm -r /var/lib/apt/lists/*; \
if [ -e /mnt/enable-repro-sources-list ]; then \
rm -rf /etc/apt; \
mv /etc/apt.bak /etc/apt; \
fi; \
\
ddist() { \
local f="$1"; shift; \
Expand All @@ -71,7 +108,7 @@ RUN set -eux; \
https://www.apache.org/dist/ \
https://archive.apache.org/dist/ \
; do \
if wget -O "$f" "$distUrl$distFile" && [ -s "$f" ]; then \
if wget --no-hsts -O "$f" "$distUrl$distFile" && [ -s "$f" ]; then \
success=1; \
break; \
fi; \
Expand Down Expand Up @@ -228,7 +265,9 @@ RUN set -eux; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
\
# smoke test
httpd -v
httpd -v; \
# clean up for reproducibility
rm -rf /var/log/* /var/cache/ldconfig/aux-cache

# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
STOPSIGNAL SIGWINCH
Expand Down
1 change: 1 addition & 0 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ cat <<-EOH
Maintainers: Tianon Gravi <[email protected]> (@tianon),
Joseph Ferguson <[email protected]> (@yosifkit)
GitRepo: https://github.com/docker-library/httpd.git
Builder: buildkit
EOH

# prints "$2$1$3$1...$N"
Expand Down