version: '2'

networks:
  puppet:

services:
  puppet:
    container_name: puppet
    hostname: puppet4.psd401.net
    image: puppet/puppetserver:latest
    ports:
      - 0.0.0.0:8140:8140
    volumes:
      - ./code:/etc/puppetlabs/code/
      - ./conf:/etc/puppetlabs/puppet/
    environment:
      - PUPPETDB_SERVER_URLS=https://puppetdb.peninsula.wednet.edu:8081
      - PUPPETSERVER_JAVA_ARGS=-Xms2048m -Xmx2048m
    networks:
      - puppet
    extra_hosts:
      - "puppetdb.peninsula.wednet.edu:172.19.0.4"
    restart: always
    
  
  puppetdbpostgres:
    container_name: postgres
    image: puppet/puppetdb-postgres:latest
    environment:
      - POSTGRES_PASSWORD=blank
      - POSTGRES_USER=puppetdb
    expose:
      - 5432
    ports:
      - 5433:5432
    volumes:
      - ./puppetdb-postgres/data:/var/lib/postgresql/data/
    networks:
      - puppet
    restart: always
  
  puppetdb:
    container_name: puppet_db
    hostname: puppetdb.peninsula.wednet.edu
    dns:
      - 10.0.0.7
    image: puppet/puppetdb:latest
    ports:
      - 8087:8080
      - 8088:8081
    depends_on:
      - puppet
    links:
      - puppet:puppet4.psd401.net
      - puppetdbpostgres:postgres
    volumes:
      - ./puppet-client.conf:/etc/puppetlabs/puppet/puppet.conf
      - ./puppetdb_conf:/etc/puppetlabs/puppetdb/conf.d
      - ./puppetdb_ssl:/etc/puppetlabs/puppet/ssl/
    networks:
      puppet:
        ipv4_address: 172.19.0.4
    restart: always
  
  puppetboard:
    container_name: puppetboard
    image: puppet/puppetboard:latest
    ports:
      - 8058:8000
    links:
      - puppet:puppet
      - puppetdb:puppetdb.peninsula.wednet.edu
    networks:
      - puppet
    environment:
      - PUPPETDB_HOST:puppetdb.peninsula.wednet.edu
    restart: always
  
  puppetexplorer:
    container_name: puppetexplorer
    image: puppet/puppetexplorer:latest
    ports:
      - 8059:80
    read_only: true
    links:
      - puppet:puppet
      - puppetdb:puppetdb
    networks:
      - puppet
    volumes:
      - "./puppetexplorer_conf/config.js:/puppetexplorer/config.js"
      - "./puppetexplorer_conf/Caddyfile:/etc/caddy/Caddyfile"
    extra_hosts:
      - "puppetdb.peninsula.wednet.edu:172.19.0.4"
    restart: always
