From 062d36e640dd95018d0565441e79b1c587ab9e2f Mon Sep 17 00:00:00 2001 From: Mauritz Uphoff Date: Mon, 18 Aug 2025 14:33:03 +0200 Subject: [PATCH] Initial commit --- .forgejo/workflows/simple-build.yaml | 20 ++++++ .gitignore | 1 + Dockerfile | 5 ++ runner.yaml | 98 ++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 .forgejo/workflows/simple-build.yaml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 runner.yaml diff --git a/.forgejo/workflows/simple-build.yaml b/.forgejo/workflows/simple-build.yaml new file mode 100644 index 0000000..ec5c572 --- /dev/null +++ b/.forgejo/workflows/simple-build.yaml @@ -0,0 +1,20 @@ +# test docker build workflow +on: + push: + branches: + - main + +jobs: + build: + runs-on: docker-dind + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build image with docker + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..04ad068 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:3.19 + +RUN apk add --no-cache curl + +CMD ["curl", "--version"] \ No newline at end of file diff --git a/runner.yaml b/runner.yaml new file mode 100644 index 0000000..a4afe92 --- /dev/null +++ b/runner.yaml @@ -0,0 +1,98 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: forgejo-runner +--- +apiVersion: v1 +stringData: + token: "" +kind: Secret +metadata: + name: runner-secret + namespace: forgejo-runner +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: forgejo-runner + name: forgejo-runner + namespace: forgejo-runner +spec: + replicas: 2 + selector: + matchLabels: + app: forgejo-runner + template: + metadata: + labels: + app: forgejo-runner + spec: + restartPolicy: Always + volumes: + - name: runner-data + emptyDir: {} + initContainers: + - name: runner-register + image: code.forgejo.org/forgejo/runner:6.3.1 + command: + - forgejo-runner + - register + - --no-interactive + - --instance + - $(FORGEJO_INSTANCE_URL) + - --token + - $(RUNNER_SECRET) + - --labels + - docker-dind # replace with your runner name + env: + - name: RUNNER_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: RUNNER_SECRET + valueFrom: + secretKeyRef: + name: runner-secret + key: token + - name: FORGEJO_INSTANCE_URL + value: https://professional-service.git.onstackit.cloud/ # replace with your git instance + volumeMounts: + - name: runner-data + mountPath: /data + + containers: + - name: runner + image: code.forgejo.org/forgejo/runner:6.3.1 + command: + - sh + - -c + - | + echo "Waiting for Docker daemon..." + while ! nc -z localhost 2375 /data/config.yml + sed -i -e "s|privileged: .*|privileged: true|" /data/config.yml + exec forgejo-runner -c /data/config.yml daemon + env: + - name: DOCKER_HOST + value: tcp://localhost:2375 + securityContext: + privileged: true + runAsUser: 0 + volumeMounts: + - name: runner-data + mountPath: /data + + - name: daemon + image: docker:27.0.1-dind + command: + - dockerd + - -H + - tcp://0.0.0.0:2375 + - --tls=false + securityContext: + privileged: true \ No newline at end of file