Skip to content
Open
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
75 changes: 48 additions & 27 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
pull_request:
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"
Expand Down Expand Up @@ -76,6 +80,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='['
Expand All @@ -84,26 +89,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

while read -r line;
do
TARGET=$(echo "$line" | cut -d " " -f 1)
ARCH=$(echo "$line" | cut -d " " -f 2)

[[ $FIRST_IB -ne 1 ]] && JSON_IB="$JSON_IB"','
FIRST_IB=0
[[ $FIRST_IB -ne 1 ]] && JSON_IB="$JSON_IB"','
FIRST_IB=0

JSON_IB="$JSON_IB"'{"target":"'"$TARGET"'"}'
JSON_IB="$JSON_IB"'{"distro": "'"$DISTRO"'", "target":"'"$TARGET"'"}'

case "$TARGET" in
x86/*|arm*|malta/be|mvebu/cortexa9)
[[ $FIRST_ROOTFS -ne 1 ]] && JSON_ROOTFS="$JSON_ROOTFS"','
FIRST_ROOTFS=0
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

JSON_ROOTFS="$JSON_ROOTFS"'{"target":"'"$TARGET"'","arch":"'"$ARCH"'"}'
;;
esac
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 <<< $(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"
Expand All @@ -121,17 +132,21 @@ jobs:
JSON='['
FIRST=1

while read -r line;
do
ARCH=$(echo "$line" | cut -d " " -f 1)
[ -z "$TARGET_FILTER" ] && TARGET=$(echo "$line" | cut -d " " -f 2) || TARGET="$TARGET_FILTER"
TARGETS=$(echo "$line" | cut -d " " -f 2- | sed -e 's/ /\\n/g')
for DISTRO in $DISTROS; do

while read -r line;
do
ARCH=$(echo "$line" | cut -d " " -f 1)
[ -z "$TARGET_FILTER" ] && TARGET=$(echo "$line" | cut -d " " -f 2) || TARGET="$TARGET_FILTER"
TARGETS=$(echo "$line" | cut -d " " -f 2- | sed -e 's/ /\\n/g')

[[ $FIRST -ne 1 ]] && JSON="$JSON"','
FIRST=0
[[ $FIRST -ne 1 ]] && JSON="$JSON"','
FIRST=0

JSON="$JSON"'{"arch":"'"$ARCH"'","target":"'"$TARGET"'","tags":"'"$ARCH"'\n'"$TARGETS"'"}'
done <<< $(perl ./scripts/dump-target-info.pl architectures 2>/dev/null | ([[ -n "$TARGET_FILTER" ]] && grep -w "$TARGET_FILTER" || cat))
JSON="$JSON"'{"distro":"'"$DISTRO"'", "arch":"'"$ARCH"'","target":"'"$TARGET"'","tags":"'"$ARCH"'\n'"$TARGETS"'"}'
done <<< $(perl ./scripts/dump-target-info.pl architectures 2>/dev/null | ([[ -n "$TARGET_FILTER" ]] && grep -w "$TARGET_FILTER" || cat))

done

JSON='{"include":'"$JSON"']}'
echo -e "\n---- sdks ----\n"
Expand Down Expand Up @@ -190,6 +205,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 }}
Expand All @@ -205,6 +221,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 }}
Expand All @@ -229,6 +246,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 }}
Expand Down Expand Up @@ -282,7 +300,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)
Expand All @@ -296,7 +314,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)
Expand All @@ -311,7 +329,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)
Expand All @@ -326,6 +344,7 @@ jobs:
flavor: |
latest=false
prefix=${{ github.event.inputs.prefix }}
suffix=${{ matrix.distro == 'alpine' && '-alpine' || '' }}
tags: ${{ matrix.tags }}

- name: Docker meta (latest)
Expand All @@ -337,6 +356,8 @@ jobs:
ghcr.io/openwrt/sdk
docker.io/openwrt/sdk
quay.io/openwrt/sdk
flavor: |
suffix=${{ matrix.distro == 'alpine' && '-alpine' || '' }}
tags: latest

- name: Build
Expand Down
65 changes: 65 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -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}