version: "3.7"

services:
  aftok:
    image: aftok/aftok-server:latest
    container_name: aftok-server
    expose:
      - "8000"
    depends_on:
      - aftokdb
      - zcashd
    volumes:
      - type: bind
        source: /opt/aftok/aftok-server
        target: /etc/aftok
        read_only: true
      - type: bind
        source: /opt/aftok/aftok-server-logs
        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:
      - "80:80"
      - "443:443"
    depends_on:
      - aftok
    volumes:
      - type: bind
        source: /opt/aftok/nginx-logs
        target: /var/log/nginx
      - type: bind
        source: /opt/aftok/nginx
        target: /etc/nginx
        read_only: true
      - type: bind
        source: /opt/aftok/letsencrypt/etc/letsencrypt
        target: /etc/letsencrypt
        read_only: true
      - type: bind
        source: /opt/aftok/letsencrypt/data/letsencrypt
        target: /opt/letsencrypt
        read_only: true
      - type: bind
        source: /opt/aftok/static/aftok.com/
        target: /opt/static/site
        read_only: true
      - type: volume
        source: v_aftok-client
        target: /opt/static/app
        read_only: true
    networks:
      - front-tier

  aftokdb:
    image: postgres:latest
    container_name: aftok-db
    expose:
      - "5432"
    volumes:
      - type: volume
        source: aftok-data
        target: /var/lib/postgresql/data
      - type: bind
        source: /opt/aftok/postgres/dumps
        target: /opt/
        read_only: true
    networks:
      - back-tier

  zcashd:
    image: electriccoinco/zcashd:v4.2.0
    container_name: aftok-zcashd
    expose:
      - "8232"
    ports:
      - "8233:8233"
    volumes:
      - type: bind
        source: /opt/aftok/zcashd/zcash-data
        target: /srv/zcashd/.zcash
      - type: bind
        source: /opt/aftok/zcashd/zcash-params
        target: /srv/zcashd/.zcash-params
        read_only: true
    networks:
      - back-tier

volumes:
  aftok-data:
  v_aftok-client:

networks:
  front-tier:
    driver: bridge
  back-tier: