version: "3.7"

x-logging: &default-logging
  driver: json-file
  options:
    max-size: "10m"
    max-file: "3"

services:
  nginx:
    environment:
      - ACCOUNTS_ENABLED=true
      - ACCOUNTS_LIMIT_ACCESS=${ACCOUNTS_LIMIT_ACCESS:-authenticated} # default to authenticated access only
    depends_on:
      - accounts

  health-check:
    environment:
      - ACCOUNTS_ENABLED=true
      - ACCOUNTS_LIMIT_ACCESS=${ACCOUNTS_LIMIT_ACCESS:-authenticated} # default to authenticated access only

  accounts:
    build:
      context: ./docker/accounts
      dockerfile: Dockerfile
      args:
        branch: main
    container_name: accounts
    restart: unless-stopped
    logging: *default-logging
    env_file:
      - .env
    environment:
      - ACCOUNTS_EMAIL_URI=${ACCOUNTS_EMAIL_URI}
      - ACCOUNTS_JWKS_FILE=/conf/jwks.json
      - COOKIE_DOMAIN=${COOKIE_DOMAIN}
      - COOKIE_HASH_KEY=${COOKIE_HASH_KEY}
      - COOKIE_ENC_KEY=${COOKIE_ENC_KEY}
      - PORTAL_DOMAIN=${PORTAL_DOMAIN}
      - SERVER_DOMAIN=${SERVER_DOMAIN}
      - SKYNET_DB_HOST=${SKYNET_DB_HOST:-mongo}
      - SKYNET_DB_PORT=${SKYNET_DB_PORT:-27017}
      - SKYNET_DB_USER=${SKYNET_DB_USER}
      - SKYNET_DB_PASS=${SKYNET_DB_PASS}
      - STRIPE_API_KEY=${STRIPE_API_KEY}
      - STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}
      - SKYNET_ACCOUNTS_LOG_LEVEL=${SKYNET_ACCOUNTS_LOG_LEVEL:-info}
    volumes:
      - ./docker/data/accounts:/data
      - ./docker/accounts/conf:/conf
    expose:
      - 3000
    networks:
      shared:
        ipv4_address: 10.10.10.70
    depends_on:
      - mongo

  dashboard:
    # uncomment "build" and comment out "image" to build from sources
    # build:
    #   context: https://github.com/SkynetLabs/skynet-webportal.git#master
    #   dockerfile: ./packages/dashboard/Dockerfile
    image: skynetlabs/dashboard
    container_name: dashboard
    restart: unless-stopped
    logging: *default-logging
    env_file:
      - .env
    environment:
      - NEXT_PUBLIC_PORTAL_DOMAIN=${PORTAL_DOMAIN}
      - NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=${STRIPE_PUBLISHABLE_KEY}
    volumes:
      - ./docker/data/dashboard/.next:/usr/app/.next
    networks:
      shared:
        ipv4_address: 10.10.10.85
    expose:
      - 3000
    depends_on:
      - mongo

  dashboard-v2:
    build:
      context: .
      dockerfile: packages/dashboard-v2/Dockerfile
    container_name: dashboard-v2
    restart: unless-stopped
    logging: *default-logging
    env_file:
      - .env
    environment:
      - GATSBY_PORTAL_DOMAIN=${PORTAL_DOMAIN}
    volumes:
      - ./docker/data/dashboard-v2/.cache:/usr/app/.cache
      - ./docker/data/dashboard-v2/public:/usr/app/public
    networks:
      shared:
        ipv4_address: 10.10.10.86
    expose:
      - 9000
    depends_on:
      - mongo
