version: "3"

volumes:
  mysql:
    driver: local

services:
  gitbucket:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        GITBUCKET_HOME: /mnt/gitbucket
    container_name: gitbucket_server
    restart: always
    ports:
      - ${HTTP_PORT}:8080
      - ${HTTPS_PORT}:8443
      # Optional for SSH:
      - ${SSH_PORT}:29418
    depends_on:
      mariadb:
        condition: service_healthy
    environment:
      - JAVA_OPTS=-Dcom.sun.net.ssl.checkRevocation=false -Dcom.sun.security.enableAIAcaIssuers=true -Docsp.enable=fase -Dtrust_all_cert=true -Djdk.tls.client.protocols=TLSv1.2 -Dcom.sun.net.ssl.enableECC=false
      - GITBUCKET_HOME=/mnt/gitbucket
      - GITBUCKET_CONNECTORS=http
      - GITBUCKET_HOST=0.0.0.0
      - GITBUCKET_PORT=8080
      - GITBUCKET_SECUREPORT=8443
      - GITBUCKET_REDIRECTHTTPS=false
      - GITBUCKET_PREFIX=/
      - GITBUCKET_MAXFILESIZE=4294967296
      - GITBUCKET_UPLOADTIMEOUT=120000
      - GITBUCKET_JETTYIDLETIMEOUT=600000
      - GITBUCKET_DB_URL=jdbc:mariadb://mariadb/gitbucket?useUnicode=true&characterEncoding=utf8
      - GITBUCKET_DB_USER=gitbucket
      - GITBUCKET_DB_PASSWORD=gitbucket
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - ../disks/disk1/gitbucket_data/repositories/:/mnt/gitbucket/repositories/
      - ../disks/disk1/gitbucket_data/data/:/mnt/gitbucket/data/
      - ../disks/disk1/gitbucket_data/gist/:/mnt/gitbucket/gist/
      - ../disks/disk1/gitbucket_data/plugins/:/mnt/gitbucket/plugins/

  mariadb:
    image: mariadb:10.6
    container_name: gitbucket_mariadb
    restart: always
    ports:
      - ${DB_PORT}:3306
    environment:
      - MYSQL_ROOT_PASSWORD=gitbucket
      - MYSQL_USER=gitbucket
      - MYSQL_PASSWORD=gitbucket
      - MYSQL_DATABASE=gitbucket
    command: ["--max-allowed-packet=128M", "--innodb-log-file-size=64M"]
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=gitbucket"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - mysql:/var/lib/mysql