ci: multiple ubuntu version (#2036)

* ci: prepare ci for multiple runners

* chore: rename dockerfiles

* chore: sup multiple os in makefile

* chore: changes to support multiple versions

* chore: remove test for TARGETPLATFORM

* chore: fixes and add individual targets

* ci: add latest tag back in

* ci: remove latest suffix tag

Co-authored-by: toast-gear <toast-gear@users.noreply.github.com>
This commit is contained in:
Callum Tait 2022-11-30 15:00:16 +00:00 committed by GitHub
parent 18077a1e83
commit 63d2cbfdaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 99 additions and 34 deletions

View File

@ -44,12 +44,15 @@ jobs:
- name: actions-runner - name: actions-runner
os-name: ubuntu os-name: ubuntu
os-version: 20.04 os-version: 20.04
latest: "true"
- name: actions-runner-dind - name: actions-runner-dind
os-name: ubuntu os-name: ubuntu
os-version: 20.04 os-version: 20.04
latest: "true"
- name: actions-runner-dind-rootless - name: actions-runner-dind-rootless
os-name: ubuntu os-name: ubuntu
os-version: 20.04 os-version: 20.04
latest: "true"
steps: steps:
- name: Checkout - name: Checkout
@ -67,7 +70,7 @@ jobs:
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3
with: with:
context: ./runner context: ./runner
file: ./runner/${{ matrix.name }}.dockerfile file: ./runner/${{ matrix.name }}.${{ matrix.os-name }}-${{ matrix.os-version }}.dockerfile
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
build-args: | build-args: |
@ -77,9 +80,30 @@ jobs:
tags: | tags: |
${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }} ${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}
${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}-${{ env.sha_short }} ${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}-${{ env.sha_short }}
${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:latest ${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:${{ matrix.os-name }}-${{ matrix.os-version }}
ghcr.io/${{ github.repository }}/${{ matrix.name }}:latest
ghcr.io/${{ github.repository }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }} ghcr.io/${{ github.repository }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}
ghcr.io/${{ github.repository }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}-${{ env.sha_short }} ghcr.io/${{ github.repository }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}-${{ env.sha_short }}
cache-from: type=gha,scope=build-${{ matrix.name }} ghcr.io/${{ github.repository }}/${{ matrix.name }}:${{ matrix.os-name }}-${{ matrix.os-version }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.name }} cache-from: type=gha,scope=build-${{ matrix.name }}-${{ matrix.os-name }}-${{ matrix.os-version }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.name }}-${{ matrix.os-name }}-${{ matrix.os-version }}
# NOTE : Only to be used on the 20.04 image until we remove the latest tag entirely
# at which point this step needs to be deleted
# https://github.com/actions-runner-controller/actions-runner-controller/issues/2056
- name: Build and Push Latest Tags
id: ${{ matrix.latest == "true" }}
uses: docker/build-push-action@v3
with:
context: ./runner
file: ./runner/${{ matrix.name }}.${{ matrix.os-name }}-${{ matrix.os-version }}.dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
build-args: |
RUNNER_VERSION=${{ env.RUNNER_VERSION }}
DOCKER_VERSION=${{ env.DOCKER_VERSION }}
RUNNER_CONTAINER_HOOKS_VERSION=${{ env.RUNNER_CONTAINER_HOOKS_VERSION }}
tags: |
${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:latest
ghcr.io/${{ github.repository }}/${{ matrix.name }}:latest
cache-from: type=gha,scope=build-${{ matrix.name }}-${{ matrix.os-name }}-${{ matrix.os-version }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.name }}-${{ matrix.os-name }}-${{ matrix.os-version }}

View File

