version: '2'

volumes:
  c4po-db:

services:
  # Database
  c4po-db:
    image: mongo:latest
    container_name: c4po-db
    volumes:
      - ./volumes/mongodb/data/:/db/data
    deploy:
      resources:
        limits:
          memory: "1G"
    ports:
      - 27017:27017
    networks:
      - c4po
  # Authentication Provider
  c4po-keycloak:
    container_name: c4po-keycloak
    image: quay.io/keycloak/keycloak:20.0.0
    volumes:
      - ./cfg/c4po_realm_export.json/:/opt/keycloak/data/import/c4po_realm_export.json
    ports:
      - 8080:8080
    entrypoint: /opt/keycloak/bin/kc.sh start-dev --import-realm --http-relative-path=/auth
    networks:
      - c4po
  # Services
  c4po-angular:
    build: '../security-c4po-angular'
    image: security-c4po-angular:latest
    container_name: c4po-angular
    depends_on:
      - c4po-keycloak
    deploy:
      resources:
        limits:
          memory: "2G"
    ports:
      - 4200:4200
    networks:
      - c4po
  c4po-api:
    build: '../security-c4po-api'
    image: security-c4po-api:latest
    container_name: c4po-api
    environment:
      - SPRING_PROFILES_ACTIVE=COMPOSE
    depends_on:
      - c4po-db
      - c4po-keycloak
    deploy:
      resources:
        limits:
          memory: "2G"
    ports:
      - 8443:8443
    networks:
      - c4po

networks:
  c4po:
