version: "3.7"
services:
  mariadb:
    hostname: mariadb
    container_name: gitea-db
    image: linuxserver/mariadb:latest
    env_file:
      - .env
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${DATABASE_NAME}
      MYSQL_USER: ${DATABASE_USER}
      MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      PUID: ${USER_UID}
      PGID: ${USER_GID}
      TZ: ${TZ}
    networks:
      - gitea
    restart: unless-stopped
    volumes:
      - /data/misc/gitea/db:/config

  gitea:
    container_name: gitea
    hostname: gitea
    image: gitea/gitea:latest
    env_file:
      - .env
    environment:
      USER_UID: ${USER_UID}
      USER_GID: ${USER_GID}
      TZ: ${TZ}
      GITEA__database__HOST: 'mariadb'
      GITEA__database__USER: ${DATABASE_USER}
      GITEA__database__PASSWD: ${DATABASE_PASSWORD}
      GITEA__database__NAME: ${DATABASE_NAME}
      GITEA__database__DB_TYPE: mysql
    networks:
      - gitea
      - reverseproxy
    ports:
      - 8124:3000
      - 222:22
    restart: unless-stopped
    volumes:
      - /data/misc/gitea/data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      - mariadb

networks:
  gitea:
    name: gitea
  reverseproxy:
    external: true
