Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 22 additions & 39 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -135,59 +136,41 @@ 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
TOKEN=$$(curl -s \
-X POST \
-u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD \
-H "Content-Type: application/json" \
-d "{\"name\":\"bootstrap\"}" \
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
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:
Expand Down
31 changes: 31 additions & 0 deletions resources/gogs/app.ini
Original file line number Diff line number Diff line change
@@ -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 = aRandomString
LOCAL_NETWORK_ALLOWLIST = *

[webhook]
DELIVER_TIMEOUT = 10
SKIP_TLS_VERIFY = true

[log]
MODE = file
LEVEL = Info
ROOT_PATH = /data/gogs/log
5 changes: 0 additions & 5 deletions tests/VCS/Adapter/GogsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---

Expand Down