Skip to content

Commit fbc5a94

Browse files
committed
initial commit
Signed-off-by: Akihiro Suda <[email protected]>
0 parents  commit fbc5a94

File tree

8 files changed

+515
-0
lines changed

8 files changed

+515
-0
lines changed

.github/workflows/main.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Build
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- 'release/**'
8+
pull_request:
9+
jobs:
10+
example:
11+
runs-on: ubuntu-22.04
12+
timeout-minutes: 10
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
dockerfile:
17+
- "Dockerfile.archlinux"
18+
- "Dockerfile.alpine"
19+
- "Dockerfile.debian"
20+
- "Dockerfile.fedora"
21+
- "Dockerfile.opensuse"
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: docker/setup-buildx-action@v2
25+
- uses: docker/metadata-action@v4
26+
id: meta
27+
with:
28+
images: example
29+
- name: Build and push
30+
uses: docker/build-push-action@v3
31+
with:
32+
context: .
33+
cache-from: type=gha
34+
cache-to: type=gha,mode=max
35+
file: ${{ matrix.dockerfile }}
36+
push: false
37+
tags: ${{ steps.meta.outputs.tags }}
38+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile.alpine

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ARG PACKAGES="gcc neofetch"
2+
3+
# PKG_CACHE defaults to the "pkg-cache-local" stage in this image.
4+
# Can be overridden to a custom image for reproducible builds.
5+
ARG PKG_CACHE=pkg-cache-local
6+
7+
ARG BASE=alpine:3.18.3@sha256:7144f7bab3d4c2648d7e59409f15ec52a18006a128c733fcff20d3a4a54ba44a
8+
9+
FROM ${BASE} AS base
10+
11+
FROM base AS pkg-cache-local-base
12+
ARG PACKAGES
13+
RUN mkdir -p /etc/apk/cache && \
14+
apk update && \
15+
apk cache download --available --add-dependencies ${PACKAGES}
16+
17+
FROM scratch AS pkg-cache-local
18+
COPY --from=pkg-cache-local-base /etc/apk/cache /etc/apk/cache
19+
20+
# pkg-cache is the stage to collect package cache files.
21+
# This stage can be pushed for the sake of reproducible builds.
22+
FROM ${PKG_CACHE} AS pkg-cache
23+
24+
FROM base
25+
ARG PACKAGES
26+
RUN \
27+
--mount=from=pkg-cache,source=/etc/apk/cache,target=/etc/apk/cache,rw \
28+
--network=none \
29+
apk add --no-network ${PACKAGES}
30+
# The package signatures are verified by apk

