version: '3.7'
services:
  traefik:
    image: traefik:v2.4
    command:
      - "--providers.docker"
    container_name: traefik
    hostname: traefik
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./traefik:/etc/traefik
      - ./traefik/logs:/logs
      - /var/run/docker.sock:/var/run/docker.sock
      - ./certificates:/certificates
    labels:
      - "traefik.enable=false"
    networks:
      - tokoemas_net

  minio:
    image: minio/minio:RELEASE.2022-10-05T14-58-27Z
    hostname: minio
    container_name: minio
    restart: always
    ports:
      - 9000:9000
      - 9001:9001
    environment:
      - MINIO_ROOT_USER=admin
      - MINIO_ROOT_PASSWORD=Of2RktjzUl
    volumes:
      - ./minio:/data
    command: ['server','/data', '--console-address',':9001']
    networks:
      - tokoemas_net

  redis:
    image: 'bitnami/redis:7.0.5'
    container_name: redis
    restart: always
    environment:
      - REDIS_PASSWORD=MGDZpQO6E4
      - REDIS_AOF_ENABLED=yes
    volumes:
      - ./redis:/bitnami/redis/data
    networks:
      - tokoemas_net

  portainer:
    image: portainer/portainer-ce:2.15.1
    container_name: portainer
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./portainer-data:/data
    ports:
      - 8000:9000
    networks:
      - tokoemas_net

  postgres:
    image: 'postgres:14.1'
    container_name: postgres
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=el3lYQlZyA
      - POSTGRES_DB=tokoemas_db
      - TZ=Asia/Jakarta
      - PGTZ=Asia/Jakarta
    volumes:
      - ./postgres:/var/lib/postgresql/data
    networks:
      - tokoemas_net

  metabase:
    image: metabase/metabase:v0.44.4
    container_name: metabase
    restart: always
    environment:
     - MB_DB_TYPE=postgres
     - MB_DB_DBNAME=metabaseappdb
     - MB_DB_PORT=5432
     - MB_DB_USER=metabase
     - MB_DB_PASS=Knuvruhip3ov
     - MB_DB_HOST=postgres
    ports:
      - 4000:3000
    networks:
      - tokoemas_net

  phppgadmin:
    image: bitnami/phppgadmin:7.13.0-debian-10-r402
    container_name: phppgadmin
    restart: always
    environment:
     - DATABASE_HOST=postgres
    networks:
      - tokoemas_net

  es01:
    image: kahidna/elasticsearch-mirror
    # comment, since biznet network issue with this repo    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.6
    container_name: es01
    restart: always
    environment:
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./es01:/usr/share/elasticsearch/data
    networks:
      - tokoemas_net

  opentelemetry-collector:
    image: otel/opentelemetry-collector-contrib:0.72.0
    volumes:
      - ./opentelemetry/otel-config.yml:/otel-config.yml
    networks:
      - tokoemas_net

  jaeger-aio:
    image: jaegertracing/all-in-one:1.47
    hostname: jaeger-aio
    container_name: jaeger
    command: [
      "--es.server-urls=http://es01:9200",
      "--es.num-replicas=0",
      "--log-level=error",
    ]
    environment:
      - COLLECTOR_OTLP_ENABLED=true
      - SPAN_STORAGE_TYPE=elasticsearch        
    networks:
      - tokoemas_net

  apiservice:
    build:
      context: ./apiservice
    container_name: apiservice
    environment:
      - APP_NAME=apiservice
      - APP_PORT=8000
      - DB_HOST=postgres
      - DB_PORT=5432
      - DB_PASS=el3lYQlZyA
      - DB_USER=postgres
      - DB_NAME=tokoemas_db
      - DB_LOGGER=false
      - REDIS_HOST=redis
      - REDIS_PASSWORD=MGDZpQO6E4
      - REDIS_PORT=6379
      - MINIO_ENDPOINT=nos.wjv-1.neo.id
      - MINIO_KEY=008c4ade2222f7bbc13b
      - MINIO_SECRET=hzImM2zVCEJDO8Ss0l9xbLlPHKjIWMrAk3yOmQ8i
      - MINIO_BUCKET=tokoemas
      - MINIO_SSL=true
      - JWT_SIGNINGKEY="tok0emaskeeyyy"
      - JWT_EXPIRED=604800 #in seconds
      - IS_MIGRATE=false
      - ELASTIC_ACTIVE=false
      - REDIS_ACTIVE=false
      - IMG_HOST=https://nos.wjv-1.neo.id/
      - FCM_CONFIG=/app/config/tokoemasdev.json
      - ELASTIC_URL=http://es01:9200
      - DB_POOL_SIZE=50
      - DB_MIN_IDLE_CONNS=40
      - DB_MAX_CONN_AGE=30
      - DB_IDLE_TIMEOUT=5       
      - OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger-aio:4318 
    restart: always
    networks:
      - tokoemas_net

  dashboard-admin:
    build:
     context: ./dashboard-admin
    container_name: dashboard_admin
    restart: always
    networks:
      - tokoemas_net
    extra_hosts:
      - "api.hsgold.id:103.150.196.240"

  dozzle:
    image: 'amir20/dozzle:v4.4.1'
    container_name: dozzle
    restart: always
    environment:
      - DOZZLE_USERNAME=dozzle
      - DOZZLE_PASSWORD=Um2Queovocrad
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - tokoemas_net

networks:
  tokoemas_net:
    name : tokoemas_net
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.19.0.0/24
