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
49 changes: 49 additions & 0 deletions .docker/ol10.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## REGISTRY CONFIGURATION ######################################################

ARG REGISTRY="ghcr.io"

## FINAL IMAGE #################################################################

FROM ${REGISTRY}/essentialkaos/oraclelinux:10

ARG HOSTNAME="rbbuild-ol10.docker.local"

LABEL org.opencontainers.image.title="RBBuild" \
org.opencontainers.image.description="Image to build Ruby (OracleLinux 10)" \
org.opencontainers.image.vendor="ESSENTIAL KAOS" \
org.opencontainers.image.authors="Anton Novojilov" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.url="https://kaos.sh/d/rbbuild" \
org.opencontainers.image.source="https://github.com/essentialkaos/rbbuild"

COPY SOURCES/rbbuild /usr/bin/rbbuild
COPY SOURCES/rbdef /usr/bin/rbdef
COPY SOURCES/mass-builder /usr/bin/mass-builder

COPY SOURCES/defs /usr/local/share/rbbuild
COPY SOURCES/libexec /usr/libexec/rbbuild

# hadolint ignore=DL3031,DL3041
RUN <<EOF
# Configure image environment
echo "$HOSTNAME" > /etc/hostname
dnf -y -q update oraclelinux-release
dnf -y -q install https://pkgs.kaos.st/kaos-repo-latest.el10.noarch.rpm
dnf -y -q install https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm
sed -i 's/gpgcheck=1/gpgcheck=1\nmodule_hotfixes=1/g' /etc/yum.repos.d/epel.repo
dnf config-manager --set-enabled ol10_codeready_builder
dnf -y -q install bash curl zstd patch gawk bc git
dnf clean all
rm -rf /var/cache/dnf /var/log/dnf.*
chmod +x /usr/bin/rbbuild \
/usr/bin/rbdef \
/usr/bin/mass-builder
mass-builder prepare
EOF

VOLUME /rbbuild
WORKDIR /rbbuild

ENTRYPOINT ["/usr/bin/bash"]

################################################################################
50 changes: 50 additions & 0 deletions .docker/ol8.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## REGISTRY CONFIGURATION ######################################################

ARG REGISTRY="ghcr.io"

## FINAL IMAGE #################################################################

FROM ${REGISTRY}/essentialkaos/oraclelinux:8

ARG HOSTNAME="rbbuild-ol8.docker.local"

LABEL org.opencontainers.image.title="RBBuild" \
org.opencontainers.image.description="Image to build Ruby (OracleLinux 8)" \
org.opencontainers.image.vendor="ESSENTIAL KAOS" \
org.opencontainers.image.authors="Anton Novojilov" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.url="https://kaos.sh/d/rbbuild" \
org.opencontainers.image.source="https://github.com/essentialkaos/rbbuild"

COPY SOURCES/rbbuild /usr/bin/rbbuild
COPY SOURCES/rbdef /usr/bin/rbdef
COPY SOURCES/mass-builder /usr/bin/mass-builder

COPY SOURCES/defs /usr/local/share/rbbuild
COPY SOURCES/libexec /usr/libexec/rbbuild

# hadolint ignore=DL3031,DL3041
RUN <<EOF
# Configure image environment
echo "$HOSTNAME" > /etc/hostname
dnf -y -q update oraclelinux-release
dnf -y -q install https://pkgs.kaos.st/kaos-repo-latest.el8.noarch.rpm
dnf -y -q install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sed -i 's/gpgcheck=1/gpgcheck=1\nmodule_hotfixes=1/g' /etc/yum.repos.d/epel.repo
dnf config-manager --set-enabled ol8_codeready_builder
dnf -y -q install bash curl zstd patch gawk bc git
dnf -y -q remove libevent
dnf clean all
rm -rf /var/cache/dnf /var/log/dnf.*
chmod +x /usr/bin/rbbuild \
/usr/bin/rbdef \
/usr/bin/mass-builder
mass-builder prepare
EOF

VOLUME /rbbuild
WORKDIR /rbbuild

ENTRYPOINT ["/usr/bin/bash"]

################################################################################
49 changes: 49 additions & 0 deletions .docker/ol9.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## REGISTRY CONFIGURATION ######################################################

ARG REGISTRY="ghcr.io"

## FINAL IMAGE #################################################################

FROM ${REGISTRY}/essentialkaos/oraclelinux:9

ARG HOSTNAME="rbbuild-ol9.docker.local"

LABEL org.opencontainers.image.title="RBBuild" \
org.opencontainers.image.description="Image to build Ruby (OracleLinux 9)" \
org.opencontainers.image.vendor="ESSENTIAL KAOS" \
org.opencontainers.image.authors="Anton Novojilov" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.url="https://kaos.sh/d/rbbuild" \
org.opencontainers.image.source="https://github.com/essentialkaos/rbbuild"

COPY SOURCES/rbbuild /usr/bin/rbbuild
COPY SOURCES/rbdef /usr/bin/rbdef
COPY SOURCES/mass-builder /usr/bin/mass-builder

COPY SOURCES/defs /usr/local/share/rbbuild
COPY SOURCES/libexec /usr/libexec/rbbuild

# hadolint ignore=DL3031,DL3041
RUN <<EOF
# Configure image environment
echo "$HOSTNAME" > /etc/hostname
dnf -y -q update oraclelinux-release
dnf -y -q install https://pkgs.kaos.st/kaos-repo-latest.el9.noarch.rpm
dnf -y -q install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
sed -i 's/gpgcheck=1/gpgcheck=1\nmodule_hotfixes=1/g' /etc/yum.repos.d/epel.repo
dnf config-manager --set-enabled ol9_codeready_builder
dnf -y -q install bash curl zstd patch gawk bc git
dnf clean all
rm -rf /var/cache/dnf /var/log/dnf.*
chmod +x /usr/bin/rbbuild \
/usr/bin/rbdef \
/usr/bin/mass-builder
mass-builder prepare
EOF

VOLUME /rbbuild
WORKDIR /rbbuild

ENTRYPOINT ["/usr/bin/bash"]

################################################################################
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Run defs tests
run: .github/scripts/def_check.sh SOURCES/defs
Expand All @@ -26,7 +26,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Check scripts with Shellcheck
uses: essentialkaos/shellcheck-action@v1
Expand All @@ -41,7 +41,7 @@ jobs:

steps:
- name: Code checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -61,7 +61,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Check spelling
uses: crate-ci/typos@master
179 changes: 179 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: "Docker Push"

on:
release:
types: [published]
workflow_dispatch:
inputs:
force_rebuild:
description: 'Force container rebuild'
required: true
type: choice
options: [yes, no]
schedule:
- cron: '30 12 * * *'

permissions:
packages: write
contents: read

env:
IMAGE_NAME: ${{ github.repository }}
LATEST_IMAGE: ol9

jobs:
Docker:
name: Docker Build & Publish
runs-on: ubuntu-latest

strategy:
matrix:
image: [ 'ol8', 'ol9', 'ol10' ]

steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Yandex Container Registry
uses: docker/login-action@v3
with:
registry: cr.yandex
username: oauth
password: ${{ secrets.YC_TOKEN }}

- name: Checkout the latest tag
run: |
rev=$(git rev-list --tags --max-count=1)
tag=$(git describe --tags "$rev")

if [[ -z "$tag" ]] ; then
echo "::error::Can't find the latest tag"
exit 1
fi

echo -e "\033[34mRev:\033[0m $rev"
echo -e "\033[34mTag:\033[0m $tag"

git checkout "$tag"

- name: Prepare metadata for build
id: metadata
run: |
rev=$(git rev-list --tags --max-count=1)
version=$(git describe --tags "$rev" | tr -d 'v')

if [[ -z "$version" ]] ; then
echo "::error::Can't find version info"
exit 1
fi

docker_file=".docker/${{matrix.image}}.docker"
base_image=$(grep 'FROM ' $docker_file | grep -v 'builder' | sed 's#${REGISTRY}/##' | tail -1 | cut -f2 -d' ')

if [[ -z "$base_image" ]] ; then
echo "::error::Can't extract base image info"
exit 1
fi

dh_tags="${{env.IMAGE_NAME}}:${{matrix.image}}-$version,${{env.IMAGE_NAME}}:${{matrix.image}}"
gh_tags="ghcr.io/${{env.IMAGE_NAME}}:${{matrix.image}}-$version,ghcr.io/${{env.IMAGE_NAME}}:${{matrix.image}}"
yc_tags="cr.yandex/${{secrets.YC_REGISTRY_ID}}/${{github.event.repository.name}}:${{matrix.image}}-$version,cr.yandex/${{secrets.YC_REGISTRY_ID}}/${{github.event.repository.name}}:${{matrix.image}}"

if [[ -n "${{env.LATEST_IMAGE}}" && "${{env.LATEST_IMAGE}}" == "${{matrix.image}}" ]] ; then
dh_tags="$dh_tags,${{env.IMAGE_NAME}}:latest"
gh_tags="$gh_tags,ghcr.io/${{env.IMAGE_NAME}}:latest"
yc_tags="$yc_tags,cr.yandex/${{secrets.YC_REGISTRY_ID}}/${{github.event.repository.name}}:latest"
fi

echo "version=$version" >> $GITHUB_OUTPUT
echo "dockerfile=$docker_file" >> $GITHUB_OUTPUT
echo "baseimage=$base_image" >> $GITHUB_OUTPUT
echo "dh_tags=$dh_tags" >> $GITHUB_OUTPUT
echo "gh_tags=$gh_tags" >> $GITHUB_OUTPUT
echo "yc_tags=$yc_tags" >> $GITHUB_OUTPUT

echo -e "\033[34mVersion:\033[0m $version"
echo -e "\033[34mDockerfile:\033[0m $docker_file"
echo -e "\033[34mBase image:\033[0m $base_image"
echo -e "\033[34mDH Tags:\033[0m $dh_tags"
echo -e "\033[34mGHCR Tags:\033[0m $gh_tags"

- name: Check if build/rebuild is required
id: build_check
run: |
if [[ "${{github.event_name}}" == "release" ]] ; then
echo "build=true" >> $GITHUB_OUTPUT
exit 0
fi

if [[ "${{ github.event.inputs.force_rebuild }}" == "true" ]] ; then
echo "::warning::Rebuild ${{matrix.version}} (reason: forced rebuild)"
echo "build=true" >> $GITHUB_OUTPUT
exit 0
fi

echo -e "::group::\033[34mDownloading built image…\033[0m"

if ! docker pull ghcr.io/${{env.IMAGE_NAME}}:${{matrix.image}} ; then
echo "::error::Can't download image ghcr.io/${{env.IMAGE_NAME}}:${{matrix.image}}"
exit 1
fi

echo "::endgroup::"
echo -e "::group::\033[34mDownloading base image…\033[0m"

if ! docker pull ${{steps.metadata.outputs.baseimage}} ; then
echo "::error::Can't download image ${{steps.metadata.outputs.baseimage}}"
exit 1
fi

echo "::endgroup::"

base_layer=$(docker inspect "${{steps.metadata.outputs.baseimage}}" | jq -r '.[0].RootFS.Layers[-1]')

if [[ -z "$base_layer" ]] ; then
echo "::error::Can't extract layers info from base image"
exit 1
fi

if ! docker inspect "ghcr.io/${{env.IMAGE_NAME}}:${{matrix.image}}" | jq -r '.[0].RootFS.Layers' | grep -q "$base_layer" ; then
echo "::warning::Rebuild image (reason: base image rebuilt)"
echo "build=true" >> $GITHUB_OUTPUT
exit 0
fi

- name: Build and push image
if: ${{ steps.build_check.outputs.build == 'true' }}
uses: docker/build-push-action@v6
with:
push: true
context: .
file: ${{steps.metadata.outputs.dockerfile}}
build-args: |
REGISTRY=ghcr.io
tags: |
${{ steps.metadata.outputs.dh_tags }}
${{ steps.metadata.outputs.gh_tags }}
${{ steps.metadata.outputs.yc_tags }}

- name: Show info about built image
if: ${{ steps.build_check.outputs.build == 'true' }}
uses: essentialkaos/docker-info-action@v1
with:
image: ghcr.io/${{env.IMAGE_NAME}}:${{matrix.image}}
show-labels: true
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@

########################################################################################

build-images: build-ol8 build-ol9 build-ol10 ## Build Docker images

build-ol8:
@echo -e "\e[1;36;49m\nBuilding Oracle Linux 8 image…\n\e[0m"
docker build -f .docker/ol8.docker -t ghcr.io/essentialkaos/rbbuild:ol8 .

build-ol9:
@echo -e "\e[1;36;49m\nBuilding Oracle Linux 9 image…\n\e[0m"
docker build -f .docker/ol9.docker -t ghcr.io/essentialkaos/rbbuild:ol9 .

build-ol10:
@echo -e "\e[1;36;49m\nBuilding Oracle Linux 10 image…\n\e[0m"
docker build -f .docker/ol10.docker -t ghcr.io/essentialkaos/rbbuild:ol10 .

get-shellcheck: ## Download and install the latest version of shellcheck (requires sudo)
ifneq ($(shell id -u), 0)
@echo -e "\e[31m▲ This target requires sudo\e[0m"
Expand Down Expand Up @@ -58,7 +72,7 @@ endif
help: ## Show this info
@echo -e '\nSupported targets:\n'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-18s\033[0m %s\n", $$1, $$2}'
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-15s\033[0m %s\n", $$1, $$2}'
@echo -e ''

########################################################################################
Loading
Loading