2021-04-17 09:02:03 +01:00
|
|
|
FROM ubuntu:20.04
|
2020-01-28 21:56:54 +09:00
|
|
|
|
2020-10-05 11:26:46 +11:00
|
|
|
ARG TARGETPLATFORM
|
2021-08-19 14:47:17 +01:00
|
|
|
ARG RUNNER_VERSION=2.280.3
|
2021-08-11 01:55:09 +01:00
|
|
|
ARG DOCKER_CHANNEL=stable
|
2021-08-18 15:50:17 +01:00
|
|
|
ARG DOCKER_VERSION=20.10.8
|
2021-08-11 01:55:09 +01:00
|
|
|
ARG DUMB_INIT_VERSION=1.2.5
|
2020-02-02 21:29:33 +09:00
|
|
|
|
2021-01-24 10:58:35 +09:00
|
|
|
RUN test -n "$TARGETPLATFORM" || (echo "TARGETPLATFORM must be set" && false)
|
|
|
|
|
|
2020-05-01 09:29:52 +00:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
RUN apt update -y \
|
2021-04-17 09:02:03 +01:00
|
|
|
&& apt install -y software-properties-common \
|
|
|
|
|
&& add-apt-repository -y ppa:git-core/ppa \
|
|
|
|
|
&& apt update -y \
|
|
|
|
|
&& apt install -y --no-install-recommends \
|
|
|
|
|
build-essential \
|
|
|
|
|
curl \
|
|
|
|
|
ca-certificates \
|
|
|
|
|
dnsutils \
|
|
|
|
|
ftp \
|
|
|
|
|
git \
|
|
|
|
|
iproute2 \
|
|
|
|
|
iputils-ping \
|
|
|
|
|
jq \
|
|
|
|
|
libunwind8 \
|
|
|
|
|
locales \
|
|
|
|
|
netcat \
|
|
|
|
|
openssh-client \
|
|
|
|
|
parallel \
|
2021-05-24 22:53:07 +01:00
|
|
|
python3-pip \
|
2021-04-17 09:02:03 +01:00
|
|
|
rsync \
|
|
|
|
|
shellcheck \
|
|
|
|
|
sudo \
|
|
|
|
|
telnet \
|
|
|
|
|
time \
|
|
|
|
|
tzdata \
|
|
|
|
|
unzip \
|
|
|
|
|
upx \
|
|
|
|
|
wget \
|
|
|
|
|
zip \
|
|
|
|
|
zstd \
|
2021-05-24 22:30:04 +01:00
|
|
|
&& ln -sf /usr/bin/python3 /usr/bin/python \
|
|
|
|
|
&& ln -sf /usr/bin/pip3 /usr/bin/pip \
|
2021-04-17 09:02:03 +01:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2020-05-01 09:29:52 +00:00
|
|
|
|
2021-06-22 17:10:09 +09:00
|
|
|
# arch command on OS X reports "i386" for Intel CPUs regardless of bitness
|
2020-10-05 11:26:46 +11:00
|
|
|
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
|
2021-06-22 17:10:09 +09:00
|
|
|
&& if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \
|
2021-08-12 00:43:25 +09:00
|
|
|
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \
|
|
|
|
|
&& curl -f -L -o /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${ARCH} \
|
2021-05-24 22:48:51 +01:00
|
|
|
&& chmod +x /usr/local/bin/dumb-init
|
2020-10-05 11:26:46 +11:00
|
|
|
|
2021-06-22 17:10:09 +09:00
|
|
|
# Docker download supports arm64 as aarch64 & amd64 / i386 as x86_64
|
2021-01-24 10:58:35 +09:00
|
|
|
RUN set -vx; \
|
2021-04-17 09:02:03 +01:00
|
|
|
export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
|
|
|
|
|
&& if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \
|
2021-06-22 17:10:09 +09:00
|
|
|
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \
|
2021-08-18 15:50:17 +01:00
|
|
|
&& curl -f -L -o docker.tgz https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${ARCH}/docker-${DOCKER_VERSION}.tgz \
|
2021-04-17 09:02:03 +01:00
|
|
|
&& tar zxvf docker.tgz \
|
|
|
|
|
&& install -o root -g root -m 755 docker/docker /usr/local/bin/docker \
|
|
|
|
|
&& rm -rf docker docker.tgz \
|
|
|
|
|
&& adduser --disabled-password --gecos "" --uid 1000 runner \
|
|
|
|
|
&& groupadd docker \
|
|
|
|
|
&& usermod -aG sudo runner \
|
|
|
|
|
&& usermod -aG docker runner \
|
|
|
|
|
&& echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers
|
2020-01-28 21:56:54 +09:00
|
|
|
|
2021-01-24 10:58:35 +09:00
|
|
|
ENV RUNNER_ASSETS_DIR=/runnertmp
|
2021-06-01 01:21:14 +01:00
|
|
|
ENV HOME=/home/runner
|
2021-01-24 10:58:35 +09:00
|
|
|
|
feat: Workflow job based ephemeral runner scaling (#721)
This add support for two upcoming enhancements on the GitHub side of self-hosted runners, ephemeral runners, and `workflow_jow` events. You can't use these yet.
**These features are not yet generally available to all GitHub users**. Please take this pull request as a preparation to make it available to actions-runner-controller users as soon as possible after GitHub released the necessary features on their end.
**Ephemeral runners**:
The former, ephemeral runners, is basically the reliable alternative to `--once`, which we've been using when you enabled `ephemeral: true` (default in actions-runner-controller).
`--once` has been suffering from a race issue #466. `--ephemeral` fixes that.
To enable ephemeral runners with `actions/runner`, you give `--ephemeral` to `config.sh`. This updated version of `actions-runner-controller` does it for you, by using `--ephemeral` instead of `--once` when you set `RUNNER_FEATURE_FLAG_EPHEMERAL=true`.
Please read the section `Ephemeral Runners` in the updated version of our README for more information.
Note that ephemeral runners is not released on GitHub yet. And `RUNNER_FEATURE_FLAG_EPHEMERAL=true` won't work at all until the feature gets released on GitHub. Stay tuned for an announcement from GitHub!
**`workflow_job` events**:
`workflow_job` is the additional webhook event that corresponds to each GitHub Actions workflow job run. It provides `actions-runner-controller` a solid foundation to improve our webhook-based autoscale.
Formerly, we've been exploiting webhook events like `check_run` for autoscaling. However, as none of our supported events has included `labels`, you had to configure an HRA to only match relevant `check_run` events. It wasn't trivial.
In contrast, a `workflow_job` event payload contains `labels` of runners requested. `actions-runner-controller` is able to automatically decide which HRA to scale by filtering the corresponding RunnerDeployment by `labels` included in the webhook payload. So all you need to use webhook-based autoscale will be to enable `workflow_job` on GitHub and expose actions-runner-controller's webhook server to the internet.
Note that the current implementation of `workflow_job` support works in two ways, increment, and decrement. An increment happens when the webhook server receives` workflow_job` of `queued` status. A decrement happens when it receives `workflow_job` of `completed` status. The latter is used to make scaling-down faster so that you waste money less than before. You still don't suffer from flapping, as a scale-down is still subject to `scaleDownDelaySecondsAfterScaleOut `.
Please read the section `Example 3: Scale on each `workflow_job` event` in the updated version of our README for more information on its usage.
2021-08-11 09:52:04 +09:00
|
|
|
# Uncomment the below COPY to use your own custom build of actions-runner.
|
|
|
|
|
#
|
|
|
|
|
# To build a custom runner:
|
|
|
|
|
# - Clone the actions/runner repo `git clone git@github.com:actions/runner.git $repo`
|
|
|
|
|
# - Run `cd $repo/src`
|
|
|
|
|
# - Run `./dev.sh layout Release linux-x64`
|
|
|
|
|
# - Run `./dev.sh package Release linux-x64`
|
2021-08-19 14:47:17 +01:00
|
|
|
# - Run cp ../_package/actions-runner-linux-x64-2.280.3.tar.gz ../../actions-runner-controller/runner/
|
|
|
|
|
# - Beware that `2.280.3` might change across versions
|
feat: Workflow job based ephemeral runner scaling (#721)
This add support for two upcoming enhancements on the GitHub side of self-hosted runners, ephemeral runners, and `workflow_jow` events. You can't use these yet.
**These features are not yet generally available to all GitHub users**. Please take this pull request as a preparation to make it available to actions-runner-controller users as soon as possible after GitHub released the necessary features on their end.
**Ephemeral runners**:
The former, ephemeral runners, is basically the reliable alternative to `--once`, which we've been using when you enabled `ephemeral: true` (default in actions-runner-controller).
`--once` has been suffering from a race issue #466. `--ephemeral` fixes that.
To enable ephemeral runners with `actions/runner`, you give `--ephemeral` to `config.sh`. This updated version of `actions-runner-controller` does it for you, by using `--ephemeral` instead of `--once` when you set `RUNNER_FEATURE_FLAG_EPHEMERAL=true`.
Please read the section `Ephemeral Runners` in the updated version of our README for more information.
Note that ephemeral runners is not released on GitHub yet. And `RUNNER_FEATURE_FLAG_EPHEMERAL=true` won't work at all until the feature gets released on GitHub. Stay tuned for an announcement from GitHub!
**`workflow_job` events**:
`workflow_job` is the additional webhook event that corresponds to each GitHub Actions workflow job run. It provides `actions-runner-controller` a solid foundation to improve our webhook-based autoscale.
Formerly, we've been exploiting webhook events like `check_run` for autoscaling. However, as none of our supported events has included `labels`, you had to configure an HRA to only match relevant `check_run` events. It wasn't trivial.
In contrast, a `workflow_job` event payload contains `labels` of runners requested. `actions-runner-controller` is able to automatically decide which HRA to scale by filtering the corresponding RunnerDeployment by `labels` included in the webhook payload. So all you need to use webhook-based autoscale will be to enable `workflow_job` on GitHub and expose actions-runner-controller's webhook server to the internet.
Note that the current implementation of `workflow_job` support works in two ways, increment, and decrement. An increment happens when the webhook server receives` workflow_job` of `queued` status. A decrement happens when it receives `workflow_job` of `completed` status. The latter is used to make scaling-down faster so that you waste money less than before. You still don't suffer from flapping, as a scale-down is still subject to `scaleDownDelaySecondsAfterScaleOut `.
Please read the section `Example 3: Scale on each `workflow_job` event` in the updated version of our README for more information on its usage.
2021-08-11 09:52:04 +09:00
|
|
|
#
|
|
|
|
|
# See https://github.com/actions/runner/blob/main/.github/workflows/release.yml for more informatino on how you can use dev.sh
|
|
|
|
|
#
|
|
|
|
|
# If you're willing to uncomment the following line, you'd also need to comment-out the
|
|
|
|
|
# && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \
|
|
|
|
|
# line in the next `RUN` command in this Dockerfile, to avoid overwiding this runner.tar.gz with a remote one.
|
|
|
|
|
|
2021-08-19 14:47:17 +01:00
|
|
|
# COPY actions-runner-linux-x64-2.280.3.tar.gz /runnertmp/runner.tar.gz
|
feat: Workflow job based ephemeral runner scaling (#721)
This add support for two upcoming enhancements on the GitHub side of self-hosted runners, ephemeral runners, and `workflow_jow` events. You can't use these yet.
**These features are not yet generally available to all GitHub users**. Please take this pull request as a preparation to make it available to actions-runner-controller users as soon as possible after GitHub released the necessary features on their end.
**Ephemeral runners**:
The former, ephemeral runners, is basically the reliable alternative to `--once`, which we've been using when you enabled `ephemeral: true` (default in actions-runner-controller).
`--once` has been suffering from a race issue #466. `--ephemeral` fixes that.
To enable ephemeral runners with `actions/runner`, you give `--ephemeral` to `config.sh`. This updated version of `actions-runner-controller` does it for you, by using `--ephemeral` instead of `--once` when you set `RUNNER_FEATURE_FLAG_EPHEMERAL=true`.
Please read the section `Ephemeral Runners` in the updated version of our README for more information.
Note that ephemeral runners is not released on GitHub yet. And `RUNNER_FEATURE_FLAG_EPHEMERAL=true` won't work at all until the feature gets released on GitHub. Stay tuned for an announcement from GitHub!
**`workflow_job` events**:
`workflow_job` is the additional webhook event that corresponds to each GitHub Actions workflow job run. It provides `actions-runner-controller` a solid foundation to improve our webhook-based autoscale.
Formerly, we've been exploiting webhook events like `check_run` for autoscaling. However, as none of our supported events has included `labels`, you had to configure an HRA to only match relevant `check_run` events. It wasn't trivial.
In contrast, a `workflow_job` event payload contains `labels` of runners requested. `actions-runner-controller` is able to automatically decide which HRA to scale by filtering the corresponding RunnerDeployment by `labels` included in the webhook payload. So all you need to use webhook-based autoscale will be to enable `workflow_job` on GitHub and expose actions-runner-controller's webhook server to the internet.
Note that the current implementation of `workflow_job` support works in two ways, increment, and decrement. An increment happens when the webhook server receives` workflow_job` of `queued` status. A decrement happens when it receives `workflow_job` of `completed` status. The latter is used to make scaling-down faster so that you waste money less than before. You still don't suffer from flapping, as a scale-down is still subject to `scaleDownDelaySecondsAfterScaleOut `.
Please read the section `Example 3: Scale on each `workflow_job` event` in the updated version of our README for more information on its usage.
2021-08-11 09:52:04 +09:00
|
|
|
|
2020-11-25 01:53:47 +02:00
|
|
|
# Runner download supports amd64 as x64. Externalstmp is needed for making mount points work inside DinD.
|
2020-12-06 11:53:38 +09:00
|
|
|
#
|
|
|
|
|
# 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.
|
2020-10-05 11:26:46 +11:00
|
|
|
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
|
2021-06-22 17:10:09 +09:00
|
|
|
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x64 ; fi \
|
2021-04-17 09:02:03 +01:00
|
|
|
&& mkdir -p "$RUNNER_ASSETS_DIR" \
|
|
|
|
|
&& cd "$RUNNER_ASSETS_DIR" \
|
feat: Workflow job based ephemeral runner scaling (#721)
This add support for two upcoming enhancements on the GitHub side of self-hosted runners, ephemeral runners, and `workflow_jow` events. You can't use these yet.
**These features are not yet generally available to all GitHub users**. Please take this pull request as a preparation to make it available to actions-runner-controller users as soon as possible after GitHub released the necessary features on their end.
**Ephemeral runners**:
The former, ephemeral runners, is basically the reliable alternative to `--once`, which we've been using when you enabled `ephemeral: true` (default in actions-runner-controller).
`--once` has been suffering from a race issue #466. `--ephemeral` fixes that.
To enable ephemeral runners with `actions/runner`, you give `--ephemeral` to `config.sh`. This updated version of `actions-runner-controller` does it for you, by using `--ephemeral` instead of `--once` when you set `RUNNER_FEATURE_FLAG_EPHEMERAL=true`.
Please read the section `Ephemeral Runners` in the updated version of our README for more information.
Note that ephemeral runners is not released on GitHub yet. And `RUNNER_FEATURE_FLAG_EPHEMERAL=true` won't work at all until the feature gets released on GitHub. Stay tuned for an announcement from GitHub!
**`workflow_job` events**:
`workflow_job` is the additional webhook event that corresponds to each GitHub Actions workflow job run. It provides `actions-runner-controller` a solid foundation to improve our webhook-based autoscale.
Formerly, we've been exploiting webhook events like `check_run` for autoscaling. However, as none of our supported events has included `labels`, you had to configure an HRA to only match relevant `check_run` events. It wasn't trivial.
In contrast, a `workflow_job` event payload contains `labels` of runners requested. `actions-runner-controller` is able to automatically decide which HRA to scale by filtering the corresponding RunnerDeployment by `labels` included in the webhook payload. So all you need to use webhook-based autoscale will be to enable `workflow_job` on GitHub and expose actions-runner-controller's webhook server to the internet.
Note that the current implementation of `workflow_job` support works in two ways, increment, and decrement. An increment happens when the webhook server receives` workflow_job` of `queued` status. A decrement happens when it receives `workflow_job` of `completed` status. The latter is used to make scaling-down faster so that you waste money less than before. You still don't suffer from flapping, as a scale-down is still subject to `scaleDownDelaySecondsAfterScaleOut `.
Please read the section `Example 3: Scale on each `workflow_job` event` in the updated version of our README for more information on its usage.
2021-08-11 09:52:04 +09:00
|
|
|
# Comment-out the below curl invocation when you use your own build of actions/runner
|
2021-08-18 15:50:17 +01:00
|
|
|
&& curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \
|
2021-04-17 09:02:03 +01:00
|
|
|
&& tar xzf ./runner.tar.gz \
|
|
|
|
|
&& rm runner.tar.gz \
|
|
|
|
|
&& ./bin/installdependencies.sh \
|
|
|
|
|
&& mv ./externals ./externalstmp \
|
|
|
|
|
&& apt-get install -y libyaml-dev \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2020-01-28 21:56:54 +09:00
|
|
|
|
2021-06-29 00:54:59 +01:00
|
|
|
ENV RUNNER_TOOL_CACHE=/opt/hostedtoolcache
|
2021-06-26 12:51:10 +01:00
|
|
|
RUN mkdir /opt/hostedtoolcache \
|
2021-04-17 09:02:03 +01:00
|
|
|
&& chgrp docker /opt/hostedtoolcache \
|
|
|
|
|
&& chmod g+rwx /opt/hostedtoolcache
|
2020-12-06 11:53:38 +09:00
|
|
|
|
2021-01-24 10:58:35 +09:00
|
|
|
COPY entrypoint.sh /
|
2021-02-07 16:21:10 +08:00
|
|
|
COPY --chown=runner:docker patched $RUNNER_ASSETS_DIR/patched
|
2020-01-28 21:56:54 +09:00
|
|
|
|
2021-06-01 01:21:14 +01:00
|
|
|
# Add the Python "User Script Directory" to the PATH
|
|
|
|
|
ENV PATH="${PATH}:${HOME}/.local/bin"
|
2021-08-18 15:50:17 +01:00
|
|
|
ENV ImageOS=ubuntu20
|
2021-06-01 01:21:14 +01:00
|
|
|
|
2020-10-25 11:25:48 +09:00
|
|
|
USER runner
|
2021-08-18 15:50:17 +01:00
|
|
|
|
2020-02-06 18:47:50 +09:00
|
|
|
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
|
2021-01-24 10:58:35 +09:00
|
|
|
CMD ["/entrypoint.sh"]
|