2.5 KiB
2.5 KiB
Gitea Docker Setup (Traefik + Existing Postgres + Actions Runner)
This project deploys:
giteabehind your existing Traefik reverse proxygitea-runnerfor CI/CD (Gitea Actions)- connection to your already running Postgres in the shared Docker network
What this is built for
- Existing stack already provides:
- Traefik with Let's Encrypt
- Postgres service named
postgres - shared Docker network via
${SHARED_NETWORK_NAME}
- Gitea should be reachable at subdomain
git(for examplegit.example.com)
Files
docker-compose.yml: Gitea + Actions runner stack.env.example: required environment variables
1) Prepare environment
cp .env.example .env
Edit .env and set:
SHARED_NETWORK_NAMEto the same network name used by your main stackGITEA_DOMAINto your git subdomain (for examplegit.example.com)- Postgres credentials for a dedicated Gitea database/user
2) Create Postgres DB/User (on your existing DB)
If not already present, create dedicated credentials for Gitea in your existing Postgres:
CREATE USER gitea WITH PASSWORD 'change-me';
CREATE DATABASE gitea OWNER gitea;
GRANT ALL PRIVILEGES ON DATABASE gitea TO gitea;
Use your own secure password and update .env.
3) DNS
Create an A/AAAA record for:
git.<your-domain>-> your server IP
4) Start services
docker compose up -d
5) Create the first admin user
Run the CLI inside the container as the non-root git user:
docker exec -u git -it gitea gitea admin user create \
--username youradmin \
--password 'StrongPasswordHere' \
--email you@example.com \
--admin \
--must-change-password=false
Public sign-up is disabled by default in this stack (GITEA__service__DISABLE_REGISTRATION=true).
6) Runner registration token
- Open
https://<your-gitea-domain> - Login as admin
- Go to:
- Site level:
Administration -> Actions -> Runners - or Org/Repo level:
Settings -> Actions -> Runners
- Site level:
- Generate registration token
- Put token into
.envasGITEA_RUNNER_REGISTRATION_TOKEN - Restart runner:
docker compose up -d gitea-runner
7) Verify
docker compose ps
docker compose logs -f gitea
docker compose logs -f gitea-runner
Notes
- This setup uses HTTPS via Traefik labels and Let's Encrypt from your existing stack.
- Git over SSH is not enabled in this compose because your current Traefik config only exposes
:80and:443. HTTPS clone/push works directly. - Gitea Actions is enabled (
GITEA__actions__ENABLED=true).