Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Multiarch push robuust #1

Draft
wants to merge 71 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
2744978
Added ARM64 support with multiarch build
boboldehampsink Sep 6, 2022
7020ef4
Get correct libpq that has packages for both architectures
boboldehampsink Sep 14, 2022
38c8ede
Update installed-packages.txt
boboldehampsink Sep 14, 2022
bdc6c4f
Push latest/no-suffix tags directly after build to support multiarch
boboldehampsink Sep 6, 2022
0152774
Build for Robuust
boboldehampsink Sep 14, 2022
9190299
Install syslinux on amd64 only and always install mtools
boboldehampsink Sep 20, 2022
7de3b54
Merge branch 'multiarch' into multiarch-push-robuust
boboldehampsink Sep 20, 2022
43d86e3
Use regctl to retag images
boboldehampsink Sep 21, 2022
73409f8
Publish to Github via CI
boboldehampsink Oct 6, 2022
1e1e47f
Updated action dependencies
boboldehampsink Oct 13, 2022
6ea8a51
Merge branch 'main' into multiarch
boboldehampsink Oct 26, 2022
3524acc
Merge branch 'multiarch' into multiarch-push-robuust
boboldehampsink Oct 26, 2022
be96e15
Updated libpq-dev
boboldehampsink Oct 26, 2022
e78df83
Merge branch 'multiarch' into multiarch-push-robuust
boboldehampsink Oct 26, 2022
2556e07
Merge branch 'main' into multiarch
boboldehampsink Nov 7, 2022
015ab89
Merge branch 'main' into multiarch-push-robuust
boboldehampsink Nov 7, 2022
24d412d
Merge branch 'main' into multiarch-push-robuust
boboldehampsink Jan 26, 2023
5d5ca70
Merge branch 'heroku:main' into multiarch
boboldehampsink Jan 26, 2023
0a6c4a3
Updated libpq-dev to 15.1-1.pgdg22.04+1
boboldehampsink Jan 26, 2023
6503898
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Jan 26, 2023
95c8182
Fix ci
boboldehampsink Jan 26, 2023
8f68aae
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Jan 26, 2023
36db314
Fix trailing spaces
boboldehampsink Jan 26, 2023
7ef5c15
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Jan 26, 2023
4dc8573
Create buildx driver first
boboldehampsink Jan 26, 2023
118cbe9
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Jan 26, 2023
6e945ee
Don’t build stack
boboldehampsink Jan 26, 2023
b360835
Merge branch 'heroku:main' into multiarch
boboldehampsink Feb 8, 2023
0afbb17
Merge branch 'heroku:main' into multiarch-push
boboldehampsink Feb 8, 2023
a3e6293
Merge branch 'main' into multiarch-push-robuust
boboldehampsink Feb 8, 2023
7f46d2a
Merge branch 'main' into multiarch-push-robuust
boboldehampsink Mar 30, 2023
a6578db
Updated libpq-dev to 15.2.2
boboldehampsink Mar 30, 2023
59ab8ec
Downgrade to available libpq-dev version
boboldehampsink Mar 30, 2023
0cc97cb
Update imagemagick
boboldehampsink Apr 1, 2023
7e56b31
Update setup.sh
boboldehampsink Apr 18, 2023
2724a4f
Merge branch 'main' into multiarch-push-robuust
boboldehampsink Jun 1, 2023
f3baa4d
Updated libpq-dev
boboldehampsink Jun 1, 2023
a5f522d
Merge branch 'main' into multiarch
boboldehampsink Jun 23, 2023
9128aae
Merge branch 'multiarch' into multiarch-push
boboldehampsink Jun 23, 2023
1a06acb
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Jun 23, 2023
aa0613f
Merge branch 'main' into multiarch
boboldehampsink Oct 4, 2023
f34d5a0
Merge branch 'multiarch' into multiarch-push
boboldehampsink Oct 4, 2023
aa3214c
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Oct 4, 2023
a87bddb
Updated libpq
boboldehampsink Oct 4, 2023
73ceae5
Merge branch 'main' into multiarch-push-robuust
boboldehampsink Jan 24, 2024
bb8440c
Updated actions
boboldehampsink Jan 24, 2024
7077830
Updated libpq-dev
boboldehampsink Jan 24, 2024
3121926
Merge branch 'main' into multiarch
boboldehampsink Mar 4, 2024
d67d81a
Merge branch 'multiarch' into multiarch-push
boboldehampsink Mar 4, 2024
fe82762
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Mar 4, 2024
34436f9
Add arg
boboldehampsink Mar 4, 2024
760eb8c
Force buildkit detection
boboldehampsink Mar 4, 2024
7d4c956
Re-add publish suffix
boboldehampsink Mar 4, 2024
8c94e8a
Always build and push
boboldehampsink Mar 4, 2024
6a34881
bump libpq-dev
boboldehampsink Mar 4, 2024
0b46e9d
Merge branch 'main' into multiarch
boboldehampsink Mar 5, 2024
48d96ed
Merge branch 'multiarch' into multiarch-push
boboldehampsink Mar 5, 2024
6a4861c
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Mar 5, 2024
50143ce
Merge branch 'main' into multiarch
boboldehampsink Apr 8, 2024
13c3432
Merge branch 'multiarch' into multiarch-push
boboldehampsink Apr 8, 2024
3444098
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Apr 8, 2024
7b971cc
shellcheck disable=SC2034
boboldehampsink Apr 8, 2024
490bf27
Merge branch 'multiarch' into multiarch-push
boboldehampsink Apr 8, 2024
e3fd3fa
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Apr 8, 2024
65a5e38
syslinux-common
boboldehampsink Apr 8, 2024
3133ea6
Merge branch 'multiarch' into multiarch-push
boboldehampsink Apr 8, 2024
083a2de
Merge branch 'multiarch-push' into multiarch-push-robuust
boboldehampsink Apr 8, 2024
c4e736a
Merge branch 'main' into multiarch-push-robuust
boboldehampsink Apr 19, 2024
cf02dc1
Merge branch 'main' into multiarch-push-robuust
boboldehampsink Apr 22, 2024
4bb290a
Merge branch 'main' into multiarch-push-robuust
boboldehampsink May 30, 2024
9401f26
Merge branch 'main' into multiarch-push-robuust
boboldehampsink Jul 15, 2024
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
39 changes: 0 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,3 @@ jobs:
uses: actions/checkout@v4
- name: Run shellcheck
run: find . -type f \( -name "*.sh" -o -path "*/bin/*" \) ! -name '*.jq' | xargs -t shellcheck
build-stack:
runs-on: ubuntu-22.04
needs:
- shellcheck
env:
STACK: heroku-${{ matrix.stack-version }}
STACK_VERSION: "${{ matrix.stack-version }}"
DOCKER_HUB_TOKEN: "${{ secrets.DOCKER_HUB_TOKEN }}"
DOCKER_HUB_USERNAME: "${{ secrets.DOCKER_HUB_USERNAME }}"
MANIFEST_APP_TOKEN: "${{ secrets.MANIFEST_APP_TOKEN }}"
MANIFEST_APP_URL: "${{ secrets.MANIFEST_APP_URL }}"
strategy:
fail-fast: false
matrix:
stack-version: ["20", "22", "24"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build images
run: bin/build.sh $STACK_VERSION
- name: Check that the generated files are in sync
run: |-
status="$(git status --porcelain)"
if [[ -n "$status" ]]; then
echo "Generated files differ from checked-in versions! Run bin/build.sh to regenerate them locally."
echo -e "\nChanged files:\n${status}\n"
git diff
exit 1
fi
- name: Publish to image registries
run: |-
docker buildx create --use
bin/publish-to-registries.sh
if: success() && (github.ref_name == 'main' || github.ref_type == 'tag')
- name: Unpublish temp tags from this run
run: bin/unpublish-tags.sh
if: always() && (github.ref_name == 'main' || github.ref_type == 'tag')
- name: Convert docker image and for Git tags release to Heroku staging
run: bin/convert-and-publish-to-heroku.sh
28 changes: 28 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Docker

on:
push:
# Publish `multiarch-push-robuust` branch to Container Registry
branches: 'multiarch-push-robuust'

jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into GitHub Container Registry
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build & push image to GitHub Container Registry
run: bin/build.sh 22
82 changes: 34 additions & 48 deletions bin/build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034

set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")/.."
. bin/stack-helpers.sh

REPO="heroku/heroku"
REPO="ghcr.io/robuust/heroku"
STACK_VERSION=${1:-"NAN"}
PUBLISH_SUFFIX=${2:-}
BASE_NAME=$(basename "${BASH_SOURCE[0]}")
Expand Down Expand Up @@ -40,59 +41,50 @@ print_usage(){
EOF
}

# Create buildx driver
docker buildx create --use

[[ $STACK_VERSION =~ ^[0-9]+$ ]] || (>&2 print_usage && abort "fatal: invalid STACK_VERSION")

have_docker_container_driver=
if (docker buildx inspect; true) | grep -q 'Driver:\s*docker-container$'; then
have_docker_container_driver=1
fi
have_docker_container_driver=1

have_containerd_snapshotter=
if docker info -f "{{ .DriverStatus }}" | grep -qF "io.containerd.snapshotter."; then have_containerd_snapshotter=1; fi


if (( STACK_VERSION <= 22 )); then
# heroku/heroku:22 and prior images do not support multiple chip
# architectures or multi-arch images. Instead, they are amd64 only.
DOCKER_ARGS=("build" "--platform=linux/amd64")
# heroku/heroku:22 and prior images need separate *cnb* variants that
# add compatibility for Cloud Native Buildpacks.
VARIANTS=("-build:" "-cnb:" "-cnb-build:-build")
else
# heroku/heroku:24 images and beyond are multi-arch (amd64+arm64) images.
# Due to weak feature support parity between Docker on Linux and Docker
# Desktop building and publishing across platforms has caveats (see the
# top of this file).
if [[ $have_containerd_snapshotter ]] || { [[ $PUBLISH_SUFFIX ]] && [[ $have_docker_container_driver ]]; }; then
DOCKER_ARGS=("buildx" "build" "--platform=linux/amd64,linux/arm64")
elif [[ ! $PUBLISH_SUFFIX ]] && [[ ! $have_docker_container_driver ]]; then
DOCKER_ARGS=("buildx" "build" "--platform=linux/amd64")
>&2 echo "WARNING: heroku-24 and newer images are multi-arch images," \
"but this script is building single architecture images" \
"due to limitations of the current platform." \
"To build a multi-arch image, enable the 'containerd'" \
"snapshotter in Docker Desktop and/or use a 'docker-container'" \
"Docker BuildKit driver."
else
>&2 echo "ERROR: Can't build images with this configuration. Enable" \
"the 'containerd' snapshotter in Docker Desktop, enable" \
"the 'docker-container' driver in Docker, or use this script" \
"in build-only mode (don't provide PUBLISH_SUFFIX argument)."
abort 1
fi
# heroku/heroku:24 and beyond images include CNB specific
# modifications, so separate *cnb* variants are not created.
VARIANTS=("-build:")
fi

if [[ $PUBLISH_SUFFIX ]]; then
# If there is a tag suffix, this script is pushing to a remote registry.
DOCKER_ARGS+=("--push")
# Due to weak feature support parity between Docker on Linux and Docker
# Desktop building and publishing across platforms has caveats (see the
# top of this file).
if [[ $have_containerd_snapshotter ]] || [[ $have_docker_container_driver ]]; then
DOCKER_ARGS=("buildx" "build" "--platform=linux/amd64,linux/arm64")
elif [[ ! $PUBLISH_SUFFIX ]] && [[ ! $have_docker_container_driver ]]; then
DOCKER_ARGS=("buildx" "build" "--platform=linux/amd64")
>&2 echo "WARNING: heroku-24 and newer images are multi-arch images," \
"but this script is building single architecture images" \
"due to limitations of the current platform." \
"To build a multi-arch image, enable the 'containerd'" \
"snapshotter in Docker Desktop and/or use a 'docker-container'" \
"Docker BuildKit driver."
else
# Otherwise, load the image into the local image store.
DOCKER_ARGS+=("--load")
>&2 echo "ERROR: Can't build images with this configuration. Enable" \
"the 'containerd' snapshotter in Docker Desktop, enable" \
"the 'docker-container' driver in Docker, or use this script" \
"in build-only mode (don't provide PUBLISH_SUFFIX argument)."
abort 1
fi

DOCKER_ARGS+=("--push")

write_package_list() {
local image_tag="$1"
local dockerfile_dir="$2"
Expand All @@ -102,24 +94,18 @@ write_package_list() {
stack_version=$(echo "$dockerfile_dir" | sed -n 's/^heroku-\([0-9]*\).*$/\1/p')

local archs=("amd64")
# heroku-24 and newer are multiarch. If containerd is available,
# If containerd is available,
# the package list for each architecture can be generated.
if (( stack_version >= 24 )); then
if [[ $have_containerd_snapshotter ]]; then
archs+=(arm64)
else
>&2 echo "WARNING: Generating package list for single architecture." \
"Use the 'containerd' snapshotter to generate package lists" \
"for all architectures."
fi
if [[ $have_containerd_snapshotter ]]; then
archs+=(arm64)
else
>&2 echo "WARNING: Generating package list for single architecture." \
"Use the 'containerd' snapshotter to generate package lists" \
"for all architectures."
fi
local output_file=""
for arch in "${archs[@]}"; do
if (( stack_version >= 24 )); then
output_file="${dockerfile_dir}/installed-packages-${arch}.txt"
else
output_file="${dockerfile_dir}/installed-packages.txt"
fi
output_file="${dockerfile_dir}/installed-packages-${arch}.txt"
display "Generating package list: ${output_file}"
echo "# List of packages present in the final image. Regenerate using bin/build.sh" > "$output_file"
# We include the package status in the output so we can differentiate between fully installed
Expand Down
4 changes: 3 additions & 1 deletion bin/publish-to-registries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set -x
echo "${DOCKER_HUB_TOKEN}" | docker login -u "${DOCKER_HUB_USERNAME}" --password-stdin
)

bin/build.sh "${STACK_VERSION}"

push_group() {
local tagBase="$1"
local sourceTagSuffix="$2"
Expand All @@ -22,7 +24,7 @@ push_group() {
for variant in "${variants[@]}"; do
source="${tagBase}${variant}${sourceTagSuffix}"
target="${tagBase}${variant}${targetTagSuffix}"
if (( STACK_VERSION < 24 )); then
if (( STACK_VERSION < 22 )); then
# Re-tag amd64-only images
docker tag "${source}" "${target}"
docker push "${target}"
Expand Down
2 changes: 1 addition & 1 deletion heroku-20-build/installed-packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ shared-mime-info
socat
ssl-cert
stunnel4
syslinux
syslinux-common
sysvinit-utils
tar
telnet
Expand Down
2 changes: 1 addition & 1 deletion heroku-20/installed-packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ sensible-utils
shared-mime-info
socat
stunnel4
syslinux
syslinux-common
sysvinit-utils
tar
telnet
Expand Down
11 changes: 7 additions & 4 deletions heroku-20/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ export DEBIAN_FRONTEND=noninteractive

# The default sources list minus backports, restricted and multiverse.
cat >/etc/apt/sources.list <<EOF
deb http://archive.ubuntu.com/ubuntu/ focal main universe
deb http://archive.ubuntu.com/ubuntu/ focal-security main universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates main universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal main universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal-security main universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal-updates main universe
deb [arch=arm64] http://ports.ubuntu.com/ focal main universe
deb [arch=arm64] http://ports.ubuntu.com/ focal-security main universe
deb [arch=arm64] http://ports.ubuntu.com/ focal-updates main universe
EOF

apt-get update --error-on=any
Expand Down Expand Up @@ -144,7 +147,7 @@ packages=(
shared-mime-info
socat
stunnel
syslinux
syslinux-common
tar
telnet
tzdata
Expand Down
2 changes: 1 addition & 1 deletion heroku-22-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ARG BASE_IMAGE=heroku/heroku:22
ARG BASE_IMAGE=robuust/heroku:22
FROM $BASE_IMAGE
RUN --mount=target=/build /build/setup.sh
2 changes: 1 addition & 1 deletion heroku-22-build/installed-packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ sensible-utils
shared-mime-info
socat
stunnel4
syslinux
syslinux-common
systemd
sysvinit-utils
tar
Expand Down
2 changes: 1 addition & 1 deletion heroku-22/installed-packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ sensible-utils
shared-mime-info
socat
stunnel4
syslinux
syslinux-common
systemd
sysvinit-utils
tar
Expand Down
11 changes: 7 additions & 4 deletions heroku-22/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ export DEBIAN_FRONTEND=noninteractive

# The default sources list minus backports, restricted and multiverse.
cat >/etc/apt/sources.list <<EOF
deb http://archive.ubuntu.com/ubuntu/ jammy main universe
deb http://archive.ubuntu.com/ubuntu/ jammy-security main universe
deb http://archive.ubuntu.com/ubuntu/ jammy-updates main universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-security main universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main universe
deb [arch=arm64] http://ports.ubuntu.com/ jammy main universe
deb [arch=arm64] http://ports.ubuntu.com/ jammy-security main universe
deb [arch=arm64] http://ports.ubuntu.com/ jammy-updates main universe
EOF

apt-get update --error-on=any
Expand Down Expand Up @@ -146,7 +149,7 @@ packages=(
shared-mime-info
socat
stunnel
syslinux
syslinux-common
tar
telnet
tzdata
Expand Down