Skip to content

Commit 114295d

Browse files
committed
Add workflow to publish container images on github
Note that variable expansion in --from and FROM was working oddly, see: docker/cli#3356 (comment) for context.
1 parent a4c1b74 commit 114295d

File tree

25 files changed

+226
-88
lines changed

25 files changed

+226
-88
lines changed

.github/workflows/release.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Dockerfiles Release
2+
on: [create]
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
5+
cancel-in-progress: true
6+
env:
7+
GITHUB_TOKEN: ${{ github.token }}
8+
9+
jobs:
10+
release:
11+
if: (github.event_name == 'create' && github.event.ref_type == 'tag')
12+
name: Release
13+
strategy:
14+
fail-fast: false
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Code Checkout
18+
uses: actions/checkout@v4
19+
- name: Login to GitHub Container Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Build and Push
26+
run: ./build-and-push-images.sh ${{ github.event.ref }}

build-and-push-images.sh

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
set -eu -o pipefail
4+
5+
create_image() {
6+
local name="$1"
7+
local ver="$2"
8+
pushd "${name}"
9+
docker build -t ghcr.io/clearlinux/"${name}":"${ver}" . --build-arg="clear_ver=${ver}"
10+
popd
11+
}
12+
13+
push_image() {
14+
local name="$1"
15+
local ver="$2"
16+
docker push ghcr.io/clearlinux/"${name}":"${ver}"
17+
}
18+
19+
build_and_push_image() {
20+
local name="$1"
21+
local ver="$2"
22+
create_image "${name}" "${ver}"
23+
push_image "${name}" "${ver}"
24+
}
25+
26+
main() {
27+
local ver="$1"
28+
build_and_push_image os-core "${ver}"
29+
build_and_push_image clr-installer-ci "${ver}"
30+
# httpd is used by cgit so it must be pushed first
31+
build_and_push_image httpd "${ver}"
32+
build_and_push_image cgit "${ver}"
33+
build_and_push_image golang "${ver}"
34+
build_and_push_image haproxy "${ver}"
35+
build_and_push_image iperf "${ver}"
36+
build_and_push_image mariadb "${ver}"
37+
build_and_push_image memcached "${ver}"
38+
build_and_push_image mixer-ci "${ver}"
39+
build_and_push_image nginx "${ver}"
40+
build_and_push_image node "${ver}"
41+
build_and_push_image numpy-mp "${ver}"
42+
build_and_push_image perl "${ver}"
43+
build_and_push_image php "${ver}"
44+
build_and_push_image php-fpm "${ver}"
45+
build_and_push_image postgres "${ver}"
46+
build_and_push_image python "${ver}"
47+
build_and_push_image rabbitmq "${ver}"
48+
build_and_push_image r-base "${ver}"
49+
build_and_push_image redis "${ver}"
50+
build_and_push_image ruby "${ver}"
51+
build_and_push_image tesseract-ocr "${ver}"
52+
}
53+
54+
main $1

cgit/Dockerfile

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
ARG clear_ver
2+
FROM ghcr.io/clearlinux/httpd:$clear_ver AS httpd
13
FROM clearlinux:latest AS builder
24

5+
ARG clear_ver
36
ARG swupd_args
47
# Move to latest Clear Linux release to ensure
58
# that the swupd command line arguments are
69
# correct
7-
RUN swupd update --no-boot-update $swupd_args
10+
RUN swupd update --no-boot-update -V $clear_ver $swupd_args
811

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

30-
FROM clearlinux/httpd:latest
33+
FROM httpd
3134

3235
COPY --from=builder /install_root /
3336
COPY cgitrc /etc/cgitrc

