version: "3.7"

services:
  aftok:
    image: aftok/aftok-server:latest
    container_name: aftok-server
    expose:
      - "8000"
    depends_on:
      - aftokdb
    volumes:
      - type: bind
        source: ./local/server/conf
        target: /etc/aftok
        read_only: true
      - type: bind
        source: ./local/server/log
        target: /opt/aftok/log
    networks:
      - front-tier
      - back-tier
    init: true

  aftok-client:
    image: aftok/aftok-client:latest
    container_name: aftok-client
    entrypoint: /opt/aftok/aftok-client-cp.sh dist
    volumes:
      - type: volume
        source: v_aftok-client
        target: /opt/aftok/client/dist-volume

  nginx:
    image: nginx:latest
    container_name: aftok-nginx
    ports:
      - "8080:80"
      - "8443:443"
    depends_on:
      - aftok
    volumes:
      - type: bind
        source: ./local/nginx/conf
        target: /etc/nginx
        read_only: true
      - type: bind
        source: ./local/nginx/certs
        target: /opt/nginx
        read_only: true
      - type: bind
        source: ./local/nginx/log
        target: /var/log/nginx
      - type: bind
        source: ./aftok.com/dist/
        target: /opt/static/site
        read_only: true
      - type: bind
        source: ./client/dist
        target: /opt/static/app
        read_only: true
        # - type: volume
        #   source: v_aftok-client
        #   target: /opt/static/app
        #   read_only: true
    networks:
      - front-tier

  aftokdb:
    image: postgres:9.4
    container_name: aftok-db
    expose:
      - "5432"
    ports:
      - "5432:5432"
    environment:
      POSTGRES_DB: "postgres"
      POSTGRES_USER: "postgres"
      POSTGRES_PASSWORD: "postgres"
    volumes:
      - type: volume
        source: v_aftok-data
        target: /var/lib/postgresql/data
      - type: bind
        source: ./local/postgres/db-dumps
        target: /opt/
        read_only: true
    networks:
      - back-tier

  zcashd:
    image: electriccoinco/zcashd:v4.5.1-1
    container_name: aftok-zcashd
    expose:
      - "18232"
    ports:
      - "18233:18233"
    volumes:
      - type: bind
        source: ./local/zcashd/zcash-data
        target: /srv/zcashd/.zcash
      - type: bind
        source: ./local/zcashd/zcash-params
        target: /srv/zcashd/.zcash-params
        read_only: true
    networks:
      - back-tier

volumes:
  v_aftok-data:
  v_aftok-client:

networks:
  front-tier:
  back-tier: