diff --git a/README.md b/README.md index 883131f..6c4ef3a 100644 --- a/README.md +++ b/README.md @@ -2,31 +2,12 @@ Forgejo instance serving https://forge.karnov.club. -## Usage +## Maintaining -### Starting / restarting +Using [spud](https://forge.karnov.club/spadinastan/spud), just `spud start ./service.yml`! + +### Starting runners -```bash -FORGEJO_ROOT=.. FORGEJO_RUNNER_ROOT=... ./start.sh ``` - -`FORGEJO_ROOT` should be a directory with read+write access by the container user, this is where application data will -get stored. - -`FORGEJO_RUNNER_ROOT` should also be read+write accessible and will be where the runner stores data. - -Calling the `start.sh` script will replace the containers if they already exists. - -Note that the runner(s) must be registered and started manually. - -### Stopping - -```bash -./stop.sh +FORGEJO_RUNNER_ROOT=... ./start-action-runner.sh ``` - -## Networking - -| Port | Notes | -|---|---| -|`3000`|Web listening port| diff --git a/start-action-runner.sh b/start-action-runner.sh new file mode 100755 index 0000000..dec8d0f --- /dev/null +++ b/start-action-runner.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +wget -O "$FORGEJO_RUNNER_ROOT"/forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v3.3.0/forgejo-runner-3.3.0-linux-amd64 +chmod +x "$FORGEJO_RUNNER_ROOT"/forgejo-runner +wget -O forgejo-runner.asc https://code.forgejo.org/forgejo/runner/releases/download/v3.3.0/forgejo-runner-3.3.0-linux-amd64.asc +gpg --keyserver keys.openpgp.org --recv EB114F5E6C0DC2BCDD183550A4B61A2DC5923710 +gpg --verify forgejo-runner.asc "$FORGEJO_RUNNER_ROOT"/forgejo-runner +rm forgejo-runner.asc + + +if [ -f "$FORGEJO_RUNNER_ROOT/.runner" ]; then + echo "Found runner state." + ( + cd "$FORGEJO_RUNNER_ROOT" || exit + "$FORGEJO_RUNNER_ROOT"/forgejo-runner --config "${FORGEJO_RUNNER_CONFIG:=./config.yml}" daemon & + ) +else + echo "Use $FORGEJO_RUNNER_ROOT/forgejo-runner register ... to register the runner" + echo "Once registered, use $FORGEJO_RUNNER_ROOT/forgejo-runner --config daemon & to start" +fi diff --git a/start.sh b/start.sh deleted file mode 100755 index 1f44814..0000000 --- a/start.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/bash - -if [[ -z "$FORGEJO_ROOT" ]]; then - echo "Error: FORGEJO_ROOT must be defined in the environment." - exit 1 -fi - -if [[ -z "$FORGEJO_RUNNER_ROOT" ]]; then - echo "Error: FORGEJO_RUNNER_ROOT must be defined in the environment." - exit 1 -fi - -if [[ -z "$FORGEJO_RUNNER_CONFIG" ]]; then - echo "Using the default runner configuration." -fi - -podman pod create \ - -p 3000:3000 \ - -p 2052:2222 \ - -p 3001:9187 \ - --replace \ - "code-forge" - -# Start app database. - -podman run \ - -td \ - --pod "code-forge" \ - --name "code-forge_db" \ - -v code-forge_db:/var/lib/postgresql/data:Z \ - --replace \ - postgres:16.2 - -# Start webapp. - -podman run \ - -td \ - --name "code-forge_app" \ - --pod "code-forge" \ - -v "$FORGEJO_ROOT"/data:/var/lib/gitea \ - -v "$FORGEJO_ROOT"/config:/etc/gitea \ - -v /etc/timezone:/etc/timezone:ro \ - -v /etc/localtime:/etc/localtime:ro \ - --replace \ - codeberg.org/forgejo/forgejo:1.21.8-0-rootless - -# The runners require the app to be healthy before startup. -response="" -until [[ $response = *"200 OK"* ]]; do - response="$(curl localhost:3000 -s -i | head -1)" - echo "Waiting for app to respond..." -done - -podman run -d \ - --env-file "$ENV_FILE_DIR"/code-forge-exporter.env \ - --pod code-forge \ - --replace \ - --name "code-forge-pg-exporter" \ - quay.io/prometheuscommunity/postgres-exporter - -if [[ -n $START_RUNNER ]]; then - wget -O "$FORGEJO_RUNNER_ROOT"/forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v3.3.0/forgejo-runner-3.3.0-linux-amd64 - chmod +x "$FORGEJO_RUNNER_ROOT"/forgejo-runner - wget -O forgejo-runner.asc https://code.forgejo.org/forgejo/runner/releases/download/v3.3.0/forgejo-runner-3.3.0-linux-amd64.asc - gpg --keyserver keys.openpgp.org --recv EB114F5E6C0DC2BCDD183550A4B61A2DC5923710 - gpg --verify forgejo-runner.asc "$FORGEJO_RUNNER_ROOT"/forgejo-runner - rm forgejo-runner.asc - - - if [ -f "$FORGEJO_RUNNER_ROOT/.runner" ]; then - echo "Found runner state." - ( - cd "$FORGEJO_RUNNER_ROOT" || exit - "$FORGEJO_RUNNER_ROOT"/forgejo-runner --config "${FORGEJO_RUNNER_CONFIG:=./config.yml}" daemon & - ) - else - echo "Use $FORGEJO_RUNNER_ROOT/forgejo-runner register ... to register the runner" - echo "Once registered, use $FORGEJO_RUNNER_ROOT/forgejo-runner --config daemon & to start" - fi -fi diff --git a/stop.sh b/stop.sh deleted file mode 100755 index 02a7ec6..0000000 --- a/stop.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/bash - -podman pod stop "code-forge" - -echo "WARN: The runner process must be stopped manually since it's not a container."