feat(runner): added runner dockerfile and entrypoint
This commit is contained in:
parent
9c592f9a10
commit
9497cacf42
2 changed files with 49 additions and 0 deletions
9
runner/Dockerfile
Normal file
9
runner/Dockerfile
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# docker run -e METADATA_URL=https://garm.garm-provider-test.t09.de/api/v1/metadata -e CALLBACK_URL=https://garm.garm-provider-test.t09.de/api/v1/callbacks -e GITHUB_URL=https://garm-provider-test.t09.de/ -e RUNNER_NAME="lala" -e BEARER_TOKEN="" test
|
||||||
|
FROM code.forgejo.org/forgejo/runner:11
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN apk add curl
|
||||||
|
|
||||||
|
COPY ./entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||||
40
runner/entrypoint.sh
Executable file
40
runner/entrypoint.sh
Executable file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
#
|
||||||
|
RUNNER_HOME=${RUNNER_HOME:-/data}
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
if [ ! -d "${RUNNER_HOME}" ]; then
|
||||||
|
log.error "$RUNNER_HOME should be an emptyDir mount. Please fix the pod spec."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$METADATA_URL" ]; then
|
||||||
|
echo "no token is available and METADATA_URL is not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$CALLBACK_URL" ]; then
|
||||||
|
echo "CALLBACK_URL is not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# retrieve runner secret from garm
|
||||||
|
RUNNER_SECRET=$(curl --retry 5 --retry-delay 5 --retry-connrefused --fail -v -X GET -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${METADATA_URL}/runner-registration-token/")
|
||||||
|
|
||||||
|
forgejo-runner \
|
||||||
|
register \
|
||||||
|
--no-interactive \
|
||||||
|
--token ${RUNNER_SECRET} \
|
||||||
|
--name ${RUNNER_NAME} \
|
||||||
|
--instance ${GITHUB_URL} \
|
||||||
|
--labels ubuntu-host:host
|
||||||
|
|
||||||
|
forgejo-runner generate-config > config.yml;
|
||||||
|
|
||||||
|
unset RUNNER_SECRET
|
||||||
|
unset BEARER_TOKEN
|
||||||
|
|
||||||
|
/bin/forgejo-runner --config config.yml daemon
|
||||||
Loading…
Add table
Add a link
Reference in a new issue