1
0
mirror of https://git.cloudron.io/cloudron/gitea-app synced 2025-09-25 14:37:44 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Vladimir D
22ddd5514d make act_runner re-register on every restart 2025-05-12 13:39:04 +04:00
Vladimir D
626326f65e act_runner implemented 2025-05-12 12:18:58 +04:00
5 changed files with 59 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
{
"id": "io.gitea.cloudronapp",
"title": "Gitea",
"id": "io.gitea.actrunner.cloudronapp",
"title": "Gitea + Act Runner",
"author": "Gitea developers",
"description": "file://DESCRIPTION.md",
"tagline": "A painless self-hosted Git Service",
@@ -10,6 +10,7 @@
"httpPort": 3000,
"memoryLimit": 536870912,
"addons": {
"docker": {},
"mysql": {},
"sendmail": {
"supportsDisplayName": true

View File

@@ -27,6 +27,12 @@ RUN mkdir -p /home/git/gitea && \
# setup config paths
ADD app.ini.template /home/git/app.ini.template
# renovate: datasource=github-releases depName=gitea/act_runner versioning=semver extractVersion=^v(?<version>.+)$ registryUrl=https://gitea.com
ARG ACT_RUNNER_VERSION=0.2.11
RUN curl -L https://gitea.com/gitea/act_runner/releases/download/v${ACT_RUNNER_VERSION}/act_runner-${ACT_RUNNER_VERSION}-linux-amd64.xz | unxz -dc > /usr/local/bin/act_runner && \
chmod +x /usr/local/bin/act_runner
# setup log paths
RUN mkdir -p /run/gitea && chown -R git:git /run/gitea
RUN sed -e 's,^logfile=.*$,logfile=/run/gitea/supervisord.log,' -i /etc/supervisor/supervisord.conf

View File

@@ -6,3 +6,7 @@ This app is pre-setup with an admin account. The initial credentials are:
<sso>
Use the `Local` authentication source for logging in as admin.
</sso>
Gitea is bundled along with `act_runner` runner. It's being registered in Gitea at the first run.
To configure `act_runner` you need to update `/app/data/act_runner/config.yaml`. Please read a config example for a reference.
https://gitea.com/gitea/act_runner/src/branch/main/internal/pkg/config/config.example.yaml

View File

@@ -2,7 +2,9 @@
set -eu -o pipefail
mkdir -p /run/gitea/tmp/uploads /run/sshd /run/gitea/sessions
mkdir -p /run/gitea/tmp/uploads /run/sshd /run/gitea/sessions /app/data/act_runner
export DOCKER_HOST=${CLOUDRON_DOCKER_HOST}
# CLOUDRON_OIDC_PROVIDER_NAME not supported as it will be used in rest route!
setup_oidc_source() {
@@ -26,14 +28,38 @@ setup_root_user() {
fi
}
setup_auth() {
set -eu
setup_act_runner() {
wait_for_gitea
# Wait for gitea to finish db setup, before we do any db operations
while ! curl --fail http://localhost:3000/explore; do
echo "==> Setup act_runner"
if [[ ! -f /app/data/act_runner/config.yaml ]]; then
gosu git act_runner generate-config > /app/data/act_runner/config.yaml
fi
yq -e -i ".runner.file=\"/app/data/act_runner/.runner\"" /app/data/act_runner/config.yaml
if [[ ! -f /app/data/act_runner/.runner ]]; then
RUNNER_TOKEN=$(gosu git /home/git/gitea/gitea --config /run/gitea/app.ini actions generate-runner-token)
echo "===> act_runner token: ${RUNNER_TOKEN}"
echo "===> Register act_runner"
gosu git act_runner register --instance ${CLOUDRON_APP_ORIGIN} --token ${RUNNER_TOKEN} --name 'cloudron-runner' --config /app/data/act_runner/config.yaml --no-interactive
else
yq -e -i ".address=\"${CLOUDRON_APP_ORIGIN}\"" /app/data/act_runner/.runner
fi
}
wait_for_gitea() {
while ! curl --fail -s http://localhost:3000/explore > /dev/null; do
echo "==> Waiting for gitea to come up"
sleep 1
done
}
setup() {
set -eu
# Wait for gitea to finish db setup, before we do any db operations
wait_for_gitea
echo "==> Gitea is up, setting up auth"
@@ -47,6 +73,9 @@ setup_auth() {
echo "==> Setting up root user for first run"
setup_root_user
fi
# setup act_runner
setup_act_runner
}
# SSH_PORT can be unset to disable SSH
@@ -120,6 +149,6 @@ mkdir -p /app/data/repository /app/data/ssh /app/data/custom /app/data/gnupg
chown -R git:git /app/data /run/gitea
# this expects app.ini to be available
( setup_auth ) &
( setup ) &
exec /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i Gitea

View File

@@ -0,0 +1,11 @@
[program:act_runner]
directory=/app/data/act_runner/
command=bash -c "while true; do [[ -f /app/data/act_runner/.runner ]] && break; echo 'Wait for act_runner config'; sleep 1; done && act_runner daemon --config /app/data/act_runner/config.yaml"
user=git
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
environment=HOME="/home/git",USER="git"