Skip to content

Commit

Permalink
Make image builds reproducible
Browse files Browse the repository at this point in the history
  • Loading branch information
HadrienPatte committed Aug 25, 2024
1 parent 9aada81 commit a92dd78
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 18 deletions.
11 changes: 9 additions & 2 deletions .github/scripts/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,34 @@ echo "Building $IMAGE"
DEFAULT_GOLANG_VERSION="1.21"
DEFAULT_CHISEL_VERSION="v0.10.0"

RELEASE=$(./images/${IMAGE}/latest.sh)
REPOSITORY=$(jq -r '.repository' ./images/${IMAGE}/metadata.json)
RELEASE_METADATA=$(curl -s "https://api.github.com/repos/${REPOSITORY}/releases/latest")
SOURCE_DATE_EPOCH=$(date +%s -d $(echo ${RELEASE_METADATA} | jq -r '.created_at'))
RELEASE=$(echo ${RELEASE_METADATA} | jq -r '.tag_name')
VERSION=${RELEASE%%_*}
VERSION=${VERSION#release-}
VERSION=${VERSION#v}

echo "Version $VERSION"
if [[ -z $VERSION ]]; then
echo "Failed to retrieve latest version for $IMAGE"
else
docker buildx build \
--push \
--platform linux/amd64,linux/arm64 \
--provenance=false \
--tag ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${IMAGE}:${VERSION} \
--tag ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${IMAGE}:latest \
--build-arg RELEASE=${RELEASE} \
--build-arg VERSION=${VERSION} \
--build-arg GOLANG_VERSION=${DEFAULT_GOLANG_VERSION} \
--build-arg CHISEL_VERSION=${DEFAULT_CHISEL_VERSION} \
--build-arg SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
--label "org.opencontainers.image.authors=${GITHUB_REPOSITORY_OWNER}" \
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
--label "org.opencontainers.image.version=${VERSION}" \
--label "org.opencontainers.image.vendor=${GITHUB_REPOSITORY_OWNER}" \
--label "org.opencontainers.image.title=${IMAGE}" \
--output type=registry,name=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${IMAGE}:${VERSION},rewrite-timestamp=true \
--output type=registry,name=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${IMAGE}:latest,rewrite-timestamp=true \
- < images/${IMAGE}/Dockerfile
fi
4 changes: 0 additions & 4 deletions images/prowlarr/latest.sh

This file was deleted.

3 changes: 3 additions & 0 deletions images/prowlarr/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"repository": "Prowlarr/Prowlarr"
}
4 changes: 0 additions & 4 deletions images/qbittorrent/latest.sh

This file was deleted.

3 changes: 3 additions & 0 deletions images/qbittorrent/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"repository": "userdocs/qbittorrent-nox-static"
}
4 changes: 0 additions & 4 deletions images/radarr/latest.sh

This file was deleted.

3 changes: 3 additions & 0 deletions images/radarr/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"repository": "Radarr/Radarr"
}
4 changes: 0 additions & 4 deletions images/sonarr/latest.sh

This file was deleted.

3 changes: 3 additions & 0 deletions images/sonarr/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"repository": "Sonarr/Sonarr"
}

0 comments on commit a92dd78

Please sign in to comment.