|
| 1 | +FROM ubuntu:24.04 |
| 2 | + |
| 3 | +ARG TARGETPLATFORM |
| 4 | +ARG RUNNER_VERSION |
| 5 | +ARG RUNNER_CONTAINER_HOOKS_VERSION |
| 6 | +# Docker and Docker Compose arguments |
| 7 | +ARG CHANNEL=stable |
| 8 | +ARG DOCKER_VERSION=24.0.7 |
| 9 | +ARG DOCKER_COMPOSE_VERSION=v2.23.0 |
| 10 | +ARG DUMB_INIT_VERSION=1.2.5 |
| 11 | +ARG RUNNER_USER_UID=1001 |
| 12 | +ARG DOCKER_GROUP_GID=121 |
| 13 | + |
| 14 | +ENV DEBIAN_FRONTEND=noninteractive |
| 15 | +RUN apt-get update -y \ |
| 16 | + && apt-get install -y software-properties-common \ |
| 17 | + && add-apt-repository -y ppa:git-core/ppa \ |
| 18 | + && apt-get update -y \ |
| 19 | + && apt-get install -y --no-install-recommends \ |
| 20 | + curl \ |
| 21 | + ca-certificates \ |
| 22 | + git \ |
| 23 | + jq \ |
| 24 | + sudo \ |
| 25 | + unzip \ |
| 26 | + zip \ |
| 27 | + && rm -rf /var/lib/apt/lists/* |
| 28 | + |
| 29 | +# Download latest git-lfs version |
| 30 | +RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \ |
| 31 | + apt-get install -y --no-install-recommends git-lfs |
| 32 | + |
| 33 | +RUN adduser --disabled-password --gecos "" --uid $RUNNER_USER_UID runner \ |
| 34 | + && groupadd docker --gid $DOCKER_GROUP_GID \ |
| 35 | + && usermod -aG sudo runner \ |
| 36 | + && usermod -aG docker runner \ |
| 37 | + && echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ |
| 38 | + && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers |
| 39 | + |
| 40 | +ENV HOME=/home/runner |
| 41 | + |
| 42 | +RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ |
| 43 | + && if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \ |
| 44 | + && if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \ |
| 45 | + && curl -fLo /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${ARCH} \ |
| 46 | + && chmod +x /usr/bin/dumb-init |
| 47 | + |
| 48 | +ENV RUNNER_ASSETS_DIR=/runnertmp |
| 49 | +RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ |
| 50 | + && if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x64 ; fi \ |
| 51 | + && mkdir -p "$RUNNER_ASSETS_DIR" \ |
| 52 | + && cd "$RUNNER_ASSETS_DIR" \ |
| 53 | + && curl -fLo runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ |
| 54 | + && tar xzf ./runner.tar.gz \ |
| 55 | + && rm runner.tar.gz \ |
| 56 | + && ./bin/installdependencies.sh \ |
| 57 | + && mv ./externals ./externalstmp \ |
| 58 | + # libyaml-dev is required for ruby/setup-ruby action. |
| 59 | + # It is installed after installdependencies.sh and before removing /var/lib/apt/lists |
| 60 | + # to avoid rerunning apt-update on its own. |
| 61 | + && apt-get install -y libyaml-dev \ |
| 62 | + && rm -rf /var/lib/apt/lists/* |
| 63 | + |
| 64 | +ENV RUNNER_TOOL_CACHE=/opt/hostedtoolcache |
| 65 | +RUN mkdir /opt/hostedtoolcache \ |
| 66 | + && chgrp docker /opt/hostedtoolcache \ |
| 67 | + && chmod g+rwx /opt/hostedtoolcache |
| 68 | + |
| 69 | +RUN cd "$RUNNER_ASSETS_DIR" \ |
| 70 | + && 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 \ |
| 71 | + && unzip ./runner-container-hooks.zip -d ./k8s \ |
| 72 | + && rm -f runner-container-hooks.zip |
| 73 | + |
| 74 | +RUN set -vx; \ |
| 75 | + export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ |
| 76 | + && if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \ |
| 77 | + && if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \ |
| 78 | + && curl -fLo docker.tgz https://download.docker.com/linux/static/${CHANNEL}/${ARCH}/docker-${DOCKER_VERSION}.tgz \ |
| 79 | + && tar zxvf docker.tgz \ |
| 80 | + && install -o root -g root -m 755 docker/docker /usr/bin/docker \ |
| 81 | + && rm -rf docker docker.tgz |
| 82 | + |
| 83 | +RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ |
| 84 | + && if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \ |
| 85 | + && if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \ |
| 86 | + && mkdir -p /usr/libexec/docker/cli-plugins \ |
| 87 | + && curl -fLo /usr/libexec/docker/cli-plugins/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \ |
| 88 | + && chmod +x /usr/libexec/docker/cli-plugins/docker-compose \ |
| 89 | + && ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose \ |
| 90 | + && which docker-compose \ |
| 91 | + && docker compose version |
| 92 | + |
| 93 | +# We place the scripts in `/usr/bin` so that users who extend this image can |
| 94 | +# override them with scripts of the same name placed in `/usr/local/bin`. |
| 95 | +COPY entrypoint.sh startup.sh logger.sh graceful-stop.sh update-status /usr/bin/ |
| 96 | + |
| 97 | +# Copy the docker shim which propagates the docker MTU to underlying networks |
| 98 | +# to replace the docker binary in the PATH. |
| 99 | +COPY docker-shim.sh /usr/local/bin/docker |
| 100 | + |
| 101 | +# Configure hooks folder structure. |
| 102 | +COPY hooks /etc/arc/hooks/ |
| 103 | + |
| 104 | +# Add the Python "User Script Directory" to the PATH |
| 105 | +ENV PATH="${PATH}:${HOME}/.local/bin/" |
| 106 | +ENV ImageOS=ubuntu24 |
| 107 | + |
| 108 | +RUN echo "PATH=${PATH}" > /etc/environment \ |
| 109 | + && echo "ImageOS=${ImageOS}" >> /etc/environment |
| 110 | + |
| 111 | +USER runner |
| 112 | + |
| 113 | +ENTRYPOINT ["/bin/bash", "-c"] |
| 114 | +CMD ["entrypoint.sh"] |
0 commit comments