From 95940a96d4c3c51459ba1d8d0b3c193d5e283dfe Mon Sep 17 00:00:00 2001 From: "Tj (bougyman) Vanderpoel" Date: Wed, 18 Dec 2024 07:42:36 -0600 Subject: [PATCH 1/2] feat(build)!: Change to use ubuntu base images --- .github/workflows/container.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/container.yaml b/.github/workflows/container.yaml index f1ccada..bf1b9fe 100644 --- a/.github/workflows/container.yaml +++ b/.github/workflows/container.yaml @@ -21,12 +21,8 @@ jobs: # Go hard on the builders max-parallel: 5 matrix: - alpine-version: ['3.20', '3.19'] + ubuntu-version: ['bookworm', 'bullseye'] ruby-version: ['3.3.6', '3.3.5', '3.3.4'] - # Only 3.3.6 is published (to docker.io) for 3.21, so we include only that here. - include: - - alpine-version: '3.21' - ruby-version: '3.3.6' steps: - name: Checkout repository @@ -34,7 +30,7 @@ jobs: - name: Publish to ghcr.io env: - ALPINE_VERSION: ${{ matrix.alpine-version }} + UBUNTU_VERSION: ${{ matrix.ubuntu-version }} REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} RUBY_VERSION: ${{ matrix.ruby-version }} TAG: ${{ github.event.inputs.tag || '' }} @@ -58,7 +54,7 @@ jobs: [ "$TRACE" = 'true' ] && printf 'Calling ./ci/build_image.sh -vvp "%s"\n' "$version" >&2 IMAGE_NAME=$(basename "$GITHUB_REPOSITORY") \ GITHUB_TOKEN=$REGISTRY_TOKEN \ - ALPINE_VERSION=$ALPINE_VERSION \ + UBUNTU_VERSION=$UBUNTU_VERSION \ RUBY_VERSION=$RUBY_VERSION \ ./ci/build_image.sh -vvp "$version" # yamllint enable rule:line-length From 28d1dbddc26f7d52e1737c967bbcd948523db7d3 Mon Sep 17 00:00:00 2001 From: "Tj (bougyman) Vanderpoel" Date: Wed, 18 Dec 2024 08:27:40 -0600 Subject: [PATCH 2/2] feat(build)!: Change to use Debian base images --- .github/workflows/container.yaml | 6 +++--- ci/build_image.sh | 12 ++++++------ oci/Containerfile | 18 +++++++++--------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/container.yaml b/.github/workflows/container.yaml index bf1b9fe..be478e1 100644 --- a/.github/workflows/container.yaml +++ b/.github/workflows/container.yaml @@ -21,7 +21,7 @@ jobs: # Go hard on the builders max-parallel: 5 matrix: - ubuntu-version: ['bookworm', 'bullseye'] + debian-version: ['bookworm', 'bullseye'] ruby-version: ['3.3.6', '3.3.5', '3.3.4'] steps: - @@ -30,7 +30,7 @@ jobs: - name: Publish to ghcr.io env: - UBUNTU_VERSION: ${{ matrix.ubuntu-version }} + DEBIAN_VERSION: ${{ matrix.debian-version }} REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} RUBY_VERSION: ${{ matrix.ruby-version }} TAG: ${{ github.event.inputs.tag || '' }} @@ -54,7 +54,7 @@ jobs: [ "$TRACE" = 'true' ] && printf 'Calling ./ci/build_image.sh -vvp "%s"\n' "$version" >&2 IMAGE_NAME=$(basename "$GITHUB_REPOSITORY") \ GITHUB_TOKEN=$REGISTRY_TOKEN \ - UBUNTU_VERSION=$UBUNTU_VERSION \ + DEBIAN_VERSION=$DEBIAN_VERSION \ RUBY_VERSION=$RUBY_VERSION \ ./ci/build_image.sh -vvp "$version" # yamllint enable rule:line-length diff --git a/ci/build_image.sh b/ci/build_image.sh index 3b5ceeb..60569d3 100755 --- a/ci/build_image.sh +++ b/ci/build_image.sh @@ -25,15 +25,15 @@ cd "$repo_top" || { } base_dir=$(basename "$(pwd)") -: "${ALPINE_VERSION:=3.20}" +: "${DEBIAN_VERSION:=bookworm}" : "${BUILD_CONTEXT:=$(pwd)}" : "${IMAGE_NAME:=$base_dir}" : "${LICENSE:=MIT}" : "${REGISTRY:=ghcr.io}" -: "${RUBY_VERSION:=3.3.4}" +: "${RUBY_VERSION:=3.3.6}" : "${REGISTRY_TOKEN:=$GITHUB_TOKEN}" -base_image_tag="$RUBY_VERSION-alpine$ALPINE_VERSION" +base_image_tag="$RUBY_VERSION-$DEBIAN_VERSION" base_exists=$(skopeo list-tags docker://docker.io/ruby |jq -r "any(.Tags[] == \"$base_image_tag\"; .)") if [ "$base_exists" = "false" ] then @@ -209,7 +209,7 @@ fi service=$(basename "$owner_and_repo" .git) owner=$(dirname "$owner_and_repo") -full_tag=$IMAGE_NAME:$tag-ruby$RUBY_VERSION-alpine$ALPINE_VERSION +full_tag=$IMAGE_NAME:$tag-ruby$RUBY_VERSION-$DEBIAN_VERSION # Pass any extra arguments to the build command ("$@" contains the rest of the arguments) $runtime build --tag "$full_tag" "$@" \ --label org.opencontainers.image.created="$(date --utc --iso-8601=seconds)" \ @@ -221,7 +221,7 @@ $runtime build --tag "$full_tag" "$@" \ --label org.opencontainers.image.source="Generated by ruby-automation's build_image.sh ($USER@$HOSTNAME)" \ --label org.opencontainers.image.version="$full_tag" \ --label shortref="$shortref" \ - --build-arg ALPINE_VERSION="$ALPINE_VERSION" \ + --build-arg DEBIAN_VERSION="$DEBIAN_VERSION" \ --build-arg RUBY_VERSION="$RUBY_VERSION" \ -f "$containerfile" "$BUILD_CONTEXT" || die 8 "Failed to build image" @@ -237,7 +237,7 @@ fi mapfile -t tags < <(echo "$tag" | awk -F'.' 'NF==3{print; print $1"."$2; print $1; next} NF==2{print; print $1; next} {print}') for t in "${tags[@]}" do - new_tag=$IMAGE_NAME:$t-ruby$RUBY_VERSION-alpine$ALPINE_VERSION + new_tag=$IMAGE_NAME:$t-ruby$RUBY_VERSION-$DEBIAN_VERSION registry_image_name="$REGISTRY/$owner/$new_tag" if [ "$runtime" = "podman" ] then diff --git a/oci/Containerfile b/oci/Containerfile index df61b9f..2aff41d 100644 --- a/oci/Containerfile +++ b/oci/Containerfile @@ -1,6 +1,6 @@ -ARG ALPINE_VERSION=3.20 -ARG RUBY_VERSION=3.3.4 -FROM docker.io/ruby:$RUBY_VERSION-alpine$ALPINE_VERSION AS build-env +ARG DEBIAN_VERSION=bookworm +ARG RUBY_VERSION=3.3.6 +FROM docker.io/ruby:$RUBY_VERSION-$DEBIAN_VERSION AS build-env # Setting env up ARG APP_ROOT=/app @@ -9,7 +9,7 @@ ENV LANG C.UTF-8 ENV BUNDLE_SILENCE_ROOT_WARNING=1 #Install dependencies needed for compilation -RUN apk --no-cache add curl ruby-dev build-base git +RUN apt-get update && apt-get install -qy build-essential curl git WORKDIR $APP_ROOT @@ -33,17 +33,17 @@ RUN bundle config set build.nokogiri --use-system-libraries && \ RUN rm -rf node_modules tmp/cache app/assets vendor/assets spec ############### Build step done ############### -ARG ALPINE_VERSION=3.20 -ARG RUBY_VERSION=3.3.4 -FROM docker.io/ruby:$RUBY_VERSION-alpine$ALPINE_VERSION +ARG DEBIAN_VERSION=bookworm +ARG RUBY_VERSION=3.3.6 +FROM docker.io/ruby:$RUBY_VERSION-$DEBIAN_VERSION ARG APP_ROOT=/app WORKDIR $APP_ROOT # install packages -RUN apk --update --no-cache add coreutils curl bash runit +RUN apt-get update && apt-get install -qy curl bash runit COPY --from=build-env /usr/local/bundle/ /usr/local/bundle/ COPY --from=build-env /bin/snooze /bin/snooze -CMD ['/bin/sh'] +CMD ['/bin/bash']