This repository has been archived by the owner on Jun 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from kpcyrd/archlinux-docker
Add support for Arch Linux Dockerfiles
- Loading branch information
Showing
3 changed files
with
122 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# syntax = docker.io/docker/dockerfile:1.4@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc | ||
# Generated by repro-get. | ||
|
||
# "Timetraveling" Dockerfile for generating the hash file with a past snapshot. | ||
|
||
# ⚠️ EXPERIMENTAL ⚠️ | ||
|
||
# Usage: | ||
# ---------------------------------------------------------- | ||
# export DOCKER_BUILDKIT=1 | ||
# docker build --output . -f Dockerfile.generate-hash . | ||
# ---------------------------------------------------------- | ||
|
||
# Output files: | ||
# - SHA256SUMS-{{.OCIArchDashVariant}}: the hash file | ||
|
||
ARG BASE_IMAGE={{.BaseImage}} # {{.BaseImageOrig}} | ||
ARG PACKAGES="{{join .Packages " "}}" | ||
|
||
ARG REPRO_GET_VERSION={{.ReproGetVersion}} | ||
ARG REPRO_GET_SHA256SUMS_SHA256SUM={{.ReproGetSHASHA}} | ||
{{snippet "fetch-repro-get"}} | ||
|
||
FROM --platform=${TARGETPLATFORM} ${BASE_IMAGE} AS generate-hash | ||
ARG PACKAGES | ||
ARG TARGETARCH | ||
ARG TARGETVARIANT | ||
SHELL ["/bin/bash", "-c"] | ||
RUN \ | ||
--mount=type=cache,target=/var/cache/pacman \ | ||
--mount=type=cache,target=/var/cache/repro-get \ | ||
--mount=type=bind,from=repro-get,source=/repro-get.linux-${TARGETARCH}${TARGETVARIANT:+-${TARGETVARIANT}},target=/usr/local/bin/repro-get \ | ||
set -eux -o pipefail; \ | ||
export SOURCE_DATE_EPOCH="$(stat --format=%Y /var/log/pacman.log)" && \ | ||
date -d "@${SOURCE_DATE_EPOCH}" '+Server = https://archive.archlinux.org/repos/%Y/%m/%d/$repo/os/$arch' > /etc/pacman.d/mirrorlist && \ | ||
pacman -Sy && \ | ||
mkdir -p /out && \ | ||
/usr/local/bin/repro-get hash generate >"/out/SHA256SUMS-preinstalled" && \ | ||
pacman -Su --noconfirm ${PACKAGES} && \ | ||
/usr/local/bin/repro-get hash generate --dedupe "/out/SHA256SUMS-preinstalled" >"/out/SHA256SUMS-${TARGETARCH}${TARGETVARIANT:+-${TARGETVARIANT}}" && \ | ||
rm -f "/out/SHA256SUMS-preinstalled" && \ | ||
chmod 444 /out/* && \ | ||
touch --date=@${SOURCE_DATE_EPOCH} /out/* | ||
|
||
FROM scratch | ||
COPY --from=generate-hash /out/ / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# syntax = docker.io/docker/dockerfile:1.4@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc | ||
# Generated by repro-get. | ||
|
||
# Dockerfile for building a container image using the hash file. | ||
|
||
# ⚠️ EXPERIMENTAL ⚠️ | ||
|
||
# Usage: | ||
# Make sure that the hash file "SHA256SUMS-{{.OCIArchDashVariant}}" is present in the current directory. | ||
# ---------------------------------------------------------- | ||
# export DOCKER_BUILDKIT=1 | ||
# docker build . | ||
# ---------------------------------------------------------- | ||
|
||
ARG BASE_IMAGE={{.BaseImage}} # {{.BaseImageOrig}} | ||
ARG REPRO_GET_PROVIDER={{join .Providers ","}} | ||
|
||
ARG REPRO_GET_VERSION={{.ReproGetVersion}} | ||
ARG REPRO_GET_SHA256SUMS_SHA256SUM={{.ReproGetSHASHA}} | ||
{{snippet "fetch-repro-get"}} | ||
|
||
FROM --platform=${TARGETPLATFORM} ${BASE_IMAGE} | ||
ARG TARGETARCH | ||
ARG TARGETVARIANT | ||
ARG REPRO_GET_PROVIDER | ||
SHELL ["/bin/bash", "-c"] | ||
# The cache dir is mounted under a directory inside tmpfs (/dev/*), so that the mount point directory does not remain in the image | ||
RUN \ | ||
--mount=type=cache,target=/dev/.cache/repro-get \ | ||
--mount=type=bind,from=repro-get,source=/repro-get.linux-${TARGETARCH}${TARGETVARIANT:+-${TARGETVARIANT}},target=/usr/local/bin/repro-get \ | ||
--mount=type=bind,source=.,target=/mnt \ | ||
set -eux -o pipefail ; \ | ||
export SOURCE_DATE_EPOCH="$(stat --format=%Y /var/log/pacman.log)" && \ | ||
pacman-key --init && \ | ||
/usr/local/bin/repro-get --provider="${REPRO_GET_PROVIDER}" --cache=/dev/.cache/repro-get install "/mnt/SHA256SUMS-${TARGETARCH}${TARGETVARIANT:+-${TARGETVARIANT}}" && \ | ||
: Removing web of trust private key && \ | ||
rm -rf /etc/pacman.d/gnupg && \ | ||
: Remove unneeded files for reproducibility && \ | ||
find /var/log -name '*.log' -or -name '*.log.*' -newermt "@${SOURCE_DATE_EPOCH}" -not -type d | xargs rm -f && \ | ||
find /run /tmp -newermt "@${SOURCE_DATE_EPOCH}" -not -type d -xdev | xargs rm -f && \ | ||
rm -f /var/cache/ldconfig/* && \ | ||
: Reset the timestamp for reproducibility && \ | ||
find $( ls / | grep -E -v "^(dev|mnt|proc|sys)$" ) -newermt "@${SOURCE_DATE_EPOCH}" -writable -xdev | xargs touch --date="@${SOURCE_DATE_EPOCH}" --no-dereference | ||
SHELL ["/bin/sh", "-c"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters