Skip to content

Commit

Permalink
Add workflow to publish container images on github
Browse files Browse the repository at this point in the history
Note that variable expansion in --from and FROM was working oddly,
see: docker/cli#3356 (comment)
for context.
  • Loading branch information
bryteise committed Jun 14, 2024
1 parent a4c1b74 commit 114295d
Show file tree
Hide file tree
Showing 25 changed files with 226 additions and 88 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Dockerfiles Release
on: [create]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ github.token }}

jobs:
release:
if: (github.event_name == 'create' && github.event.ref_type == 'tag')
name: Release
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
run: ./build-and-push-images.sh ${{ github.event.ref }}
54 changes: 54 additions & 0 deletions build-and-push-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

set -eu -o pipefail

create_image() {
local name="$1"
local ver="$2"
pushd "${name}"
docker build -t ghcr.io/clearlinux/"${name}":"${ver}" . --build-arg="clear_ver=${ver}"
popd
}

push_image() {
local name="$1"
local ver="$2"
docker push ghcr.io/clearlinux/"${name}":"${ver}"
}

build_and_push_image() {
local name="$1"
local ver="$2"
create_image "${name}" "${ver}"
push_image "${name}" "${ver}"
}

main() {
local ver="$1"
build_and_push_image os-core "${ver}"
build_and_push_image clr-installer-ci "${ver}"
# httpd is used by cgit so it must be pushed first
build_and_push_image httpd "${ver}"
build_and_push_image cgit "${ver}"
build_and_push_image golang "${ver}"
build_and_push_image haproxy "${ver}"
build_and_push_image iperf "${ver}"
build_and_push_image mariadb "${ver}"
build_and_push_image memcached "${ver}"
build_and_push_image mixer-ci "${ver}"
build_and_push_image nginx "${ver}"
build_and_push_image node "${ver}"
build_and_push_image numpy-mp "${ver}"
build_and_push_image perl "${ver}"
build_and_push_image php "${ver}"
build_and_push_image php-fpm "${ver}"
build_and_push_image postgres "${ver}"
build_and_push_image python "${ver}"
build_and_push_image rabbitmq "${ver}"
build_and_push_image r-base "${ver}"
build_and_push_image redis "${ver}"
build_and_push_image ruby "${ver}"
build_and_push_image tesseract-ocr "${ver}"
}

main $1
9 changes: 6 additions & 3 deletions cgit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
ARG clear_ver
FROM ghcr.io/clearlinux/httpd:$clear_ver AS httpd
FROM clearlinux:latest AS builder

ARG clear_ver
ARG swupd_args
# Move to latest Clear Linux release to ensure
# that the swupd command line arguments are
# correct
RUN swupd update --no-boot-update $swupd_args
RUN swupd update --no-boot-update -V $clear_ver $swupd_args

# Grab os-release info from the minimal base image so
# that the new content matches the exact OS version
Expand All @@ -23,11 +26,11 @@ RUN source /os-release && \
# file exists on different layers. To minimize docker
# image size, remove the overlapped files before copy.
RUN mkdir /os_core_install
COPY --from=clearlinux/httpd:latest / /os_core_install/
COPY --from=httpd / /os_core_install/
RUN cd / && \
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true

FROM clearlinux/httpd:latest
FROM httpd

