services:
  postgres:
    image: postgres:14
    container_name: postgres-db
    environment:
      POSTGRES_USER: supertokens
      POSTGRES_PASSWORD: password
      POSTGRES_DB: supertokens
    ports:
      - "5432:5432"
    env_file:
      - .env
      - .env.docker
    volumes:
      - postgres-data:/var/lib/postgresql/data
      - ./.docker-postgres-init:/docker-entrypoint-initdb.d
    networks:
      - app-network

  pocketbase:
    build:
      context: .
      dockerfile: Dockerfile.pocketbase
    container_name: pocketbase-db
    ports:
      - "8090:8090"
    volumes:
      - ./pb_data:/pb/pb_data
      - ./pb_migrations:/pb/pb_migrations
      - ./pb_hooks:/pb/pb_hooks
    networks:
      - app-network
    restart: unless-stopped
    
  #redis:
  #  image: redis:7-alpine
  #  container_name: redis-cache
  #  ports:
  #    - "6379:6379"
  #  command: redis-server --appendonly yes
  #  volumes:
  #    - redis-data:/data
  #  networks:
  #    - app-network
  #  restart: unless-stopped

  supertokens:
    image: registry.supertokens.io/supertokens/supertokens-postgresql
    container_name: supertokens-core
    depends_on:
      - postgres
    environment:
      POSTGRESQL_CONNECTION_URI: postgresql://supertokens:password@postgres:5432/supertokens
      ACCESS_TOKEN_VALIDITY: 360000
    ports:
      - "3567:3567"
    env_file:
      - .env
      - .env.docker
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

volumes:
  postgres-data:
  pocketbase-data:
  redis-data: