From e39b5a9860e740f623d18a5f855fd8970f23453a Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 24 Mar 2026 15:24:12 +0530 Subject: [PATCH 1/4] fix: use pre-written app.ini mount for Gogs webhook support --- docker-compose.yml | 1 + resources/gogs/app.ini | 31 +++++++++++++++++++++++++++++++ tests/VCS/Adapter/GogsTest.php | 5 ----- 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 resources/gogs/app.ini diff --git a/docker-compose.yml b/docker-compose.yml index c9de843a..95b07470 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -125,6 +125,7 @@ services: image: gogs/gogs:0.14 volumes: - gogs-data:/data + - ./resources/gogs/app.ini:/data/gogs/conf/app.ini ports: - "3002:3000" healthcheck: diff --git a/resources/gogs/app.ini b/resources/gogs/app.ini new file mode 100644 index 00000000..2041e581 --- /dev/null +++ b/resources/gogs/app.ini @@ -0,0 +1,31 @@ +BRAND_NAME = Gogs +RUN_USER = git +RUN_MODE = prod + +[database] +TYPE = sqlite3 +PATH = /data/gogs.db + +[repository] +ROOT = /data/repositories +DEFAULT_BRANCH = master + +[server] +DOMAIN = gogs +HTTP_PORT = 3000 +EXTERNAL_URL = http://gogs:3000/ +DISABLE_SSH = true + +[security] +INSTALL_LOCK = true +SECRET_KEY = changeThisToARandomString +LOCAL_NETWORK_ALLOWLIST = * + +[webhook] +DELIVER_TIMEOUT = 10 +SKIP_TLS_VERIFY = true + +[log] +MODE = file +LEVEL = Info +ROOT_PATH = /data/gogs/log \ No newline at end of file diff --git a/tests/VCS/Adapter/GogsTest.php b/tests/VCS/Adapter/GogsTest.php index 2f79cf2f..fe291fa5 100644 --- a/tests/VCS/Adapter/GogsTest.php +++ b/tests/VCS/Adapter/GogsTest.php @@ -61,11 +61,6 @@ protected function setupGogs(): void } } - // Webhook delivery (Gogs queues but does not deliver webhooks in test environment) - public function testWebhookPushEvent(): void - { - $this->markTestSkipped('Gogs webhook delivery not working in test environment'); - } // --- Skip tests for unsupported Gogs features --- From b0e4d0c48aa152f73d5cc01862729d99215fb5bd Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 24 Mar 2026 15:41:40 +0530 Subject: [PATCH 2/4] updated with suggestions --- docker-compose.yml | 59 ++++++++++++++---------------------------- resources/gogs/app.ini | 2 +- 2 files changed, 21 insertions(+), 40 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 95b07470..e1fd8a28 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -136,59 +136,40 @@ services: start_period: 15s gogs-bootstrap: - image: alpine/curl:8.12.1 + image: gogs/gogs:0.14 volumes: - gogs-data:/data depends_on: gogs: condition: service_healthy + entrypoint: /bin/sh environment: - GOGS_ADMIN_USERNAME=${GOGS_ADMIN_USERNAME:-utopia} - GOGS_ADMIN_PASSWORD=${GOGS_ADMIN_PASSWORD:-password} - GOGS_ADMIN_EMAIL=${GOGS_ADMIN_EMAIL:-utopia@example.com} - entrypoint: /bin/sh command: - - -ce + - -c - | - if [ -f /data/gogs/token.txt ]; then exit 0; fi - - apk add --no-cache jq - - curl -s -o /dev/null -X POST http://gogs:3000/install \ - -d db_type=SQLite3 \ - -d db_path=/data/gogs.db \ - -d app_name=Gogs \ - -d repo_root_path=/data/repositories \ - -d run_user=git \ - -d domain=gogs \ - -d http_port=3000 \ - -d app_url=http://gogs:3000/ \ - -d log_root_path=/data/gogs/log \ - -d default_branch=master \ - -d admin_name=$$GOGS_ADMIN_USERNAME \ - -d admin_passwd=$$GOGS_ADMIN_PASSWORD \ - -d admin_confirm_passwd=$$GOGS_ADMIN_PASSWORD \ - -d admin_email=$$GOGS_ADMIN_EMAIL \ - || true + USER=git /app/gogs/gogs admin create-user \ + --admin \ + --name $$GOGS_ADMIN_USERNAME \ + --password $$GOGS_ADMIN_PASSWORD \ + --email $$GOGS_ADMIN_EMAIL \ + --config /data/gogs/conf/app.ini || true - sleep 3 - - if ! grep -q '\[webhook\]' /data/gogs/conf/app.ini; then - printf '\n[webhook]\nDELIVER_TIMEOUT = 10\nSKIP_TLS_VERIFY = true\n' >> /data/gogs/conf/app.ini + if [ ! -f /data/gogs/token.txt ]; then + sleep 2 + RESPONSE=$$(curl -s -X POST http://gogs:3000/api/v1/users/$$GOGS_ADMIN_USERNAME/tokens \ + -H "Content-Type: application/json" \ + -d "{\"name\":\"bootstrap\"}" \ + -u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD) + echo "Token response: $$RESPONSE" + TOKEN=$$(echo "$$RESPONSE" | grep -o '"sha1":"[^"]*"' | cut -d'"' -f4) + if [ -z "$$TOKEN" ]; then echo "Failed to get token"; exit 1; fi + mkdir -p /data/gogs + echo $$TOKEN > /data/gogs/token.txt fi - RESPONSE=$$(curl -s -X POST http://gogs:3000/api/v1/users/$$GOGS_ADMIN_USERNAME/tokens \ - -H 'Content-Type: application/json' \ - -d "{\"name\":\"bootstrap-$$(date +%s)\"}" \ - -u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD) - echo "Token API response: $$RESPONSE" - - TOKEN=$$(echo "$$RESPONSE" | jq -r '.sha1') - if [ -z "$$TOKEN" ] || [ "$$TOKEN" = "null" ]; then echo 'Failed to extract token'; exit 1; fi - - mkdir -p /data/gogs - echo $$TOKEN > /data/gogs/token.txt - volumes: gitea-data: forgejo-data: diff --git a/resources/gogs/app.ini b/resources/gogs/app.ini index 2041e581..eb99ff4e 100644 --- a/resources/gogs/app.ini +++ b/resources/gogs/app.ini @@ -28,4 +28,4 @@ SKIP_TLS_VERIFY = true [log] MODE = file LEVEL = Info -ROOT_PATH = /data/gogs/log \ No newline at end of file +ROOT_PATH = /data/gogs/log From 7c9a22fb6833669f502d4e398d233e0a30c9287d Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 24 Mar 2026 15:58:50 +0530 Subject: [PATCH 3/4] updated with suggestions-2 --- docker-compose.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e1fd8a28..fc488878 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -159,12 +159,13 @@ services: if [ ! -f /data/gogs/token.txt ]; then sleep 2 - RESPONSE=$$(curl -s -X POST http://gogs:3000/api/v1/users/$$GOGS_ADMIN_USERNAME/tokens \ + TOKEN=$$(curl -s \ + -X POST \ + -u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD \ -H "Content-Type: application/json" \ -d "{\"name\":\"bootstrap\"}" \ - -u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD) - echo "Token response: $$RESPONSE" - TOKEN=$$(echo "$$RESPONSE" | grep -o '"sha1":"[^"]*"' | cut -d'"' -f4) + http://gogs:3000/api/v1/users/$$GOGS_ADMIN_USERNAME/tokens \ + | grep -o '"sha1":"[^"]*"' | cut -d'"' -f4) if [ -z "$$TOKEN" ]; then echo "Failed to get token"; exit 1; fi mkdir -p /data/gogs echo $$TOKEN > /data/gogs/token.txt From c9f73c1053ecd4eb3e0638038cf88eedc3cb13ab Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 24 Mar 2026 16:05:36 +0530 Subject: [PATCH 4/4] updated with random string --- resources/gogs/app.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/gogs/app.ini b/resources/gogs/app.ini index eb99ff4e..84455215 100644 --- a/resources/gogs/app.ini +++ b/resources/gogs/app.ini @@ -18,7 +18,7 @@ DISABLE_SSH = true [security] INSTALL_LOCK = true -SECRET_KEY = changeThisToARandomString +SECRET_KEY = aRandomString LOCAL_NETWORK_ALLOWLIST = * [webhook]