Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 3 additions & 7 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@ jobs:
# Go hard on the builders
max-parallel: 5
matrix:
alpine-version: ['3.20', '3.19']
debian-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
uses: actions/checkout@v4
-
name: Publish to ghcr.io
env:
ALPINE_VERSION: ${{ matrix.alpine-version }}
DEBIAN_VERSION: ${{ matrix.debian-version }}
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUBY_VERSION: ${{ matrix.ruby-version }}
TAG: ${{ github.event.inputs.tag || '' }}
Expand All @@ -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 \
DEBIAN_VERSION=$DEBIAN_VERSION \
RUBY_VERSION=$RUBY_VERSION \
./ci/build_image.sh -vvp "$version"
# yamllint enable rule:line-length
Expand Down
12 changes: 6 additions & 6 deletions ci/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)" \
Expand All @@ -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"

Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions oci/Containerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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']
Loading