# Docker Compose Configuration
# Description: This file sets up a multi-container environment for Kener (https://github.com/rajnandan1/kener).
# Last Updated: 2025-02-08
# Docker Compose Version: 3.8
# Notes: Ensure that you specify a random value for the `KENER_SECRET_KEY` environment variable before running `docker-compose up -d`.

version: '3.8'

services:
  kener:
    image: rajnandan1/kener:latest      # Change to 'rajnandan1/kener:alpine' for an even smaller image! 😁🚀
    container_name: kener
    # env_file: custom.env              # Uncomment this if you are needing to export environment variables from a custom environment file. By default, Docker will import any variables that exist in `.env`
    environment:
      TZ: Etc/UTC
      KENER_SECRET_KEY: replace_me_with_a_random_string   # Keep private!! - best to define in `.env` file or through Docker Secret
      # DATABASE_URL: custom_db_url     # By default, a SQLite database is used - you may override the database url/type here
      # RESEND_API_KEY: 
      # RESEND_SENDER_EMAIL: 

      ### You most likely will NOT need to change anything below this line. Be sure you know what you're doing!! (https://kener.ing/docs/deployment/#docker-environment-variables)

      # PORT: 3000                      # Port that app listens on in the container
      # KENER_BASE_PATH:                # By default, Kener runs at `/`. You may change this to be, e.g. `/status`, etc. Do NOT add a trailing slash!! (more info here: https://kener.ing/docs/deployment/#docker-environment-variables)
      # ORIGIN: http://localhost:3000
      # NODE_ENV: production            # This is already set to "production" by default within the container
    ports:
      - '3000:3000/tcp'
    volumes:
      - data:/app/database              # We suggest using a Docker named volume, which is more performant for databases
      - $(pwd)/uploads:/app/uploads
    # read_only: true                   # Uncommenting this fortifies security by marking the container's filesystem as read-only (aka no data can be written to the container's filesystem except for explicitly defined writable volumes and bind mounts, an exception has already been defined for `/database` and `/uploads`)
    restart: unless-stopped
    # depends_on:                       #  <-- Uncomment if you would like to use PostgreSQL or MySQL
    #   - postgres                      #       ...instead of SQLite
    #   - mysql                         #

  # Only use below section if you would like to utilize PostgreSQL instead of Kener's default SQLite database. (Don't forget to set `DATABASE_URL` in `kener` service to be: `DATABASE_URL=postgresql://db_user:db_password@localhost:5432/kener_db`)
  postgres:
    image: postgres:alpine
    name: kener_db
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: some_super_random_secure_password   # Best to define this in `.env` or via Docker Secret!!
      POSTGRES_DB: kener_db
    restart: unless-stopped

  # Only use below section if you would like to utilize MySQL instead of Kener's default SQLite database. (Don't forget to set `DATABASE_URL` in `kener` service to be: `DATABASE_URL=mysql://db_user:db_password@localhost:3306/kener_db`)
  mysql:
    image: mariadb:11
    name: kener_db
    environment:
      MYSQL_USER: user
      MYSQL_PASSWORD: some_super_random_secure_password   # Best to define this in `.env` or via Docker Secret!!
      MYSQL_DATABASE: kener_db
      MYSQL_RANDOM_ROOT_PASSWORD: true
    restart: unless-stopped

volumes:
  data:
    name: kener_db