---
author: The Bunker Admin
date: 2025 05 03
tags: [sript]
---
## build.gittea

Getting used to using gittea with my next changemaker deployment. 

See[[ config.gittea]] for configuration details. 
See [[config.cloudflare.homelab]] for more on getting system online. 

---
## Docker Compose 
The following docker compose is to get gittea up and running with Cloudflare:  

> [!check] Remember to update with your own strong passwords and to update URL's for your own domain

```
version: "3"

networks:
  gitea:
    external: false

volumes:
  gitea_data:
    driver: local
  mysql_data:
    driver: local

services:
  server:
    image: docker.gitea.com/gitea:1.23.7
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=mysql
      - GITEA__database__HOST=db:3306
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=[insert password 1]
      # Cloudflare Tunnel configuration
      - GITEA__server__ROOT_URL=https://gitea.bnkhome.org
      # Set the HTTP port explicitly
      - GITEA__server__HTTP_PORT=3000
      # Add proxy settings for Cloudflare
      - GITEA__server__PROTOCOL=http
      - GITEA__server__DOMAIN=gitea.bnkhome.org
      - GITEA__server__ENABLE_GZIP=true
      - GITEA__server__PROXY_PROTOCOL=true
      - GITEA__server__PROXY_PROXY_PROTOCOL_TLS=true
      - GITEA__server__PROXY_ALLOW_SUBNET=0.0.0.0/0
    restart: always
    networks:
      - gitea
    volumes:
      - gitea_data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      # Expose on all interfaces, not just localhost, so Cloudflare can reach it
      - "3001:3000"
      # Also expose SSH on all interfaces if needed
      - "2222:22"
    depends_on:
      - db

  db:
    image: docker.io/library/mysql:8
    container_name: gitea_mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=[instert password]
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=[insert password 1]
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
      - mysql_data:/var/lib/mysql
    # MySQL is only accessible within the Docker network, not exposed to host
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "gitea", "-pgitea"]
      interval: 10s
      timeout: 5s
      retries: 5
```


