# This docker-compose file is just here for testing
version: "3.4"
services:
  webapp-base:
    image: ocelotsocialnetwork/webapp:local-base
    build: 
      dockerfile: ../webapp/Dockerfile
      context: ../webapp
      target: base
    command: sleep 0

  webapp-code:
    image: ocelotsocialnetwork/webapp:local-code
    build: 
      dockerfile: ../webapp/Dockerfile
      context: ../webapp
      target: code
    command: sleep 0

  webapp:
    image: ocelotsocialnetwork/webapp-branded:local-${CONFIGURATION}
    container_name: webapp-branded
    build:
      dockerfile: src/docker/webapp.Dockerfile
      target: branded
      context: .
      args:
        - CONFIGURATION=$CONFIGURATION
        - APP_IMAGE_TAG_BASE=local-base
        - APP_IMAGE_TAG_CODE=local-code
    ports:
      - 3000:3000
    networks:
      - test-network
    depends_on:
      - backend
      - webapp-base
      - webapp-code
    env_file: 
      - .env
    environment:
      - HOST=0.0.0.0
      - GRAPHQL_URI=http://backend:4000
      - MAPBOX_TOKEN="pk.eyJ1IjoiYnVzZmFrdG9yIiwiYSI6ImNraDNiM3JxcDBhaWQydG1uczhpZWtpOW4ifQ.7TNRTO-o9aK1Y6MyW_Nd4g"
      # - WEBSOCKETS_URI=ws://backend:4000/graphql # is not working and not given in Docker YAML in main repo
      - PUBLIC_REGISTRATION=true
      - INVITE_REGISTRATION=true
      - CATEGORIES_ACTIVE=true

  backend-base:
    image: ocelotsocialnetwork/backend:local-base
    build: 
      dockerfile: ../backend/Dockerfile
      context: ../backend
      target: base
    command: sleep 0
  
  backend-code:
    image: ocelotsocialnetwork/backend:local-code
    build: 
      dockerfile: ../backend/Dockerfile
      context: ../backend
      target: code
    command: sleep 0
  
  backend:
    image: ocelotsocialnetwork/backend-branded:local-${CONFIGURATION}
    container_name: backend
    build:
      dockerfile: src/docker/backend.Dockerfile
      target: branded-branded
      context: .
      args:
        - CONFIGURATION=$CONFIGURATION
        - APP_IMAGE_TAG_BASE=local-base
        - APP_IMAGE_TAG_CODE=local-code
    networks:
      - test-network
    depends_on:
      - neo4j
      - backend-base
      - backend-code
    ports:
      - 4000:4000
    volumes:
      - backend_uploads:/app/public/uploads
    environment:
      - NEO4J_URI=bolt://neo4j:7687
      - GRAPHQL_URI=http://backend:4000
      - CLIENT_URI=http://localhost:3000
      - JWT_SECRET=b/&&7b78BF&fv/Vd
      - MAPBOX_TOKEN=pk.eyJ1IjoiYnVzZmFrdG9yIiwiYSI6ImNraDNiM3JxcDBhaWQydG1uczhpZWtpOW4ifQ.7TNRTO-o9aK1Y6MyW_Nd4g
      - PRIVATE_KEY_PASSPHRASE=a7dsf78sadg87ad87sfagsadg78
      - EMAIL_SUPPORT=support@wir.social
      - EMAIL_DEFAULT_SENDER=info@wir.social
      - PUBLIC_REGISTRATION=true
      - INVITE_REGISTRATION=true
      - CATEGORIES_ACTIVE=true
      - SMTP_USERNAME=${SMTP_USERNAME}
      - SMTP_PASSWORD=${SMTP_PASSWORD}
      - SMTP_HOST=mailserver
      - SMTP_PORT=25
      - SMTP_IGNORE_TLS=true
      #- PRODUCTION_DB_CLEAN_ALLOW=true
      - NODE_ENV=development

  maintenance-base:
    image: ocelotsocialnetwork/maintenance:local-base
    build: 
      dockerfile: ../webapp/Dockerfile.maintenance
      context: ../webapp
      target: base
    command: sleep 0

  maintenance-code:
    image: ocelotsocialnetwork/maintenance:local-code
    build: 
      dockerfile: ../webapp/Dockerfile.maintenance
      context: ../webapp
      target: code
    command: sleep 0

  maintenance:
    # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there
    image: ocelotsocialnetwork/maintenance-branded:local-${CONFIGURATION}
    container_name: maintenance-branded
    build:
      # TODO: Separate from webapp, this must be independent
      dockerfile: src/docker/maintenance.Dockerfile
      target: branded
      context: .
      args:
        - CONFIGURATION=$CONFIGURATION
        - APP_IMAGE_TAG_BASE=local-base
        - APP_IMAGE_TAG_CODE=local-code
    networks:
      - test-network
    depends_on:
      - maintenance-base
      - maintenance-code
    ports:
      - 3001:80

  neo4j:
    image: ocelotsocialnetwork/neo4j-community:latest
    container_name: neo4j
    networks:
      - test-network
    volumes:
      - neo4j_data:/data
    environment:
      - NEO4J_AUTH=none
      - NEO4J_dbms_security_procedures_unrestricted=algo.*,apoc.*
      - NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
    ports:
      - 7687:7687
      - 7474:7474

  mailserver:
    image: djfarrelly/maildev
    container_name: mailserver-branded
    ports:
      - 1080:80
    networks:
      - test-network

networks:
  test-network:

volumes:
  backend_uploads:
  neo4j_data:
