version: "2.1"
networks:
  backend:
    external: true
  frontend:
    external: true
services:
  phoenix-frontend:
    restart: always
    image: "yurimatoslima/phoenix-frontend:alpha"
    volumes:
      - "/opt/containers/phx/app_custom:/usr/share/nginx/html/assets/custom"
      - "/opt/containers/phx/nginx/nginx.conf:/etc/nginx/nginx.conf"
    ports:
      - "8081:80"
      # - "443:443"
    networks:
      - frontend
    depends_on:
      - phoenix-backend
  phoenix-backend:
    restart: always
    image: "yurimatoslima/phoenix-backend:alpha"
    env_file: .env
    environment:
      DB_PORT: ${DB_POSTGRESDB_PORT}
      DB: ${DB_POSTGRES_TYPE}
      DB_HOST: ${DB_POSTGRESDB_HOST}
      DB_PASSWORD: ${POSTGRES_PASSWORD}
      DB_USERNAME: ${DB_POSTGRESDB_USER}
      DB_NAME: ${DB_POSTGRESDB_DATABASE}
      POSTGRES_USER: ${DB_POSTGRESDB_USER}
      CONNECTION_POOL_MAX: ${CONNECTION_POOL_MAX}
      SUPER_ADMIN_USER_PASSWORD: ${SUPER_ADMIN_USER_PASSWORD}
      RUN_JOB_QUEUE: ${RUN_JOB_QUEUE}
      SMTP_TYPE: ${SMTP_TYPE}
      SMTP_NAME: ${SMTP_NAME}
      SMTP_HOST: ${SMTP_HOST}
      SMTP_PORT: ${SMTP_PORT}
      SMTP_SECURE: ${SMTP_SECURE}
      SMTP_USER: ${SMTP_USER}
      SMTP_PASS: ${SMTP_PASS}
      SMTP_LOGGING: ${SMTP_LOGGING}
      SMTP_DEBUG: ${SMTP_DEBUG}
      SMTP_TLS_REJECT_UNAUTHORIZED: ${SMTP_TLS_REJECT_UNAUTHORIZED}
      SMTP_SECURE_CONNECTION: ${SMTP_SECURE_CONNECTION}
      SMTP_IGNORE_TLS: ${SMTP_IGNORE_TLS}
      ENV_MODE: ${ENV_MODE}
    command: [ "npm", "run", "start:server" ]
    ports:
      - "3000:3000"
      - "3400:3400"
      - "9615:9615"
      - "587:587" # Email Port
    volumes:
      - "asset-data:/usr/src/app/packages/dev-server/assets"
      - "/opt/containers/phx/server_custom:/usr/src/app/packages/dev-server/custom"
    networks:
      - backend
    # deploy:
    #   replicas: 2
  phoenix-backend-worker:
    restart: always
    image: "yurimatoslima/phoenix-backend:alpha"
    environment:
      DB_HOST: ${DB_POSTGRESDB_HOST}
      DB_PASSWORD: ${POSTGRES_PASSWORD}
      DB_USERNAME: ${DB_POSTGRESDB_USER}
      SUPER_ADMIN_USER_PASSWORD: ${SUPER_ADMIN_USER_PASSWORD}
      REDIS_PASSWORD: ${REDIS_PASSWORD}
    command: [ "npm", "run", "start:worker" ]
    volumes:
      #  - "/opt/containers/phx/assets:/usr/src/app/packages/dev-server/custo/assets"
      #  - "asset-data:/usr/src/app/packages/dev-server/assets"
      - "/opt/containers/phx/server_custom:/usr/src/app/packages/dev-server/custom"
    networks:
      - backend
volumes:
  asset-data: null
