version: "2"
services:
  server:
    build:
      context: .
      dockerfile: server.Dockerfile
    networks:
      - mdb
      - sig
    ports:
      - "8080"
      - "4443:4443"
    entrypoint: /usr/bin/env sh
    command: -c "./migrations/migrate.sh && notary-server -config=fixtures/server-config.postgres.json"
    environment:
      MIGRATIONS_PATH: migrations/server/postgresql
      DB_URL: postgres://server@postgresql:5432/notaryserver?sslmode=verify-ca&sslrootcert=/go/src/github.com/theupdateframework/notary/fixtures/database/ca.pem&sslcert=/go/src/github.com/theupdateframework/notary/fixtures/database/notary-server.pem&sslkey=/go/src/github.com/theupdateframework/notary/fixtures/database/notary-server-key.pem
    depends_on:
      - postgresql
      - signer
  signer:
    build:
      context: .
      dockerfile: signer.Dockerfile
    networks:
      mdb:
      sig:
        aliases:
          - notarysigner
    entrypoint: /usr/bin/env sh
    command: -c "./migrations/migrate.sh && notary-signer -config=fixtures/signer-config.postgres.json"
    environment:
      MIGRATIONS_PATH: migrations/signer/postgresql
      DB_URL: postgres://signer@postgresql:5432/notarysigner?sslmode=verify-ca&sslrootcert=/go/src/github.com/theupdateframework/notary/fixtures/database/ca.pem&sslcert=/go/src/github.com/theupdateframework/notary/fixtures/database/notary-signer.pem&sslkey=/go/src/github.com/theupdateframework/notary/fixtures/database/notary-signer-key.pem
    depends_on:
      - postgresql
  postgresql:
    image: postgres:9.5.4
    networks:
      - mdb
    volumes:
      - ./notarysql/postgresql-initdb.d:/docker-entrypoint-initdb.d
      - notary_data:/var/lib/postgresql
    ports:
      - 5432:5432
    command: -l
volumes:
  notary_data:
    external: false
networks:
  mdb:
    external: false
  sig:
    external: false