@ -1,9 +1,9 @@
DOCKER_USER ?= summerwind DOCKER_USER ?= summerwind
DOCKER ?= docker DOCKER ?= docker
NAME ?= ${DOCKER_USER}/actions-runner DEFAULT_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner
DIND_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind DIND_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind
DIND_ROOTLESS_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind-rootless DIND_ROOTLESS_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind-rootless
TAG ?= latest OS_IMAGE ?= ubuntu-20.04
TARGETPLATFORM ?= $(shell arch) TARGETPLATFORM ?= $(shell arch)
RUNNER_VERSION ?= 2.299.1 RUNNER_VERSION ?= 2.299.1
@ -39,33 +39,33 @@ else
$(error Supported target platforms: linux/amd64 and linux/arm64) $(error Supported target platforms: linux/amd64 and linux/arm64)
endif endif
docker-build-ubuntu: check-target-platform docker-build-set: check-target-platform
${DOCKER} build \ ${DOCKER} build \
--build-arg TARGETPLATFORM=${TARGETPLATFORM} \ --build-arg TARGETPLATFORM=${TARGETPLATFORM} \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \ --build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \ --build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \ --build-arg DOCKER_VERSION=${DOCKER_VERSION} \
-f actions-runner.dockerfile \ -f actions-runner.${OS_IMAGE}.dockerfile \
-t ${NAME}:${TAG} . -t ${DEFAULT_RUNNER_NAME}:${OS_IMAGE} .
${DOCKER} build \ ${DOCKER} build \
--build-arg TARGETPLATFORM=${TARGETPLATFORM} \ --build-arg TARGETPLATFORM=${TARGETPLATFORM} \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \ --build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \ --build-arg DOCKER_VERSION=${DOCKER_VERSION} \
-f actions-runner-dind.dockerfile \ -f actions-runner-dind.${OS_IMAGE}.dockerfile \
-t ${DIND_RUNNER_NAME}:${TAG} . -t ${DIND_RUNNER_NAME}:${OS_IMAGE} .
${DOCKER} build \ ${DOCKER} build \
--build-arg TARGETPLATFORM=${TARGETPLATFORM} \ --build-arg TARGETPLATFORM=${TARGETPLATFORM} \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \ --build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \ --build-arg DOCKER_VERSION=${DOCKER_VERSION} \
-f actions-runner-dind-rootless.dockerfile \ -f actions-runner-dind-rootless.${OS_IMAGE}.dockerfile \
-t ${DIND_ROOTLESS_RUNNER_NAME}:${TAG} . -t "${DIND_ROOTLESS_RUNNER_NAME}:${OS_IMAGE}" .
docker-push-ubuntu: docker-push-set:
${DOCKER} push ${NAME}:${TAG} ${DOCKER} push "${DEFAULT_RUNNER_NAME}:${OS_IMAGE}"
${DOCKER} push ${DIND_RUNNER_NAME}:${TAG} ${DOCKER} push "${DIND_RUNNER_NAME}:${OS_IMAGE}"
${DOCKER} push ${DIND_ROOTLESS_RUNNER_NAME}:${TAG} ${DOCKER} push "${DIND_ROOTLESS_RUNNER_NAME}:${OS_IMAGE}"
docker-buildx-ubuntu: docker-buildx-set:
export DOCKER_CLI_EXPERIMENTAL=enabled ;\ export DOCKER_CLI_EXPERIMENTAL=enabled ;\
export DOCKER_BUILDKIT=1 export DOCKER_BUILDKIT=1
@if ! docker buildx ls | grep -q container-builder; then\ @if ! docker buildx ls | grep -q container-builder; then\
@ -75,19 +75,62 @@ docker-buildx-ubuntu:
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \ --build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \ --build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \ --build-arg DOCKER_VERSION=${DOCKER_VERSION} \
-f actions-runner.dockerfile \ -f actions-runner.${OS_IMAGE}.dockerfile \
-t "${NAME}:${TAG}" \ -t "${DEFAULT_RUNNER_NAME}:${OS_IMAGE}" \
. ${PUSH_ARG} . ${PUSH_ARG}
${DOCKER} buildx build --platform ${PLATFORMS} \ ${DOCKER} buildx build --platform ${PLATFORMS} \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \ --build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \ --build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \ --build-arg DOCKER_VERSION=${DOCKER_VERSION} \
-f actions-runner-dind.dockerfile \ -f actions-runner-dind.${OS_IMAGE}.dockerfile \
-t "${DIND_RUNNER_NAME}:${TAG}" \ -t "${DIND_RUNNER_NAME}:${OS_IMAGE}" \
. ${PUSH_ARG} . ${PUSH_ARG}
${DOCKER} buildx build --platform ${PLATFORMS} \ ${DOCKER} buildx build --platform ${PLATFORMS} \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \ --build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \ --build-arg DOCKER_VERSION=${DOCKER_VERSION} \
-f actions-runner-dind-rootless.dockerfile \ -f actions-runner-dind-rootless.${OS_IMAGE}.dockerfile \
-t "${DIND_ROOTLESS_RUNNER_NAME}:${TAG}" \ -t "${DIND_ROOTLESS_RUNNER_NAME}:${OS_IMAGE}" \
. ${PUSH_ARG}
docker-buildx-default:
export DOCKER_CLI_EXPERIMENTAL=enabled ;\
export DOCKER_BUILDKIT=1
@if ! docker buildx ls | grep -q container-builder; then\
docker buildx create --platform ${PLATFORMS} --name container-builder --use;\
fi
${DOCKER} buildx build --platform ${PLATFORMS} \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \
-f actions-runner.${OS_IMAGE}.dockerfile \
-t "${DEFAULT_RUNNER_NAME}:${OS_IMAGE}" \
. ${PUSH_ARG}
docker-buildx-dind:
export DOCKER_CLI_EXPERIMENTAL=enabled ;\
export DOCKER_BUILDKIT=1
@if ! docker buildx ls | grep -q container-builder; then\
docker buildx create --platform ${PLATFORMS} --name container-builder --use;\
fi
${DOCKER} buildx build --platform ${PLATFORMS} \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \
-f actions-runner-dind.${OS_IMAGE}.dockerfile \
-t "${DIND_RUNNER_NAME}:${OS_IMAGE}" \
. ${PUSH_ARG}
docker-buildx-dind-rootless:
export DOCKER_CLI_EXPERIMENTAL=enabled ;\
export DOCKER_BUILDKIT=1
@if ! docker buildx ls | grep -q container-builder; then\
docker buildx create --platform ${PLATFORMS} --name container-builder --use;\
fi
${DOCKER} buildx build --platform ${PLATFORMS} \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \
--build-arg RUNNER_CONTAINER_HOOKS_VERSION=${RUNNER_CONTAINER_HOOKS_VERSION} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \
-f actions-runner-dind-rootless.${OS_IMAGE}.dockerfile \
-t "${DIND_ROOTLESS_RUNNER_NAME}:${OS_IMAGE}" \
. ${PUSH_ARG} . ${PUSH_ARG}