Dockerfile.archlinux

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ARG PACKAGES="gcc neofetch"
2+
3+
# PKG_CACHE defaults to the "pkg-cache-local" stage in this image.
4+
# Can be overridden to a custom image for reproducible builds.
5+
ARG PKG_CACHE=pkg-cache-local
6+
7+
ARG BASE=archlinux:base-20230910.0.177821
8+
9+
FROM ${BASE} AS base
10+
11+
FROM base AS pkg-cache-local-base
12+
ARG PACKAGES
13+
RUN pacman -S --noconfirm --refresh --downloadonly ${PACKAGES}
14+
15+
FROM scratch AS pkg-cache-local
16+
COPY --from=pkg-cache-local-base /var/cache/pacman /var/cache/pacman
17+
COPY --from=pkg-cache-local-base /var/lib/pacman/sync /var/lib/pacman/sync
18+
19+
# pkg-cache is the stage to collect package cache files.
20+
# This stage can be pushed for the sake of reproducible builds.
21+
FROM ${PKG_CACHE} AS pkg-cache
22+
23+
FROM base
24+
ADD --chmod=0755 <<-"EOT" /usr/local/bin/verify-var-cache-pacman-pkg.sh
25+
#!/bin/bash
26+
set -eux -o pipefail
27+
for pkg in /var/cache/pacman/pkg/*.tar.zst; do
28+
pacman-key --verify "${pkg}.sig"
29+
done
30+
EOT
31+
ARG PACKAGES
32+
RUN \
33+
--mount=from=pkg-cache,source=/var/cache/pacman,target=/var/cache/pacman,rw \
34+
--mount=from=pkg-cache,source=/var/lib/pacman/sync,target=/var/lib/pacman/sync,rw \
35+
--network=none \
36+
verify-var-cache-pacman-pkg.sh && \
37+
pacman -S --noconfirm ${PACKAGES}
38+
# WARNING: the repository signatures (`/var/cache/pacman/pkg/*.sig`)
39+
# are only verified on running downloading packages.
40+
# The signatures are just ignored on installing the packages from the cache.
41+
#
42+
# As a workaround, the signatures are verified with the `verify-var-cache-pacman-pkg.sh`
43+
# script above, however, this script might not be as robust as `pacman -Sy`.
44+
#
45+
# For ArchLinux, consider using https://github.com/reproducible-containers/repro-sources-list.sh
46+
# instead.

Dockerfile.debian

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
ARG PACKAGES="gcc neofetch"
2+
3+
# PKG_CACHE defaults to the "pkg-cache-local" stage in this image.
4+
# Can be overridden to a custom image for reproducible builds.
5+
ARG PKG_CACHE=pkg-cache-local
6+
7+
# The base image can be Ubuntu too.
8+
ARG BASE=debian:bookworm-20230904-slim
9+
10+
FROM ${BASE} AS base
11+
12+
FROM base AS pkg-cache-local-base
13+
ARG PACKAGES
14+
ENV DEBIAN_FRONTEND=noninteractive
15+
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
16+
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache && \
17+
apt-get update && \
18+
apt-get install -y --download-only ${PACKAGES}
19+
20+
FROM scratch AS pkg-cache-local
21+
COPY --from=pkg-cache-local-base /var/cache/apt /var/cache/apt
22+
COPY --from=pkg-cache-local-base /var/lib/apt /var/lib/apt
23+
24+
# pkg-cache is the stage to collect package cache files.
25+
# This stage can be pushed for the sake of reproducible builds.
26+
FROM ${PKG_CACHE} AS pkg-cache
27+
28+
FROM base
29+
ADD --chmod=0755 <<-"EOT" /usr/local/bin/verify-var-lib-apt-lists.sh
30+
#!/bin/bash
31+
set -eux -o pipefail
32+
for ir in /var/lib/apt/lists/*InRelease; do
33+
verified=0
34+
for keyring in /usr/share/keyrings/*.gpg; do
35+
if gpgv --keyring "${keyring}" "${ir}"; then
36+
verified=1
37+
break
38+
fi
39+
done
40+
if [ "${verified}" != "1" ]; then
41+
echo >&2 "Failed to verify ${ir}"
42+
exit 1
43+
fi
44+
echo "Verified: gpgv --keyring ${keyring} ${ir}"
45+
done
46+
EOT
47+
ENV DEBIAN_FRONTEND=noninteractive
48+
ARG PACKAGES
49+
RUN \
50+
--mount=from=pkg-cache,source=/var/cache/apt,target=/var/cache/apt,rw \
51+
--mount=from=pkg-cache,source=/var/lib/apt,target=/var/lib/apt,rw \
52+
--network=none \
53+
verify-var-lib-apt-lists.sh && \
54+
apt-get install -y --no-download ${PACKAGES}
55+
56+
# WARNING: the repository signatures (`/var/lib/apt/lists/*InRelease`)
57+
# are only verified on running `apt-get update`.
58+
# The signatures are just ignored on running `apt-get install --no-download`.
59+
#
60+
# As a workaround, the signatures are verified with the `verify-var-lib-apt-lists.sh`
61+
# script above, however, this script might not be as robust as `apt-get update`.
62+
#
63+
# For Debian and Ubuntu, consider using https://github.com/reproducible-containers/repro-sources-list.sh
64+
# instead.

Dockerfile.fedora

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
ARG PACKAGES="gcc neofetch"
2+
3+
# PKG_CACHE defaults to the "pkg-cache-local" stage in this image.
4+
# Can be overridden to a custom image for reproducible builds.
5+
ARG PKG_CACHE=pkg-cache-local
6+
7+
# The base image can be CentOS Stream, Rocky Linux, and AlmaLinux too.
8+
ARG BASE=fedora:38@sha256:6fc00f83a1b6526b1c6562e30f552d109ba8e269259c6742a26efab1b7aef59e
9+
10+
FROM ${BASE} AS base
11+
12+
FROM base AS pkg-cache-local-base
13+
ARG PACKAGES
14+
RUN dnf install -y --downloadonly ${PACKAGES}
15+
16+
FROM scratch AS pkg-cache-local
17+
COPY --from=pkg-cache-local-base /var/cache/dnf /var/cache/dnf
18+
19+
# pkg-cache is the stage to collect package cache files.
20+
# This stage can be pushed for the sake of reproducible builds.
21+
FROM ${PKG_CACHE} AS pkg-cache
22+
23+
FROM base
24+
ARG PACKAGES
25+
RUN \
26+
--mount=from=pkg-cache,source=/var/cache/dnf,target=/var/cache/dnf,rw \
27+
--network=none \
28+
dnf install -y --cacheonly ${PACKAGES}
29+
# The package signatures are verified by rpm

Dockerfile.opensuse

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ARG PACKAGES="gcc neofetch"
2+
3+
# PKG_CACHE defaults to the "pkg-cache-local" stage in this image.
4+
# Can be overridden to a custom image for reproducible builds.
5+
ARG PKG_CACHE=pkg-cache-local
6+
7+
ARG BASE=opensuse/leap:15.5@sha256:987224e4850af16eef9c89dee43c7bfbbe3b197f8abaf926aec8ad2043b5b577
8+
9+
FROM ${BASE} AS base
10+
11+
FROM base AS pkg-cache-local-base
12+
ARG PACKAGES
13+
RUN zypper install -y --download-only ${PACKAGES}
14+
15+
FROM scratch AS pkg-cache-local
16+
COPY --from=pkg-cache-local-base /var/cache/zypp /var/cache/zypp
17+
18+
# pkg-cache is the stage to collect package cache files.
19+
# This stage can be pushed for the sake of reproducible builds.
20+
FROM ${PKG_CACHE} AS pkg-cache
21+
22+
FROM base
23+
ARG PACKAGES
24+
RUN \
25+
--mount=from=pkg-cache,source=/var/cache/zypp,target=/var/cache/zypp,rw \
26+
--network=none \
27+
zypper --no-refresh install -y ${PACKAGES}
28+
# The package signatures are verified by zypper

0 commit comments

Comments
 (0)