system-config/playbooks/roles/gitea/templates/docker-compose.yaml.j2
Clark Boylan 67662bb735 Run gitea with memcached cache adapter
By default gitea caches everything in memory using a Go hashmap. There
is suspicion that the now many persistent AI web crawlers cause this
hashmap to grow in ways that eventually cause the Go GC system to pause
the world in noticeable ways when loading pages. Restarting the gitea
services seems to temporarily reset things (as it should with an in
memory map) until we cross some threshold and things become slow again.

The good news is that gitea supports several backends (called adapters)
for the cache. We elect to use memcached because it is relatively
simple and has a FOSS license (unlike redis). The other alternative we
could consider is twoqueue which also caches within memory in the Go
runtime but allows for setting a size limit. I've gone with memcached
because it doesn't rely on Golang GC, but twoqueue is likely simpler if
we want to start there.

Note we also bump the job timeout to 5400 seconds (90 minutes) from 4800
seconds (80 minutes) because a run on ovh-gra1 timed out while running
testinfra test cases (the very end of the job). It is possible that
using memcache is slightly slower than using in process memory caching,
but the goal here isn't to make things faster it is to make things more
consistent over time. As long as memcached performance is within the
same ballpark and doesn't degrade over time this is acceptable.

Change-Id: Ie9ca246a8321fe84d9a1582e35cd4c5459b48bee
2025-02-28 10:49:27 -08:00

75 lines
1.8 KiB
Django/Jinja

# Version 2 is the latest that is supported by docker-compose in
# Ubuntu Xenial.
version: '2'
services:
mariadb:
image: quay.io/opendevmirror/mariadb:10.11
network_mode: host
restart: always
environment:
MYSQL_ROOT_PASSWORD: "{{ gitea_root_db_password }}"
MYSQL_DATABASE: gitea
MYSQL_USER: "{{ gitea_db_username }}"
MYSQL_PASSWORD: "{{ gitea_db_password }}"
MARIADB_AUTO_UPGRADE: 1
volumes:
- /var/gitea/db:/var/lib/mysql
- /var/gitea/conf/99-max_conn_my.cnf:/etc/mysql/conf.d/99-max_conn_my.cnf:ro
logging:
driver: journald
options:
tag: "docker-mariadb"
memcached:
image: quay.io/opendevmirror/memcached:latest
network_mode: host
restart: always
command:
- -v
- --listen=127.0.0.1:11211
- --memory-limit=1024
logging:
driver: journald
options:
tag: "docker-memcached"
gitea-web:
depends_on:
- mariadb
- memcached
image: docker.io/opendevorg/gitea:latest
network_mode: host
restart: always
environment:
- USER_UID=1000
- USER_GID=1000
ulimits:
stack:
soft: 16777216
hard: 9223372036854775807
volumes:
- /var/gitea/data:/data
- /var/gitea/conf:/custom/conf
- /var/gitea/logs:/logs
- /var/gitea/certs:/certs
logging:
driver: journald
options:
tag: "docker-gitea"
gitea-ssh:
depends_on:
- mariadb
- gitea-web
environment:
- SSH_LISTEN_PORT=222
image: docker.io/opendevorg/gitea-openssh
network_mode: host
restart: always
volumes:
- /var/gitea/data:/data
- /var/gitea/conf:/custom/conf
- /var/gitea/logs:/logs
logging:
driver: journald
options:
tag: "docker-gitea-ssh"