Compare commits

...
42 Commits
Author SHA1 Message Date
Marcus Young 032d5c358f [Automated 🤖 ] Bump to version 2.286.1 2022-01-14 11:11:35 -06:00
myoung34andGitHub 46259e4d1e Merge pull request #171 from jensbaitingerbosch/patch-2
Added chapter about proxy support
2022-01-07 08:01:30 -06:00
Jens BaitingerandGitHub c7c7a89cb0 Added chapter about proxy support 2022-01-07 11:31:27 +01:00
myoung34andGitHub 111dfab468 Merge pull request #170 from jensbaitingerbosch/patch-1
fixing HTTP/1.1 411 Length Required
2022-01-06 10:56:12 -06:00
Jens BaitingerandGitHub c0539dfb0e fixing HTTP/1.1 411 Length Required
Somehow our Github enterprise server returns 411 when the "Content-Lenght" header is not set. 

The complete error message is (using curl -v): 
```
HTTP/1.1 411 Length Required
< Content-Type: text/html; charset=us-ascii
< Server: Microsoft-HTTPAPI/2.0
< Date: Thu, 06 Jan 2022 15:36:55 GMT
< Connection: close
< Content-Length: 344
<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
```

By setting this Header explicitely, this error does no longer occur.
2022-01-06 16:51:42 +01:00
Marcus Young a3bfdb6798 [Automated 🤖 ] Bump to version 2.286.0 2021-12-21 10:09:57 -06:00
Marcus Young 2fb64e21af Add docs around auto update 2021-12-13 10:53:14 -06:00
Marcus Young 1859a7f9f0 Fix typo in docker image name in readme 2021-12-13 10:40:51 -06:00
Marcus Young 75fe1ec298 [Automated 🤖 ] Bump to version 2.285.1 2021-12-06 11:01:30 -06:00
Marcus Young 0b94c32395 [Automated 🤖 ] Bump to version 2.285.0 2021-11-29 10:31:01 -06:00
myoung34andGitHub 84d2ccdb6c Merge pull request #162 from Kesin11/fix_configure_command_no_ephemral
Fix configure command when EPHEMERAL is disabled
2021-11-27 06:49:12 -06:00
Kenta KaseandGitHub 073a18840d Fix configure command when EPHEMERAL is disabled 2021-11-27 18:09:11 +09:00
myoung34andGitHub 569fdcef42 Merge pull request #161 from Kesin11/support_ephemeral_option
Support --ephemeral option
2021-11-24 09:38:46 -06:00
Kenta KaseandGitHub 197ded45fb Add docs for 'EPHEMERAL' ENV 2021-11-24 09:25:15 +09:00
Kenta KaseandGitHub 63b7a683ad Support --ephemeral runner option 2021-11-24 09:18:49 +09:00
Marcus Young 12755b572f [Automated 🤖 ] Bump to version 2.284.0 2021-11-01 10:37:01 -05:00
Marcus Young e4b56c3d76 [Automated 🤖 ] Bump to version 2.283.3 2021-10-04 14:14:55 -05:00
Marcus Young b91ff43474 [Automated 🤖 ] Bump to version 2.283.2 2021-09-30 08:04:43 -05:00
myoung34andGitHub 3e5e6de819 Merge pull request #150 from gazab/patch-1
Fix small typo in entrypoint.sh log output
2021-09-22 07:30:19 -05:00
Gustav TonérandGitHub d0da2268ee Fix typo in entrypoint.sh log output 2021-09-22 13:24:20 +02:00
Marcus Young fbc204bc10 [Automated 🤖 ] Bump to version 2.283.1 2021-09-20 09:06:26 -05:00
Marcus Young 162cb1f201 [Automated 🤖 ] Bump to version 2.283.0 2021-09-20 08:21:05 -05:00
Marcus Young 0e38dc10ce [Automated 🤖 ] Bump to version 2.282.1 2021-09-15 13:04:58 -05:00
myoung34andGitHub dd77bee9a9 Merge pull request #149 from myoung34/signals
Fix deregistration hijacking
2021-09-15 10:26:18 -05:00
Marcus Young c837c99a7b Fix deregistration hijacking 2021-09-15 10:23:46 -05:00
myoung34andGitHub 10b21dfc71 Merge pull request #141 from joeyparrish/deregistration
Fix runner deregistration with ACCESS_TOKEN
2021-09-15 10:22:25 -05:00
myoung34andGitHub e386012396 Merge branch 'master' into deregistration 2021-09-15 08:31:07 -05:00
myoung34andGitHub 4df911ff4b Merge pull request #145 from Niek/master
Fix #142 - building on Sid
2021-09-15 08:29:28 -05:00
myoung34andGitHub d75627b94e Merge pull request #143 from JulianGro/update_debian
Update Debian README information
2021-09-15 08:19:45 -05:00
myoung34andGitHub 2aa12337bb Merge pull request #146 from JulianGro/fix_locale
Properly enable locale
2021-09-15 08:19:12 -05:00
myoung34andGitHub 37ffbfad94 Merge pull request #147 from lukaszjankowski/fix-typo
Fix typo in entrypoint.sh
2021-09-15 08:17:53 -05:00
Łukasz JankowskiandGitHub 9bf27c4aac Update entrypoint.sh 2021-09-14 11:20:43 +02:00
Julian Groß 3cbb4714a8 Properly enable locale 2021-09-13 23:58:46 +02:00
Marcus Young 85d2ef126b [Automated 🤖 ] Bump to version 2.282.0 2021-09-13 13:17:21 -05:00
Niek van der MaasandGitHub c9b0931b5a Merge branch 'myoung34:master' into master 2021-09-13 12:35:32 +02:00
Niek van der Maas 450ab99ee9 Fix Sid support 2021-09-13 12:35:12 +02:00
Julian Groß 4006da573c Update Debian README as Debian Bullseye has been released as stable. 2021-09-11 03:35:30 +02:00
myoung34andGitHub b11f137e68 Merge pull request #140 from joeyparrish/ephemeral
feat: Ephemeral mode
2021-09-10 11:17:06 -05:00
53089f4326 Accept maintainer's suggestion in README
Co-authored-by: myoung34 <myoung34@my.apsu.edu>
2021-09-10 12:16:06 -04:00
Joey Parrish 844d91507d Add docs for ephemeral mode 2021-09-10 09:08:35 -07:00
Joey Parrish 816a1c181f Fix runner deregistration with ACCESS_TOKEN
This fixes runner deregistration, which needs to have ACCESS_TOKEN still
defined to fetch a fresh RUNNER_TOKEN for deregistration.