COPY --from=builder /install_root /
COPY cgitrc /etc/cgitrc
Expand Down
2 changes: 1 addition & 1 deletion docker-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function do_tag {
local image=$1
local pkg=$2
local base=$3

echo "=> Tagging the $image"
local tag=$(get_tag $pkg)

Expand Down
11 changes: 7 additions & 4 deletions golang/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
ARG clear_ver
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
FROM clearlinux:latest AS builder

ARG clear_ver
ARG swupd_args
# Move to latest Clear Linux release to ensure
# that the swupd command line arguments are
# correct
RUN swupd update --no-boot-update $swupd_args
RUN swupd update --no-boot-update -V $clear_ver $swupd_args

# Grab os-release info from the minimal base image so
# that the new content matches the exact OS version
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
COPY --from=core /usr/lib/os-release /

# Install additional content in a target directory
# using the os version from the minimal base
Expand All @@ -23,11 +26,11 @@ RUN source /os-release && \
# file exists on different layers. To minimize docker
# image size, remove the overlapped files before copy.
RUN mkdir /os_core_install
COPY --from=clearlinux/os-core:latest / /os_core_install/
COPY --from=core / /os_core_install/
RUN cd / && \
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true

FROM clearlinux/os-core:latest
FROM core

COPY --from=builder /install_root /

Expand Down
11 changes: 7 additions & 4 deletions haproxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
ARG clear_ver
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
FROM clearlinux:latest AS builder

ARG clear_ver
ARG swupd_args
# Move to latest Clear Linux release to ensure
# that the swupd command line arguments are
# correct
RUN swupd update --no-boot-update $swupd_args
RUN swupd update --no-boot-update -V $clear_ver $swupd_args

# Grab os-release info from the minimal base image so
# that the new content matches the exact OS version
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
COPY --from=core /usr/lib/os-release /

# Install additional content in a target directory
# using the os version from the minimal base
Expand All @@ -23,12 +26,12 @@ RUN source /os-release && \
# file exists on different layers. To minimize docker
# image size, remove the overlapped files before copy.
RUN mkdir /os_core_install
COPY --from=clearlinux/os-core:latest / /os_core_install/
COPY --from=core / /os_core_install/
RUN cd / && \
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true


FROM clearlinux/os-core:latest
FROM core

COPY --from=builder /install_root /

Expand Down
11 changes: 7 additions & 4 deletions httpd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
ARG clear_ver
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
FROM clearlinux:latest AS builder

ARG clear_ver
ARG swupd_args
# Move to latest Clear Linux release to ensure
# that the swupd command line arguments are
# correct
RUN swupd update --no-boot-update $swupd_args
RUN swupd update --no-boot-update -V $clear_ver $swupd_args

# Grab os-release info from the minimal base image so
# that the new content matches the exact OS version
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
COPY --from=core /usr/lib/os-release /

# Install additional content in a target directory
# using the os version from the minimal base
Expand All @@ -23,11 +26,11 @@ RUN source /os-release && \
# file exists on different layers. To minimize docker
# image size, remove the overlapped files before copy.
RUN mkdir /os_core_install
COPY --from=clearlinux/os-core:latest / /os_core_install/
COPY --from=core / /os_core_install/
RUN cd / && \
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true

FROM clearlinux/os-core:latest
FROM core

COPY --from=builder /install_root /

Expand Down
11 changes: 7 additions & 4 deletions iperf/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
ARG clear_ver
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
FROM clearlinux:latest AS builder

ARG clear_ver
ARG swupd_args
# Move to latest Clear Linux release to ensure
# that the swupd command line arguments are
# correct
RUN swupd update --no-boot-update $swupd_args
RUN swupd update --no-boot-update -V $clear_ver $swupd_args

# Grab os-release info from the minimal base image so
# that the new content matches the exact OS version
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
COPY --from=core /usr/lib/os-release /

# Install additional content in a target directory
# using the os version from the minimal base
Expand All @@ -23,12 +26,12 @@ RUN source /os-release && \
# file exists on different layers. To minimize docker
# image size, remove the overlapped files before copy.
RUN mkdir /os_core_install
COPY --from=clearlinux/os-core:latest / /os_core_install/
COPY --from=core / /os_core_install/
RUN cd / && \
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true


FROM clearlinux/os-core:latest
FROM core

COPY --from=builder /install_root /

Expand Down
11 changes: 7 additions & 4 deletions mariadb/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
ARG clear_ver
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
FROM clearlinux:latest as builder

ARG clear_ver
ARG swupd_args

# Move to latest Clear Linux release to ensure
# that the swupd command line arguments are
# correct
RUN swupd update --no-boot-update $swupd_args
RUN swupd update --no-boot-update -V $clear_ver $swupd_args

# Grab os-release info from the minimal base image so
# that the new content matches the exact OS version
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
COPY --from=core /usr/lib/os-release /

# Install additional content in a target directory
# using the os version from the minimal base
Expand All @@ -24,11 +27,11 @@ RUN source /os-release && \
# file exists on different layers. To minimize docker
# image size, remove the overlapped files before copy.
RUN mkdir /os_core_install
COPY --from=clearlinux/os-core:latest / /os_core_install/
COPY --from=core / /os_core_install/
RUN cd / && \
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true

FROM clearlinux/os-core:latest
FROM core

COPY --from=builder /install_root /

Expand Down
11 changes: 7 additions & 4 deletions memcached/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
ARG clear_ver
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
FROM clearlinux:latest AS builder

ARG clear_ver
ARG swupd_args
# Move to latest Clear Linux release to ensure
# that the swupd command line arguments are
# correct
RUN swupd update --no-boot-update $swupd_args
RUN swupd update --no-boot-update -V $clear_ver $swupd_args

# Grab os-release info from the minimal base image so
# that the new content matches the exact OS version
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
COPY --from=core /usr/lib/os-release /

# Install additional content in a target directory
# using the os version from the minimal base
Expand All @@ -23,11 +26,11 @@ RUN source /os-release && \
# file exists on different layers. To minimize docker
# image size, remove the overlapped files before copy.
RUN mkdir /os_core_install
COPY --from=clearlinux/os-core:latest / /os_core_install/
COPY --from=core / /os_core_install/
RUN cd / && \
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true

FROM clearlinux/os-core:latest
FROM core

COPY --from=builder /install_root /

Expand Down
11 changes: 7 additions & 4 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
ARG clear_ver
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
FROM clearlinux:latest AS builder

ARG clear_ver
ARG swupd_args
# Move to latest Clear Linux release to ensure
# that the swupd command line arguments are
# correct
RUN swupd update --no-boot-update $swupd_args
RUN swupd update --no-boot-update -V $clear_ver $swupd_args

# Grab os-release info from the minimal base image so
# that the new content matches the exact OS version
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
COPY --from=core /usr/lib/os-release /

# Install additional content in a target directory
# using the os version from the minimal base
Expand All @@ -23,11 +26,11 @@ RUN source /os-release && \
# file exists on different layers. To minimize docker
# image size, remove the overlapped files before copy.
RUN mkdir /os_core_install
COPY --from=clearlinux/os-core:latest / /os_core_install/
COPY --from=core / /os_core_install/
RUN cd / && \
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true

FROM clearlinux/os-core:latest
FROM core

COPY --from=builder /install_root /
COPY default.conf /etc/nginx-mainline/conf.d/default.conf
Expand Down
11 changes: 7 additions & 4 deletions node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
ARG clear_ver
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
FROM clearlinux:latest AS builder

ARG clear_ver
ARG swupd_args
# Move to latest Clear Linux release to ensure
# that the swupd command line arguments are
# correct
RUN swupd update --no-boot-update $swupd_args
RUN swupd update --no-boot-update -V $clear_ver $swupd_args

# Grab os-release info from the minimal base image so
# that the new content matches the exact OS version
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
COPY --from=core /usr/lib/os-release /

# Install additional content in a target directory
# using the os version from the minimal base
Expand All @@ -23,12 +26,12 @@ RUN source /os-release && \
# file exists on different layers. To minimize docker
# image size, remove the overlapped files before copy.
RUN mkdir /os_core_install
COPY --from=clearlinux/os-core:latest / /os_core_install/
COPY --from=core / /os_core_install/
RUN cd / && \
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true


FROM clearlinux/os-core:latest
FROM core

COPY --from=builder /install_root /

Expand Down
Loading

0 comments on commit 114295d

Please sign in to comment.