Skip to content

Commit f9b144a

Browse files
authored
Merge pull request #82 from jaysomani/fix/gogs-fixes-2
fix: use pre-written app.ini mount for Gogs webhook support
2 parents 79550c2 + c9f73c1 commit f9b144a

3 files changed

Lines changed: 53 additions & 44 deletions

File tree

docker-compose.yml

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ services:
125125
image: gogs/gogs:0.14
126126
volumes:
127127
- gogs-data:/data
128+
- ./resources/gogs/app.ini:/data/gogs/conf/app.ini
128129
ports:
129130
- "3002:3000"
130131
healthcheck:
@@ -135,59 +136,41 @@ services:
135136
start_period: 15s
136137

137138
gogs-bootstrap:
138-
image: alpine/curl:8.12.1
139+
image: gogs/gogs:0.14
139140
volumes:
140141
- gogs-data:/data
141142
depends_on:
142143
gogs:
143144
condition: service_healthy
145+
entrypoint: /bin/sh
144146
environment:
145147
- GOGS_ADMIN_USERNAME=${GOGS_ADMIN_USERNAME:-utopia}
146148
- GOGS_ADMIN_PASSWORD=${GOGS_ADMIN_PASSWORD:-password}
147149
- GOGS_ADMIN_EMAIL=${GOGS_ADMIN_EMAIL:-utopia@example.com}
148-
entrypoint: /bin/sh
149150
command:
150-
- -ce
151+
- -c
151152
- |
152-
if [ -f /data/gogs/token.txt ]; then exit 0; fi
153-
154-
apk add --no-cache jq
155-
156-
curl -s -o /dev/null -X POST http://gogs:3000/install \
157-
-d db_type=SQLite3 \
158-
-d db_path=/data/gogs.db \
159-
-d app_name=Gogs \
160-
-d repo_root_path=/data/repositories \
161-
-d run_user=git \
162-
-d domain=gogs \
163-
-d http_port=3000 \
164-
-d app_url=http://gogs:3000/ \
165-
-d log_root_path=/data/gogs/log \
166-
-d default_branch=master \
167-
-d admin_name=$$GOGS_ADMIN_USERNAME \
168-
-d admin_passwd=$$GOGS_ADMIN_PASSWORD \
169-
-d admin_confirm_passwd=$$GOGS_ADMIN_PASSWORD \
170-
-d admin_email=$$GOGS_ADMIN_EMAIL \
171-
|| true
153+
USER=git /app/gogs/gogs admin create-user \
154+
--admin \
155+
--name $$GOGS_ADMIN_USERNAME \
156+
--password $$GOGS_ADMIN_PASSWORD \
157+
--email $$GOGS_ADMIN_EMAIL \
158+
--config /data/gogs/conf/app.ini || true
172159
173-
sleep 3
174-
175-
if ! grep -q '\[webhook\]' /data/gogs/conf/app.ini; then
176-
printf '\n[webhook]\nDELIVER_TIMEOUT = 10\nSKIP_TLS_VERIFY = true\n' >> /data/gogs/conf/app.ini
160+
if [ ! -f /data/gogs/token.txt ]; then
161+
sleep 2
162+
TOKEN=$$(curl -s \
163+
-X POST \
164+
-u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD \
165+
-H "Content-Type: application/json" \
166+
-d "{\"name\":\"bootstrap\"}" \
167+
http://gogs:3000/api/v1/users/$$GOGS_ADMIN_USERNAME/tokens \
168+
| grep -o '"sha1":"[^"]*"' | cut -d'"' -f4)
169+
if [ -z "$$TOKEN" ]; then echo "Failed to get token"; exit 1; fi
170+
mkdir -p /data/gogs
171+
echo $$TOKEN > /data/gogs/token.txt
177172
fi
178173
179-
RESPONSE=$$(curl -s -X POST http://gogs:3000/api/v1/users/$$GOGS_ADMIN_USERNAME/tokens \
180-
-H 'Content-Type: application/json' \
181-
-d "{\"name\":\"bootstrap-$$(date +%s)\"}" \
182-
-u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD)
183-
echo "Token API response: $$RESPONSE"
184-
185-
TOKEN=$$(echo "$$RESPONSE" | jq -r '.sha1')
186-
if [ -z "$$TOKEN" ] || [ "$$TOKEN" = "null" ]; then echo 'Failed to extract token'; exit 1; fi
187-
188-
mkdir -p /data/gogs
189-
echo $$TOKEN > /data/gogs/token.txt
190-
191174
volumes:
192175
gitea-data:
193176
forgejo-data:

resources/gogs/app.ini

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
BRAND_NAME = Gogs
2+
RUN_USER = git
3+
RUN_MODE = prod
4+
5+
[database]
6+
TYPE = sqlite3
7+
PATH = /data/gogs.db
8+
9+
[repository]
10+
ROOT = /data/repositories
11+
DEFAULT_BRANCH = master
12+
13+
[server]
14+
DOMAIN = gogs
15+
HTTP_PORT = 3000
16+
EXTERNAL_URL = http://gogs:3000/
17+
DISABLE_SSH = true
18+
19+
[security]
20+
INSTALL_LOCK = true
21+
SECRET_KEY = aRandomString
22+
LOCAL_NETWORK_ALLOWLIST = *
23+
24+
[webhook]
25+
DELIVER_TIMEOUT = 10
26+
SKIP_TLS_VERIFY = true
27+
28+
[log]
29+
MODE = file
30+
LEVEL = Info
31+
ROOT_PATH = /data/gogs/log

tests/VCS/Adapter/GogsTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ protected function setupGogs(): void
6161
}
6262
}
6363

64-
// Webhook delivery (Gogs queues but does not deliver webhooks in test environment)
65-
public function testWebhookPushEvent(): void
66-
{
67-
$this->markTestSkipped('Gogs webhook delivery not working in test environment');
68-
}
6964

7065
// --- Skip tests for unsupported Gogs features ---
7166

0 commit comments

Comments
 (0)