x-defaults: &defaults
  restart: unless-stopped
  logging:
    driver: json-file
    options:
      max-size: 100m
      max-file: '3'

services:
  gitlab:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}gitlab/gitlab-ce:${GITLAB_VERSION:-18.8.3-ce.0}
    ports:
      - '${GITLAB_PORT_OVERRIDE_HTTPS:-5443}:443'
      - '${GITLAB_PORT_OVERRIDE_HTTP:-5080}:80'
      - '${GITLAB_PORT_OVERRIDE_SSH:-5022}:22'
    volumes:
      - ./config:/etc/gitlab
      - gitlab_logs:/var/log/gitlab
      - gitlab_data:/var/opt/gitlab
    environment:
      - TZ=${TZ:-UTC}
      - GITLAB_OMNIBUS_CONFIG=${GITLAB_OMNIBUS_CONFIG:-}
    deploy:
      resources:
        limits:
          cpus: ${GITLAB_CPU_LIMIT:-2.0}
          memory: ${GITLAB_MEMORY_LIMIT:-8G}
        reservations:
          cpus: ${GITLAB_CPU_RESERVATION:-0.1}
          memory: ${GITLAB_MEMORY_RESERVATION:-4G}
    healthcheck:
      test: [CMD, /opt/gitlab/bin/gitlab-healthcheck, --fail]
      interval: 60s
      timeout: 30s
      retries: 5
      start_period: 300s

volumes:
  gitlab_logs:
  gitlab_data:
