Files
gitea/README.md
T
jason 958439b9ee 🐛 Fix DATABASE_DIR_SQLITE override; 📝 correct docker run example 🐛
DATABASE_DIR fix:
The previous override hardcoded $DATA_DIR/db/sqlite, ignoring
DATABASE_DIR_SQLITE when it was explicitly set via env var. Changed
to respect DATABASE_DIR_SQLITE and only fall back to $DATA_DIR/db/sqlite
when the env var is not provided.
README:
- docker run and compose examples updated to match actual working flags:
--cgroupns private, --tty, --cap-add CHOWN/SYS_TIME/SYS_ADMIN,
--hostname FQDN, --domainname, GITEA_PROTO, DATABASE_DIR_SQLITE
with a separate sqlite volume mount
- Removed non-functional vars from examples (CONTAINER_PROTOCOL,
CONTAINER_DEFAULT_DATABASE_TYPE, DATABASE_BASE_DIR, WEB_PORT)
- Added DATABASE_DIR_SQLITE to the database env var table
- rootfs/usr/local/etc/docker/init.d/08-gitea.sh: respect DATABASE_DIR_SQLITE env var
- README.md: fix docker run/compose examples, add DATABASE_DIR_SQLITE to table

README.md
rootfs/usr/local/etc/docker/init.d/08-gitea.sh
2026-06-05 13:41:26 -04:00

6.2 KiB

gitea

A self-hosted Docker image for Gitea — a lightweight, fast Git hosting service — bundled with the Gitea Actions runner (act_runner) and Docker-in-Docker support so CI pipelines run out of the box.


🐳 Docker

Quick start

docker run -d \
  --name casjaysdevdocker-gitea-latest \
  --privileged \
  --restart always \
  --tty \
  --cgroupns private \
  --hostname git.example.com \
  --domainname example.com \
  --network bridge \
  --cap-add CHOWN \
  --cap-add SYS_TIME \
  --cap-add SYS_ADMIN \
  -e TZ=America/New_York \
  -e HOSTNAME=git.example.com \
  -e GITEA_PROTO=http \
  -e DATABASE_DIR_SQLITE=/data/db/sqlite \
  -v /srv/docker/gitea/data:/data:z \
  -v /srv/docker/gitea/config:/config:z \
  -v /srv/docker/databases/sqlite/gitea:/data/db/sqlite:z \
  -p 80:80 \
  -p 22:22 \
  casjaysdevdocker/gitea:latest

via docker compose

services:
  gitea:
    image: casjaysdevdocker/gitea:latest
    container_name: casjaysdevdocker-gitea-latest
    hostname: git.example.com
    domainname: example.com
    privileged: true
    tty: true
    restart: always
    cap_add:
      - CHOWN
      - SYS_TIME
      - SYS_ADMIN
    environment:
      - TZ=America/New_York
      - HOSTNAME=git.example.com
      - GITEA_PROTO=http
      - DATABASE_DIR_SQLITE=/data/db/sqlite
    volumes:
      - /srv/docker/gitea/data:/data:z
      - /srv/docker/gitea/config:/config:z
      - /srv/docker/databases/sqlite/gitea:/data/db/sqlite:z
    ports:
      - 80:80
      - 22:22

Environment variables

General

Variable Default Description
TZ America/New_York Timezone
DEBUGGER (empty) Set to on to enable shell-level debug tracing

Server / domain

Variable Default Description
GITEA_SERVER hostname -f Public FQDN — sets ROOT_URL, DOMAIN, SSH_DOMAIN, and all email addresses. Always set this in production.
GITEA_HOSTNAME (empty) Alias for GITEA_SERVER
FULL_DOMAIN_NAME (empty) Fallback FQDN used when neither GITEA_SERVER nor GITEA_HOSTNAME is set
DOMAIN (empty) Overrides the domain used in email addresses (takes precedence over GITEA_SERVER)
GITEA_PROTO http Protocol used in ROOT_URL (http or https)
GITEA_PORT 80 Internal port Gitea listens on
GITEA_NAME SelfHosted GIT Server Site title shown in the UI
GITEA_TZ $TZ Override timezone for Gitea specifically
GITEA_WORK_DIR /data/gitea Override Gitea's work path

Users

Variable Default Description
GITEA_ROOT_USER_NAME (empty) Initial admin account username (created on first run)
GITEA_ROOT_PASS_WORD (empty) Initial admin account password
GITEA_USER_NAME (empty) Initial normal user username
GITEA_USER_PASS_WORD (empty) Initial normal user password

Mail

Variable Default Description
GITEA_ADMIN administrator@<GITEA_SERVER> Admin contact / mailer FROM address
GITEA_EMAIL_RELAY 172.17.0.1 SMTP relay host
GITEA_EMAIL_CONFIRM false Set to yes to require email confirmation and enable the mailer

Database

Variable Default Description
GITEA_SQL_TYPE sqlite3 Database type (sqlite3, mysql, postgres)
GITEA_SQL_HOST localhost Database host (external DB only)
GITEA_SQL_DB_HOST $GITEA_SQL_HOST Alternate database host variable
GITEA_SQL_USER (empty) Database user (external DB only)
GITEA_SQL_PASS (empty) Database password (external DB only)
GITEA_SQL_NAME (empty) Database name (external DB only)
DATABASE_DIR_SQLITE $DATA_DIR/db/sqlite Override the SQLite database directory (mount a separate volume here to keep the DB outside /data)

act_runner

Variable Default Description
RUNNERS_START 5 Number of act_runner instances to register
RUNNER_CACHE_PORT 44015 Port for the act_runner cache server
RUNNER_IP_ADDRESS container IP IP address act_runner registers with Gitea
RUNNER_DEFAULT_HOME /config/act_runner/gitea Directory where runner registration state is stored
RUNNER_CONFIG_NAME act_runner.yaml Runner config filename inside RUNNER_DEFAULT_HOME
ACT_RUNNER_FALLBACK_VERSION v1.0.8 Pinned act_runner version used if gitea.com is unreachable during build

Volumes

Path Purpose
/data Repositories, SQLite database, LFS objects, attachments, indexes
/config app.ini, SSH host keys, act_runner config — persisted across container restarts

Ports

Port Protocol Purpose
80 TCP Gitea web UI and API
22 TCP Git over SSH

Notes

  • --privileged is required for Docker-in-Docker (act_runner runs CI jobs inside containers).
  • The container ships its own /etc/resolv.conf (Cloudflare + Google DNS, no search domain) so DNS resolution inside the container is not affected by the host's search domain configuration.
  • GITEA_SERVER must be set for a production deployment — without it, ROOT_URL, SSH clone URLs, and all system email addresses fall back to the container's short hostname.
  • The mailer is disabled by default. Set GITEA_EMAIL_CONFIRM=yes to enable it along with the SMTP relay.
  • SQLite is the default database. For external MySQL/Postgres set GITEA_SQL_TYPE, GITEA_SQL_HOST, GITEA_SQL_USER, GITEA_SQL_PASS, and GITEA_SQL_NAME.

🛠️ Development

Prerequisites

  • Docker with buildx
  • bash, git

Build from source

git clone https://github.com/casjaysdevdocker/gitea "$HOME/Projects/github/casjaysdevdocker/gitea"
cd "$HOME/Projects/github/casjaysdevdocker/gitea"
buildx

Install via dockermgr

sudo bash -c "$(curl -q -LSsf https://github.com/systemmgr/installer/raw/main/install.sh)"
sudo systemmgr --config && sudo systemmgr install scripts
dockermgr update gitea

📄 License

MIT — see LICENSE.md