View File

@ -11,10 +11,8 @@ ARG DUMB_INIT_VERSION=1.2.5
# Other arguments # Other arguments
ARG DEBUG=false ARG DEBUG=false
RUN test -n "$TARGETPLATFORM" || (echo "TARGETPLATFORM must be set" && false)
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt update -y \ RUN apt-get update -y \
&& apt-get install -y software-properties-common \ && apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:git-core/ppa \ && add-apt-repository -y ppa:git-core/ppa \
&& apt-get update -y \ && apt-get update -y \

View File

@ -9,10 +9,8 @@ ARG DOCKER_VERSION=20.10.18
ARG DOCKER_COMPOSE_VERSION=v2.6.0 ARG DOCKER_COMPOSE_VERSION=v2.6.0
ARG DUMB_INIT_VERSION=1.2.5 ARG DUMB_INIT_VERSION=1.2.5
RUN test -n "$TARGETPLATFORM" || (echo "TARGETPLATFORM must be set" && false)
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt update -y \ RUN apt-get update -y \
&& apt-get install -y software-properties-common \ && apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:git-core/ppa \ && add-apt-repository -y ppa:git-core/ppa \
&& apt-get update -y \ && apt-get update -y \

View File

@ -9,10 +9,8 @@ ARG DOCKER_VERSION=20.10.18
ARG DOCKER_COMPOSE_VERSION=v2.6.0 ARG DOCKER_COMPOSE_VERSION=v2.6.0
ARG DUMB_INIT_VERSION=1.2.5 ARG DUMB_INIT_VERSION=1.2.5
RUN test -n "$TARGETPLATFORM" || (echo "TARGETPLATFORM must be set" && false)
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt update -y \ RUN apt-get update -y \
&& apt-get install -y software-properties-common \ && apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:git-core/ppa \ && add-apt-repository -y ppa:git-core/ppa \
&& apt-get update -y \ && apt-get update -y \

View File

@ -172,5 +172,9 @@ unset RUNNER_NAME RUNNER_REPO RUNNER_TOKEN STARTUP_DELAY_IN_SECONDS DISABLE_WAIT
if [ -z "${UNITTEST:-}" ]; then if [ -z "${UNITTEST:-}" ]; then
mapfile -t env </etc/environment mapfile -t env </etc/environment
fi fi
log.notice "WARNING LATEST TAG HAS BEEN DEPRECATED. SEE GITHUB ISSUE FOR DETAILS:"
log.notice "https://github.com/actions-runner-controller/actions-runner-controller/issues/2056"
update-status "Idle" update-status "Idle"
exec env -- "${env[@]}" ./run.sh exec env -- "${env[@]}" ./run.sh