services:
  fdroid-buildserver:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: fdroid-buildserver
    entrypoint: ["/bin/bash"]
    stdin_open: true   # equivalent to -i
    tty: true          # equivalent to -t
    # Run as vagrant user (UID 1000, GID 1000)
    user: "1000:1000"
    volumes:
      # Overwrite the net.aliasvault.app.yml file with the local one which forces build to use latest com>
      - ./net.aliasvault.app.yml:/net.aliasvault.app.yml
      # Add build script to the container
      - ./scripts/build.sh:/build.sh:Z
      # Bind the outputs directory to capture APK build output
      - ./outputs:/outputs:rw
    # Increase memory limits for Gradle builds
    shm_size: '2gb'
    mem_limit: 12g
    memswap_limit: 12g
    cpus: 4
    environment:
      - GRADLE_OPTS=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError
      - JAVA_OPTS=-Xmx4g -XX:MaxMetaspaceSize=1g
    restart: "no"
