services:
  kener:
    container_name: kener
    image: docker.io/rajnandan1/kener:v4.1.1
    restart: unless-stopped
    networks:
      - homelab-network
    security_opt:
      - no-new-privileges:true
    environment:
      - TZ=Africa/Nairobi
      - PUID=1000
      - PGID=1000
      - PORT=4040
      - KENER_SECRET_KEY=${KENER_SECRET_KEY}
      - ORIGIN=${KENER_ORIGIN}
      - DATABASE_URL=${KENER_POSTGRES_URL}
      - REDIS_URL=${KENER_REDIS_URL}
      - SMTP_HOST=${SMTP_HOST}
      - SMTP_PORT=${SMTP_PORT}
      - SMTP_USER=${SMTP_NAME}
      - SMTP_PASSWORD=${SMTP_PASSWORD}
      - SMTP_SENDER=${MAIL_FROM_ADDRESS}
      - SMTP_SECURE=1
    ports:
      - 4040:4040
    volumes:
      - ~/docker-volumes/kener/data:/app/database

  kener-db:
    container_name: kener-db
    image: docker.io/postgres:16.1
    restart: unless-stopped
    networks:
      - homelab-network
    security_opt:
      - no-new-privileges:true
    volumes:
      - ~/docker-volumes/kener/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=${KENER_POSTGRES_USER}
      - POSTGRES_PASSWORD=${KENER_POSTGRES_PASSWORD}
      - POSTGRES_DB=${KENER_POSTGRES_DB}
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "pg_isready -U '${KENER_POSTGRES_USER}' -d '${KENER_POSTGRES_DB}'",
        ]
      interval: 5s
      timeout: 5s
      retries: 5

  kener-redis:
    container_name: kener-redis
    image: docker.io/redis:8-alpine
    restart: unless-stopped
    networks:
      - homelab-network
    security_opt:
      - no-new-privileges:true
    command: /bin/sh -c "redis-server --requirepass ${KENER_REDIS_PASSWORD}"
    volumes:
      - ~/docker-volumes/kener/redis:/data
    environment:
      - REDIS_PASSWORD=${KENER_REDIS_PASSWORD}
