version: '3'

services:
  application:
    logging:
      driver: journald
    restart: always
    image: gitea/gitea:latest
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=database:3306
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD={{gitea_database_password}}
      - SSH_PORT={{ssh_port}}
      - SSH_LISTEN_PORT=22
      - DOMAIN={{domain}}
      - SSH_DOMAIN={{domain}}
      - RUN_MODE="{{run_mode}}"
      - ROOT_URL="https://{{domain}}/"
    ports:
      - "127.0.0.1:{{http_port}}:3000"
      - "{{ssh_port}}:22"
    links:
      - database
    volumes:
      - data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      - database
  database:
    logging:
      driver: journald
    image: mariadb
    restart: always
    environment:
      MYSQL_DATABASE: "gitea"
      MYSQL_USER: "gitea"
      MYSQL_PASSWORD: "{{gitea_database_password}}"
      MYSQL_ROOT_PASSWORD: "{{gitea_database_password}}"
      MARIADB_AUTO_UPGRADE: "1"
    volumes:
      - database:/var/lib/mysql
    healthcheck:
      test: "/usr/bin/mariadb --user=gitea --password={{gitea_database_password}} --execute \"SHOW DATABASES;\""
      interval: 3s
      timeout: 1s
      retries: 5
volumes:
  database:
  data:
networks:
  default:
    driver: bridge