docker-hooks.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function do_tag {
6868
local image=$1
6969
local pkg=$2
7070
local base=$3
71-
71+
7272
echo "=> Tagging the $image"
7373
local tag=$(get_tag $pkg)
7474

golang/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
ARG clear_ver
2+
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
13
FROM clearlinux:latest AS builder
24

5+
ARG clear_ver
36
ARG swupd_args
47
# Move to latest Clear Linux release to ensure
58
# that the swupd command line arguments are
69
# correct
7-
RUN swupd update --no-boot-update $swupd_args
10+
RUN swupd update --no-boot-update -V $clear_ver $swupd_args
811

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

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

30-
FROM clearlinux/os-core:latest
33+
FROM core
3134

3235
COPY --from=builder /install_root /
3336

haproxy/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
ARG clear_ver
2+
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
13
FROM clearlinux:latest AS builder
24

5+
ARG clear_ver
36
ARG swupd_args
47
# Move to latest Clear Linux release to ensure
58
# that the swupd command line arguments are
69
# correct
7-
RUN swupd update --no-boot-update $swupd_args
10+
RUN swupd update --no-boot-update -V $clear_ver $swupd_args
811

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

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

3033

31-
FROM clearlinux/os-core:latest
34+
FROM core
3235

3336
COPY --from=builder /install_root /
3437

httpd/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
ARG clear_ver
2+
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
13
FROM clearlinux:latest AS builder
24

5+
ARG clear_ver
36
ARG swupd_args
47
# Move to latest Clear Linux release to ensure
58
# that the swupd command line arguments are
69
# correct
7-
RUN swupd update --no-boot-update $swupd_args
10+
RUN swupd update --no-boot-update -V $clear_ver $swupd_args
811

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

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

30-
FROM clearlinux/os-core:latest
33+
FROM core
3134

3235
COPY --from=builder /install_root /
3336

iperf/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
ARG clear_ver
2+
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
13
FROM clearlinux:latest AS builder
24

5+
ARG clear_ver
36
ARG swupd_args
47
# Move to latest Clear Linux release to ensure
58
# that the swupd command line arguments are
69
# correct
7-
RUN swupd update --no-boot-update $swupd_args
10+
RUN swupd update --no-boot-update -V $clear_ver $swupd_args
811

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

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

3033

31-
FROM clearlinux/os-core:latest
34+
FROM core
3235

3336
COPY --from=builder /install_root /
3437

mariadb/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
ARG clear_ver
2+
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
13
FROM clearlinux:latest as builder
24

5+
ARG clear_ver
36
ARG swupd_args
47

58
# Move to latest Clear Linux release to ensure
69
# that the swupd command line arguments are
710
# correct
8-
RUN swupd update --no-boot-update $swupd_args
11+
RUN swupd update --no-boot-update -V $clear_ver $swupd_args
912

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

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

31-
FROM clearlinux/os-core:latest
34+
FROM core
3235

3336
COPY --from=builder /install_root /
3437

memcached/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
ARG clear_ver
2+
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
13
FROM clearlinux:latest AS builder
24

5+
ARG clear_ver
36
ARG swupd_args
47
# Move to latest Clear Linux release to ensure
58
# that the swupd command line arguments are
69
# correct
7-
RUN swupd update --no-boot-update $swupd_args
10+
RUN swupd update --no-boot-update -V $clear_ver $swupd_args
811

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

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

30-
FROM clearlinux/os-core:latest
33+
FROM core
3134

3235
COPY --from=builder /install_root /
3336

nginx/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
ARG clear_ver
2+
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
13
FROM clearlinux:latest AS builder
24

5+
ARG clear_ver
36
ARG swupd_args
47
# Move to latest Clear Linux release to ensure
58
# that the swupd command line arguments are
69
# correct
7-
RUN swupd update --no-boot-update $swupd_args
10+
RUN swupd update --no-boot-update -V $clear_ver $swupd_args
811

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

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

30-
FROM clearlinux/os-core:latest
33+
FROM core
3134

3235
COPY --from=builder /install_root /
3336
COPY default.conf /etc/nginx-mainline/conf.d/default.conf

node/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
ARG clear_ver
2+
FROM ghcr.io/clearlinux/os-core:$clear_ver AS core
13
FROM clearlinux:latest AS builder
24

5+
ARG clear_ver
36
ARG swupd_args
47
# Move to latest Clear Linux release to ensure
58
# that the swupd command line arguments are
69
# correct
7-
RUN swupd update --no-boot-update $swupd_args
10+
RUN swupd update --no-boot-update -V $clear_ver $swupd_args
811

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

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

3033

31-
FROM clearlinux/os-core:latest
34+
FROM core
3235

3336
COPY --from=builder /install_root /
3437

0 commit comments

Comments
 (0)