mirror of
https://gitea.com/gitea/act_runner.git
synced 2024-11-10 12:47:22 +01:00
5a8134410d
This adds a very simple Dockerfile and run script for running `act_runner` as a container. It also allows setting `Privileged` and `ContainerOptions` flags via the new config file when spawning task containers. The combination makes it possible to use Docker-in-Docker (which requires `privileged` mode) as well as pass any other options child Docker containers may require. For example, if Gitea is running in Docker on the same machine, for the `checkout` action to behave as expected from a task container launched by `act_runner`, it might be necessary to map the hostname via something like: ``` container: network_mode: bridge privileged: true options: --add-host=my.gitea.hostname:host-gateway ``` > NOTE: Description updated to reflect latest code. > NOTE: Description updated to reflect latest code (again). Reviewed-on: https://gitea.com/gitea/act_runner/pulls/84 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: Jason Song <i@wolfogre.com> Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com> Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
46 lines
1.2 KiB
Bash
Executable File
46 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
if [[ ! -d /data ]]; then
|
|
mkdir -p /data
|
|
fi
|
|
|
|
cd /data
|
|
|
|
CONFIG_ARG=""
|
|
if [[ ! -z "${CONFIG_FILE}" ]]; then
|
|
CONFIG_ARG="--config ${CONFIG_FILE}"
|
|
fi
|
|
|
|
# Use the same ENV variable names as https://github.com/vegardit/docker-gitea-act-runner
|
|
|
|
if [[ ! -s .runner ]]; then
|
|
try=$((try + 1))
|
|
success=0
|
|
|
|
# The point of this loop is to make it simple, when running both act_runner and gitea in docker,
|
|
# for the act_runner to wait a moment for gitea to become available before erroring out. Within
|
|
# the context of a single docker-compose, something similar could be done via healthchecks, but
|
|
# this is more flexible.
|
|
while [[ $success -eq 0 ]] && [[ $try -lt ${GITEA_MAX_REG_ATTEMPTS:-10} ]]; do
|
|
act_runner register \
|
|
--instance "${GITEA_INSTANCE_URL}" \
|
|
--token "${GITEA_RUNNER_REGISTRATION_TOKEN}" \
|
|
--name "${GITEA_RUNNER_NAME:-`hostname`}" \
|
|
--labels "${GITEA_RUNNER_LABELS}" \
|
|
${CONFIG_ARG} --no-interactive > /tmp/reg.log 2>&1
|
|
|
|
cat /tmp/reg.log
|
|
|
|
cat /tmp/reg.log | grep 'Runner registered successfully' > /dev/null
|
|
if [[ $? -eq 0 ]]; then
|
|
echo "SUCCESS"
|
|
success=1
|
|
else
|
|
echo "Waiting to retry ..."
|
|
sleep 5
|
|
fi
|
|
done
|
|
fi
|
|
|
|
act_runner daemon ${CONFIG_ARG}
|