diff --git a/runner/Makefile b/runner/Makefile index c66a4a2b..3dffc9a0 100644 --- a/runner/Makefile +++ b/runner/Makefile @@ -3,7 +3,7 @@ DOCKER ?= docker DEFAULT_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner DIND_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind DIND_ROOTLESS_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind-rootless -OS_IMAGE ?= ubuntu-20.04 +OS_IMAGE ?= ubuntu-22.04 TARGETPLATFORM ?= $(shell arch) RUNNER_VERSION ?= 2.299.1 @@ -50,6 +50,7 @@ docker-build-set: check-target-platform ${DOCKER} build \ --build-arg TARGETPLATFORM=${TARGETPLATFORM} \ --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} . @@ -60,6 +61,30 @@ docker-build-set: check-target-platform -f actions-runner-dind-rootless.${OS_IMAGE}.dockerfile \ -t "${DIND_ROOTLESS_RUNNER_NAME}:${OS_IMAGE}" . +docker-build-default: check-target-platform + ${DOCKER} build \ + --build-arg TARGETPLATFORM=${TARGETPLATFORM} \ + --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} . + +docker-build-dind: check-target-platform + ${DOCKER} build \ + --build-arg TARGETPLATFORM=${TARGETPLATFORM} \ + --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} . + +docker-push-default: + ${DOCKER} push "${DEFAULT_RUNNER_NAME}:${OS_IMAGE}" + +docker-push-dind: + ${DOCKER} push "${DIND_RUNNER_NAME}:${OS_IMAGE}" + docker-push-set: ${DOCKER} push "${DEFAULT_RUNNER_NAME}:${OS_IMAGE}" ${DOCKER} push "${DIND_RUNNER_NAME}:${OS_IMAGE}" diff --git a/runner/actions-runner-dind.ubuntu-22.04.dockerfile b/runner/actions-runner-dind.ubuntu-22.04.dockerfile new file mode 100644 index 00000000..36a06a5a --- /dev/null +++ b/runner/actions-runner-dind.ubuntu-22.04.dockerfile @@ -0,0 +1,115 @@ +FROM ubuntu:22.04 + +ARG TARGETPLATFORM +ARG RUNNER_VERSION=2.299.1 +ARG RUNNER_CONTAINER_HOOKS_VERSION=0.1.3 +# Docker and Docker Compose arguments +ARG CHANNEL=stable +ARG DOCKER_VERSION=20.10.21 +ARG DOCKER_COMPOSE_VERSION=v2.12.2 +ARG DUMB_INIT_VERSION=1.2.5 +ARG RUNNER_USER_UID=1001 +ARG DOCKER_GROUP_GID=121 + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update -y \ + && apt-get install -y software-properties-common \ + && add-apt-repository -y ppa:git-core/ppa \ + && apt-get update -y \ + && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + git \ + git-lfs \ + iptables \ + jq \ + supervisor \ + software-properties-common \ + sudo \ + unzip \ + zip \ + && rm -rf /var/lib/apt/lists/* + +# Runner user +RUN adduser --disabled-password --gecos "" --uid $RUNNER_USER_UID runner \ + && groupadd docker --gid $DOCKER_GROUP_GID \ + && usermod -aG sudo runner \ + && usermod -aG docker runner \ + && echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ + && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers + +ENV HOME=/home/runner + +RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ + && if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \ + && if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \ + && curl -fLo /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${ARCH} \ + && chmod +x /usr/bin/dumb-init + +ENV RUNNER_ASSETS_DIR=/runnertmp +RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ + && if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x64 ; fi \ + && mkdir -p "$RUNNER_ASSETS_DIR" \ + && cd "$RUNNER_ASSETS_DIR" \ + && curl -fLo runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ + && tar xzf ./runner.tar.gz \ + && rm -f runner.tar.gz \ + && ./bin/installdependencies.sh \ + # libyaml-dev is required for ruby/setup-ruby action. + # It is installed after installdependencies.sh and before removing /var/lib/apt/lists + # to avoid rerunning apt-update on its own. + && apt-get install -y libyaml-dev \ + && rm -rf /var/lib/apt/lists/* + +ENV RUNNER_TOOL_CACHE=/opt/hostedtoolcache +RUN mkdir /opt/hostedtoolcache \ + && chgrp docker /opt/hostedtoolcache \ + && chmod g+rwx /opt/hostedtoolcache + +RUN cd "$RUNNER_ASSETS_DIR" \ + && curl -fLo runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-k8s-${RUNNER_CONTAINER_HOOKS_VERSION}.zip \ + && unzip ./runner-container-hooks.zip -d ./k8s \ + && rm -f runner-container-hooks.zip + +RUN set -vx; \ + export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ + && if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \ + && if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \ + && curl -fLo docker.tgz https://download.docker.com/linux/static/${CHANNEL}/${ARCH}/docker-${DOCKER_VERSION}.tgz \ + && tar zxvf docker.tgz \ + && install -o root -g root -m 755 docker/* /usr/bin/ \ + && rm -rf docker docker.tgz + +RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ + && if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \ + && if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \ + && curl -fLo /usr/bin/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \ + && chmod +x /usr/bin/docker-compose + +# We place the scripts in `/usr/bin` so that users who extend this image can +# override them with scripts of the same name placed in `/usr/local/bin`. +COPY entrypoint-dind.sh startup.sh logger.sh wait.sh graceful-stop.sh update-status /usr/bin/ +COPY supervisor/ /etc/supervisor/conf.d/ +RUN chmod +x /usr/bin/entrypoint-dind.sh /usr/bin/startup.sh + +# Copy the docker shim which propagates the docker MTU to underlying networks +# to replace the docker binary in the PATH. +COPY docker-shim.sh /usr/local/bin/docker + +# Configure hooks folder structure. +COPY hooks /etc/arc/hooks/ + +VOLUME /var/lib/docker + +# Add the Python "User Script Directory" to the PATH +ENV PATH="${PATH}:${HOME}/.local/bin" +ENV ImageOS=ubuntu22 + +RUN echo "PATH=${PATH}" > /etc/environment \ + && echo "ImageOS=${ImageOS}" >> /etc/environment + +# No group definition, as that makes it harder to run docker. +USER runner + +ENTRYPOINT ["/bin/bash", "-c"] +CMD ["entrypoint-dind.sh"]