name: jenkins-gerrit-lab

services:
  jenkins:
    build:
      context: .
    image: local/jenkins-gerrit:2.555.1
    restart: unless-stopped
    init: true
    user: "1000:1000"
    environment:
      JAVA_OPTS: >-
        -Xms1g
        -Xmx3g
        -XX:MaxMetaspaceSize=512m
        -XX:+ExitOnOutOfMemoryError
        -XX:+HeapDumpOnOutOfMemoryError
        -XX:HeapDumpPath=/var/jenkins_home/heapdump.hprof
      JENKINS_OPTS: --httpPort=8080
      JENKINS_SLAVE_AGENT_PORT: "-1"
      TZ: Asia/Shanghai
    ports:
      - "${JENKINS_BIND_ADDRESS:-127.0.0.1}:${JENKINS_HTTP_PORT:-8082}:8080"
    volumes:
      - ./data/jenkins_home:/var/jenkins_home
    tmpfs:
      - /tmp:size=1g,mode=1777
    read_only: true
    security_opt:
      - no-new-privileges:true
    cpus: 2.0
    mem_limit: 4g
    stop_grace_period: 120s
    healthcheck:
      test: ["CMD-SHELL", "curl --fail --silent http://localhost:8080/login >/dev/null"]
      interval: 30s
      timeout: 5s
      start_period: 180s
      retries: 10
    logging:
      options:
        max-size: "10m"
        max-file: "3"