The original purpose of unsetting the variables would seem to be for
security, to make sure they unavailable to the jobs running in the
container. Unexporting the variables achieves the same goal, but leaves
them available to the entrypoint later when it runs the deregistration
process.
2021-09-10 08:56:00 -07:00
Joey Parrish ced39230ac feat: Ephemeral mode 2021-09-10 08:49:45 -07:00
6 changed files with 149 additions and 24 deletions
+4 -4
View File
@@ -5,7 +5,7 @@ LABEL maintainer="myoung34@my.apsu.edu"
ENV AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
RUN mkdir -p /opt/hostedtoolcache
ARG GH_RUNNER_VERSION="2.281.1"
ARG GH_RUNNER_VERSION="2.286.1"
ARG TARGETPLATFORM
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -17,8 +17,8 @@ RUN chmod +x /actions-runner/install_actions.sh \
&& /actions-runner/install_actions.sh ${GH_RUNNER_VERSION} ${TARGETPLATFORM} \
&& rm /actions-runner/install_actions.sh
COPY token.sh entrypoint.sh /
RUN chmod +x /token.sh /entrypoint.sh
COPY token.sh entrypoint.sh ephemeral-runner.sh /
RUN chmod +x /token.sh /entrypoint.sh /ephemeral-runner.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/actions-runner/bin/runsvc.sh"]
CMD ["./bin/Runner.Listener", "run", "--startuptype", "service"]
+12 -8
View File
@@ -12,13 +12,14 @@ ARG DOCKER_KEY="7EA0A9C3F273FCD8"
ENV DOCKER_COMPOSE_VERSION="1.27.4"
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
# hadolint ignore=DL3003,DL4001
RUN apt-get update && \
apt-get install -y --no-install-recommends \
RUN echo en_US.UTF-8 UTF-8 >> /etc/locale.gen \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
awscli \
curl \
tar \
@@ -45,8 +46,6 @@ RUN apt-get update && \
python \
dumb-init \
&& pip3 install --no-cache-dir awscliv2 \
&& locale-gen en_US.UTF-8 \
&& dpkg-reconfigure locales \
&& c_rehash \
&& cd /tmp \
&& curl -sL https://www.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz -o git.tgz \
@@ -56,9 +55,14 @@ RUN apt-get update && \
&& make \
&& make install \
&& cd / \
# Determine the Distro name (Debian, Ubuntu, etc)
&& distro=$(lsb_release -is | awk '{print tolower($0)}') \
# Determine the Distro version (bullseye, xenial, etc)
# Note: sid is aliased to bullseye, because Docker doesn't have a matching apt repo
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${DOCKER_KEY} \
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | awk '{print tolower($0)}')/gpg | apt-key add - \
&& ( add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(lsb_release -is | awk '{print tolower($0)}') $(lsb_release -cs) stable" ) \
&& curl -fsSL https://download.docker.com/linux/${distro}/gpg | apt-key add - \
&& version=$(lsb_release -cs | awk '{gsub("sid", "bullseye"); print $0}') \
&& ( add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/${distro} ${version} stable" ) \
&& apt-get update \
&& apt-get install -y docker-ce docker-ce-cli containerd.io --no-install-recommends --allow-unauthenticated \
&& [[ $(lscpu -J | jq -r '.lscpu[] | select(.field == "Vendor ID:") | .data') == "ARM" ]] && echo "Not installing docker-compose. See https://github.com/docker/compose/issues/6831" || ( curl -sL "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose ) \
+75 -3
View File
@@ -7,6 +7,10 @@ This will run the [new self-hosted github actions runners](https://help.github.c
## Notes ##
### Auto Update Issues ###
There is a [known issue with auto updates in docker](https://github.com/actions/runner/issues/246). If one is running a version that has an update it will try to auto update and fail. The only current workaround is to run `latest` which in theory is always up to date and wont update/throttle.
### Docker Support ###
Please note that while this runner installs and allows docker, github actions itself does not support using docker from a self hosted runner yet.
@@ -28,9 +32,9 @@ A workaround exists, please see [here](https://github.com/myoung34/docker-github
| --- | --- | --- | --- | --- | --- |
| ubuntu focal | `x86_64`,`arm64` | `/\d\.\d{3}\.\d+/` | [latest](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=latest) | This is the latest build (Rebuilt nightly and on master merges). Tags without an OS name are included. | Tags without an OS name *before* 9/17/2020 are `eoan`. `armv7` support stopped 9/18/2020 due to inconsistent docker-ce packaging |
| ubuntu bionic | `x86_64`,`armv7`,`arm64` | `/\d\.\d{3}\.\d+-ubuntu-bionic/` | [ubuntu-bionic](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=ubuntu-bionic) | This is the latest build from bionic (Rebuilt nightly and on master merges). Tags with `-ubuntu-bionic` are included and created on [upstream tags](https://github.com/actions/runner/tags). | |
| debian buster | `x86_64`,`arm64`,`armv7` | `/\d\.\d{3}\.\d+-debian-buster/` | [debian-buster](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-buster) | This is the latest build from buster (Rebuilt nightly and on master merges). Tags with `-debian-buster` are included and created on [upstream tags](https://github.com/actions/runner/tags). | |
| debian bullseye | `x86_64`,`arm64`,`armv7` | `/\d\.\d{3}\.\d+-debian-bullseye/` | [debian-bullseye](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-bullseye) | This is the latest build from bullseye (Rebuilt nightly and on master merges). Tags with `-debian-bullseye` are included and created on [upstream tags](https://github.com/actions/runner/tags). | Debian Bullseye will be the next stable release of Debian Linux. |
| debian sid | `x86_64`,`arm64`,`admv7` | `/\d\.\d{3}\.\d+-debian-sid/` | [debian-sid](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-sid) | This is the latest build from sid (Rebuilt nightly and on master merges). Tags with `-debian-sid` are included and created on [upstream tags](https://github.com/actions/runner/tags). | Debian sid is considered unstable by Debian. |
| debian buster | `x86_64`,`arm64`,`armv7` | `/\d\.\d{3}\.\d+-debian-buster/` | [debian-buster](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-buster) | This is the latest build from buster (Rebuilt nightly and on master merges). Tags with `-debian-buster` are included and created on [upstream tags](https://github.com/actions/runner/tags). | Buster is Debians current old-stable release. |
| debian bullseye | `x86_64`,`arm64`,`armv7` | `/\d\.\d{3}\.\d+-debian-bullseye/` | [debian-bullseye](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-bullseye) | This is the latest build from bullseye (Rebuilt nightly and on master merges). Tags with `-debian-bullseye` are included and created on [upstream tags](https://github.com/actions/runner/tags). | Bullseye is Debians current stable release. |
| debian sid | `x86_64`,`arm64`,`admv7` | `/\d\.\d{3}\.\d+-debian-sid/` | [debian-sid](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-sid) | This is the latest build from sid (Rebuilt nightly and on master merges). Tags with `-debian-sid` are included and created on [upstream tags](https://github.com/actions/runner/tags). | Sid is considered unstable by Debian. |
| ubuntu xenial | `x86_64`,`arm64` | `/\d\.\d{3}\.\d+-ubuntu-xenial/` | [ubuntu-xenial](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=ubuntu-xenial) | This is the latest build from xenial (Rebuilt nightly and on master merges). Tags with `-ubuntu-xenial` are included and created on [upstream tags](https://github.com/actions/runner/tags). | This is deprecated as of 7/15/2021 and will no longer receive tags. |
These containers are built via Github actions that [copy the dockerfile](https://github.com/myoung34/docker-github-actions-runner/blob/master/.github/workflows/deploy.yml#L47), changing the `FROM` and building to provide simplicity.
@@ -53,6 +57,7 @@ These containers are built via Github actions that [copy the dockerfile](https:/
| `GITHUB_HOST` | Optional URL of the Github Enterprise server e.g github.mycompany.com. Defaults to `github.com`. |
| `DISABLE_AUTOMATIC_DEREGISTRATION` | Optional flag to disable signal catching for deregistration. Default is `false`. Any value other than exactly `false` is considered `true`. See [here](https://github.com/myoung34/docker-github-actions-runner/issues/94) |
| `CONFIGURED_ACTIONS_RUNNER_FILES_DIR` | Path to use for runner data. It allows avoiding reregistration each the start of the runner. No default value. |
| `EPHEMERAL` | Optional flag to configure runner with [`--ephemeral` option](https://docs.github.com/en/actions/hosting-your-own-runners/autoscaling-with-self-hosted-runners#using-ephemeral-runners-for-autoscaling). Ephemeral runners are suitable for autoscaling. |
## Examples ##
@@ -315,3 +320,70 @@ docker run -d --restart always --name github-runner \
-v /tmp/github-runner-your-repo:/tmp/github-runner-your-repo \
myoung34/github-runner:latest
```
## Ephemeral mode
GitHub's hosted runners are completely ephemeral. You can remove all its data without breaking all future jobs.
To achieve the same resilience in a self-hosted runner:
1. override the command for your runner with `/ephemeral-runner.sh` (which will terminate after one job executes)
2. don't mount a local folder into `RUNNER_WORKDIR` (to ensure no filesystem persistence)
3. run the container with `--rm` (to delete it after termination)
4. wrap the container execution in a system service that restarts (to start a fresh container after each job)
Here's an example service definition for systemd:
```
# Install with:
# sudo install -m 644 ephemeral-github-actions-runner.service /etc/systemd/system/
# sudo systemctl daemon-reload
# sudo systemctl enable ephemeral-github-actions-runner
# Run with:
# sudo systemctl start ephemeral-github-actions-runner
# Stop with:
# sudo systemctl stop ephemeral-github-actions-runner
# See live logs with:
# journalctl -f -u ephemeral-github-actions-runner.service --no-hostname --no-tail
[Unit]
Description=Ephemeral GitHub Actions Runner Container
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop %n
ExecStartPre=-/usr/bin/docker rm %n
ExecStartPre=-/usr/bin/docker pull myoung34/github-runner:latest
ExecStart=/usr/bin/docker run --rm --env-file /etc/ephemeral-github-actions-runner.env --name %n myoung34/github-runner:latest /ephemeral-runner.sh
[Install]
WantedBy=multi-user.target
```
And an example of the corresponding env file that the service reads from:
```
# Install with:
# sudo install -m 600 ephemeral-github-actions-runner.env /etc/
REPO_URL=https://github.com/your-org/your-repo
RUNNER_NAME=your-runner-name-here
ACCESS_TOKEN=foo-access-token
RUNNER_WORKDIR=/tmp/runner/work
LABELS=any-custom-labels-go-here
EPHEMERAL=true
```
## Proxy Support
To run the github runners behind a proxy, you need to pass the [proxy parameters required for the GitHub Runner](https://docs.github.com/en/actions/hosting-your-own-runners/using-a-proxy-server-with-self-hosted-runners) as environment variables.
Note: The `http://` as prefix is required by the GitHub Runner.
```shell
docker run -d --restart always --name github-runner \
-e https_proxy="http://myproxy:3128" \
-e http_proxy="http://myproxy:3128" \
-e RUNNER_NAME_PREFIX="myrunner" \
# ...
myoung34/github-runner:latest
+20 -9
View File
@@ -3,10 +3,17 @@
export RUNNER_ALLOW_RUNASROOT=1
export PATH=$PATH:/actions-runner
# Un-export these, so that they must be passed explicitly to the environment of
# any command that needs them. This may help prevent leaks.
export -n ACCESS_TOKEN
export -n RUNNER_TOKEN
deregister_runner() {
echo "Caught SIGTERM. Deregistering runner"
_TOKEN=$(bash /token.sh)
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
if [[ -n "${ACCESS_TOKEN}" ]]; then
_TOKEN=$(ACCESS_TOKEN="${ACCESS_TOKEN}" bash /token.sh)
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
fi
./config.sh remove --token "${RUNNER_TOKEN}"
exit
}
@@ -53,11 +60,18 @@ esac
configure_runner() {
if [[ -n "${ACCESS_TOKEN}" ]]; then
echo "Obtaining the token of the runnet"
_TOKEN=$(bash /token.sh)
echo "Obtaining the token of the runner"
_TOKEN=$(ACCESS_TOKEN="${ACCESS_TOKEN}" bash /token.sh)
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
fi
if [ -n "${EPHEMERAL}" ]; then
echo "Ephemeral option is enabled"
_EPHEMERAL="--ephemeral"
else
_EPHEMERAL=""
fi
echo "Configuring"
./config.sh \
--url "${_SHORT_URL}" \
@@ -67,7 +81,7 @@ configure_runner() {
--labels "${_LABELS}" \
--runnergroup "${_RUNNER_GROUP}" \
--unattended \
--replace
--replace ${_EPHEMERAL}
}
@@ -98,11 +112,8 @@ if [[ -n "${CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]]; then
fi
if [[ ${_DISABLE_AUTOMATIC_DEREGISTRATION} == "false" ]]; then
trap deregister_runner SIGINT SIGQUIT SIGTERM
trap deregister_runner SIGINT SIGQUIT SIGTERM INT TERM QUIT
fi
unset ACCESS_TOKEN
unset RUNNER_TOKEN
# Container's command (CMD) execution
"$@"
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
echo "*** Starting ephemeral runner. ***"
/actions-runner/run.sh --once
rv=$?
# See exit code constants in the runner source here:
# https://github.com/actions/runner/blob/be96323/src/Runner.Common/Constants.cs#L135
if [[ $rv == 4 ]]; then
# The runner software was updated.
echo "*** Software update detected. ***"
echo "*** Waiting for update to complete. ***"
# Hard-coded sleep. Without some delay, the update is still in progress in
# the background, leading to failures when we re-launch.
sleep 10
# Now add an adaptive delay, where we loop and check if the Runner is usable
# yet. As soon as it is, break.
for i in $(seq 10); do
if /actions-runner/bin/Runner.Listener --version &>/dev/null; then
break
fi
echo "*** Update still in progress... ***"
sleep 5
done
# Now re-launch the script.
echo "*** Re-launching runner. ***"
exec "$0"
fi
# For any other return value, let the script and the Docker container terminate.
echo "*** Exit code $rv ***"
exit $rv
+2
View File
@@ -12,6 +12,7 @@ fi
API_VERSION=v3
API_HEADER="Accept: application/vnd.github.${API_VERSION}+json"
AUTH_HEADER="Authorization: token ${ACCESS_TOKEN}"
CONTENT_LENGTH_HEADER="Content-Length: 0"
case ${RUNNER_SCOPE} in
org*)
@@ -34,6 +35,7 @@ case ${RUNNER_SCOPE} in
esac
RUNNER_TOKEN="$(curl -XPOST -fsSL \
-H "${CONTENT_LENGTH_HEADER}" \
-H "${AUTH_HEADER}" \
-H "${API_HEADER}" \
"${_FULL_URL}" \