ci: add alpine variant

Signed-off-by: Samuele Longhi <agave@dracaena.it>
pull/169/head
Samuele Longhi 2025-06-18 15:00:11 +02:00 committed by a-gave
parent c0ddfae186
commit 85e590cde8
2 changed files with 118 additions and 32 deletions

View File

@ -17,6 +17,10 @@ on:
- cron: "30 2 * * 1"
workflow_dispatch:
inputs:
distros:
description: "Distribution to use as the base docker image (debian or alpine or both)"
default: "debian alpine"
required: false
ref:
description: "Tag or branch to deploy (empty for main)"
default: "main"
@ -100,6 +104,7 @@ jobs:
id: find_targets
run: |
TARGET_FILTER="${{ github.event.inputs.target }}"
DISTROS="$(${{ github.event.inputs.distros != '' }} && echo '${{github.event.inputs.distros}}' || echo 'debian alpine')"
# imagebuilders & rootfs
JSON_IB='['
@ -108,26 +113,32 @@ jobs:
JSON_ROOTFS='['
FIRST_ROOTFS=1
while read -r line;
do
TARGET=$(echo "$line" | cut -d " " -f 1)
ARCH=$(echo "$line" | cut -d " " -f 2)
for DISTRO in $DISTROS; do
[[ $FIRST_IB -ne 1 ]] && JSON_IB="$JSON_IB"','
FIRST_IB=0
while read -r line;
do
TARGET=$(echo "$line" | cut -d " " -f 1)
ARCH=$(echo "$line" | cut -d " " -f 2)
JSON_IB="$JSON_IB"'{"target":"'"$TARGET"'"}'
[[ $FIRST_IB -ne 1 ]] && JSON_IB="$JSON_IB"','
FIRST_IB=0
case "$TARGET" in
x86/*|arm*|malta/be|mvebu/cortexa9)
[[ $FIRST_ROOTFS -ne 1 ]] && JSON_ROOTFS="$JSON_ROOTFS"','
FIRST_ROOTFS=0
JSON_IB="$JSON_IB"'{"distro": "'"$DISTRO"'", "target":"'"$TARGET"'"}'
JSON_ROOTFS="$JSON_ROOTFS"'{"target":"'"$TARGET"'","arch":"'"$ARCH"'"}'
;;
esac
if [ $DISTRO == $(echo "${DISTROS[0]%% *}") ]; then
case "$TARGET" in
x86/*|arm*|malta/be|mvebu/cortexa9)
[[ $FIRST_ROOTFS -ne 1 ]] && JSON_ROOTFS="$JSON_ROOTFS"','
FIRST_ROOTFS=0
done <<< $(perl ./scripts/dump-target-info.pl targets 2>/dev/null | ([[ -n "$TARGET_FILTER" ]] && grep -w "$TARGET_FILTER" || cat))
JSON_ROOTFS="$JSON_ROOTFS"'{"target":"'"$TARGET"'","arch":"'"$ARCH"'"}'
;;
esac
fi
done <<< $(perl ./scripts/dump-target-info.pl targets 2>/dev/null | ([[ -n "$TARGET_FILTER" ]] && grep -w "$TARGET_FILTER" || cat))
done
JSON_IB='{"include":'"$JSON_IB"']}'
echo -e "\n---- imagebuilders ----\n"
@ -146,23 +157,27 @@ jobs:
JSON='['
FIRST=1
while read -r line;
do
TARGET=$(echo "$line" | cut -d " " -f 1)
ARCH=$(echo "$line" | cut -d " " -f 2)
TARGET_TAG="${TARGET//\//-}"
for DISTRO in $DISTROS; do
TAGS="$TARGET_TAG"
if [ -z "${ARCH_SEEN[$ARCH]+x}" ]; then
TAGS="$TARGET_TAG\n$ARCH"
ARCH_SEEN[$ARCH]=1
fi
while read -r line;
do
TARGET=$(echo "$line" | cut -d " " -f 1)
ARCH=$(echo "$line" | cut -d " " -f 2)
TARGET_TAG="${TARGET//\//-}"
[[ $FIRST -ne 1 ]] && JSON="$JSON"','
FIRST=0
TAGS="$TARGET_TAG"
if [ -z "${ARCH_SEEN[$ARCH]+x}" ]; then
TAGS="$TARGET_TAG\n$ARCH"
ARCH_SEEN[$ARCH]=1
fi
JSON="$JSON"'{"target":"'"$TARGET"'","tags":"'"$TAGS"'"}'
done <<< $(perl ./scripts/dump-target-info.pl targets 2>/dev/null | ([[ -n "$TARGET_FILTER" ]] && grep -w "$TARGET_FILTER" || cat))
[[ $FIRST -ne 1 ]] && JSON="$JSON"','
FIRST=0
JSON="$JSON"'{"distro":"'"$DISTRO"'", "target":"'"$TARGET"'","tags":"'"$TAGS"'"}'
done <<< $(perl ./scripts/dump-target-info.pl targets 2>/dev/null | ([[ -n "$TARGET_FILTER" ]] && grep -w "$TARGET_FILTER" || cat))
done
JSON='{"include":'"$JSON"']}'
echo -e "\n---- sdks ----\n"
@ -221,6 +236,7 @@ jobs:
flavor: |
latest=false
prefix=${{ github.event.inputs.prefix }}
suffix=${{ matrix.distro == 'alpine' && '-alpine' || '' }}
tags: |
${{ matrix.target }}-${{ needs.generate_matrix.outputs.ref }}
${{ matrix.target }}-${{ needs.generate_matrix.outputs.version }}
@ -236,6 +252,7 @@ jobs:
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ matrix.distro == 'debian' && 'Dockerfile' || 'Dockerfile.alpine' }}
build-args: |
DOWNLOAD_FILE=imagebuilder-.*x86_64.tar.[xz|zst]
VERSION_PATH=${{ needs.generate_matrix.outputs.version_path }}
@ -260,6 +277,7 @@ jobs:
no-cache: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ matrix.distro == 'debian' && 'Dockerfile' || 'Dockerfile.alpine' }}
build-args: |
DOWNLOAD_FILE=imagebuilder-.*x86_64.tar.[xz|zst]
VERSION_PATH=${{ needs.generate_matrix.outputs.version_path }}
@ -313,7 +331,7 @@ jobs:
flavor: |
latest=false
prefix=${{ github.event.inputs.prefix }}
suffix=-${{ needs.generate_matrix.outputs.ref }}
suffix=-${{ needs.generate_matrix.outputs.ref }}${{ matrix.distro == 'alpine' && '-alpine' || '' }}
tags: ${{ matrix.tags }}
- name: Docker meta (version)
@ -327,7 +345,7 @@ jobs:
flavor: |
latest=false
prefix=${{ github.event.inputs.prefix }}
suffix=-${{ needs.generate_matrix.outputs.version }}
suffix=-${{ needs.generate_matrix.outputs.version }}${{ matrix.distro == 'alpine' && '-alpine' || '' }}
tags: ${{ matrix.tags }}
- name: Docker meta (master)
@ -342,7 +360,7 @@ jobs:
flavor: |
latest=false
prefix=${{ github.event.inputs.prefix }}
suffix=-master
suffix=-master${{ matrix.distro == 'alpine' && '-alpine' || '' }}
tags: ${{ matrix.tags }}
- name: Docker meta (target and arch)
@ -357,6 +375,7 @@ jobs:
flavor: |
latest=false
prefix=${{ github.event.inputs.prefix }}
suffix=${{ matrix.distro == 'alpine' && '-alpine' || '' }}
tags: ${{ matrix.tags }}
- name: Docker meta (latest)
@ -368,6 +387,8 @@ jobs:
ghcr.io/${{ github.repository_owner }}/sdk
${{ env.DOCKER_USER != '' && format('docker.io/{0}/sdk', env.DOCKER_USER) || '' }}
${{ env.QUAY_USER != '' && format('quay.io/{0}/sdk', env.QUAY_USER) || '' }}
flavor: |
suffix=${{ matrix.distro == 'alpine' && '-alpine' || '' }}
tags: latest
- name: Build

65
Dockerfile.alpine 100644
View File

@ -0,0 +1,65 @@
FROM alpine:latest
USER root
RUN apk add -u --no-cache \
bash \
build-base \
bzip2 \
ccache \
coreutils \
diffutils \
findutils \
gawk \
git \
gettext \
gpg \
gpg-agent \
grep \
gzip \
libxslt \
ncurses-dev \
openssl-dev \
perl \
python3 \
py3-setuptools \
rsync \
unzip \
util-linux \
tar \
wget \
xz \
zlib-dev \
zstd
ARG USER=buildbot
ARG WORKDIR=/builder/
ARG CMD="/bin/bash"
ARG DOWNLOAD_FILE="imagebuilder-.*x86_64.tar.[xz|zst]"
ARG TARGET=x86/64
ARG FILE_HOST=downloads.openwrt.org
ARG VERSION_PATH
ENV DOWNLOAD_FILE=$DOWNLOAD_FILE
ENV TARGET=$TARGET
ENV FILE_HOST=$FILE_HOST
ENV VERSION_PATH=$VERSION_PATH
RUN adduser -h $WORKDIR -DH $USER
USER $USER
WORKDIR $WORKDIR
ADD --chown=buildbot:buildbot keys/*.asc /builder/keys/
COPY --chmod=0755 setup.sh /builder/setup.sh
ARG RUN_SETUP=0
ENV RUN_SETUP=$RUN_SETUP
RUN if [ "$RUN_SETUP" -eq 1 ]; then /builder/setup.sh; fi
ENTRYPOINT [ ]
# required to have CMD as ENV to be executed
ENV CMD_ENV=${CMD}
CMD ${CMD_ENV}