version: '3.6'
#based on https://github.com/puppetlabs/pupperware/blob/master/docker-compose.yml
services:
  puppet:
    hostname: puppet
    image: ${DOCKER_REGISTRY:-dockerregistry.artix.su:2443}/puppet-artixmod
    logging:
      driver: "json-file"
      options:
        max-file: "2"
        max-size: "50m"
    restart: always
    ports:
      - 8140:8140
      - 8072:8072
      - 8073:8073
    environment:
      # DNS_ALT_NAMES must be set before starting the stack the first time,
      # and must list all the names under which the puppetserver can be
      # reached. 'puppet' must be one of them, otherwise puppetdb won't be
      # able to get a cert. Add other names as a comma-separated list
      - DNS_ALT_NAMES=puppet,${DNS_ALT_NAMES:-}
      - PUPPETDB_SERVER_URLS=https://puppetdb:8081
      - PUPPETSERVER_JAVA_ARGS=-Duser.timezone=${SET_TIMEZONE:-UTC} -Xms512m -Xmx512m
      - AUTOSIGN="true"
      - CS_SERVER_PORT=${CS_SERVER_PORT:-8080}
      - CS_SERVER_HOST=${CS_SERVER_HOST:-cs}
    volumes:
      - puppet_code:/etc/puppetlabs/code/
      - puppet_config:/etc/puppetlabs/puppet/
      - puppet_data:/opt/puppetlabs/server/data/puppetserver/

  rsync_puppet:
    image: ${DOCKER_REGISTRY:-dockerregistry.artix.su:2443}/rsync-artixmod
    logging:
      driver: "json-file"
      options:
        max-file: "2"
        max-size: "50m"
    hostname: rsync_puppet
    restart: always
    ports:
      - 45873:873
    environment:
      - USERNAME=rsync
      - ALLOW=*
      - PASSWORD=password
    volumes:
      - puppet_code:/data/

  postgres:
    image: ${DOCKER_REGISTRY:-dockerregistry.artix.su:2443}/postgres:9.6.13-local
    logging:
      driver: "json-file"
      options:
        max-file: "2"
        max-size: "50m"
    restart: always
    volumes:
      - puppetdb-postgres:/var/lib/postgresql/data/
    environment:
      - POSTGRES_PASSWORD=puppetdb
      - POSTGRES_USER=puppetdb
      - POSTGRES_DB=puppetdb
    expose:
      - 5432

  puppetdb:
    hostname: puppetdb
    restart: always
    image: ${DOCKER_REGISTRY:-dockerregistry.artix.su:2443}/puppet/puppetdb:6.2.0-local
    logging:
      driver: "json-file"
      options:
        max-file: "2"
        max-size: "50m"
    environment:
      - PUPPETDB_PASSWORD=puppetdb
      - PUPPETDB_USER=puppetdb
      - PUPPERWARE_DISABLE_ANALYTICS=true
    ports:
      - 8081
    depends_on:
      - postgres
      - puppet
    volumes:
      - puppetdb_ssl:/etc/puppetlabs/puppet/ssl/


volumes:
  puppetdb_ssl:
  puppet_code:
  puppet_config:
  puppet_data:
  puppetdb-postgres:

networks:
  default:
