networks:
  proxy:
    external: true
  maybe-internal:
    internal: true
  homechart-internal:
    internal: true
  monica-internal:
    internal: true

#######################
#######################

services:

  mealie:
    image: ghcr.io/mealie-recipes/mealie:latest
    container_name: mealie
    hostname: mealie
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/mealie:/app/data
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - ALLOW_SIGNUP=true
      - BASE_URL=https://mealie.jujub.eu
    networks:
      - proxy

##################
## Stack Tandoor
##################

  tandoor-db:
    image: postgres:latest
    container_name: tandoor-db
    hostname: tandoor-db
    restart: unless-stopped
#    expose:
#      - 5432
    volumes:
      - ${CONFIG_DIR}/tandoor/db:/var/lib/postgresql
    env_file:
      - ${CONFIG_DIR}/tandoor/.env
    networks:
      - proxy

  tandoor:
    image: vabene1111/recipes:latest
    container_name: tandoor
    hostname: tandoor
    restart: unless-stopped
    depends_on:
      - tandoor-db
    env_file:
      - ${CONFIG_DIR}/tandoor/.env
    volumes:
      - ${CONFIG_DIR}/tandoor/staticfiles:/opt/recipes/staticfiles
      - ${CONFIG_DIR}/tandoor/mediafiles:/opt/recipes/mediafiles
    networks:
      - proxy

##################
##################

  grocy:
    image: lscr.io/linuxserver/grocy:latest
    container_name: grocy
    hostname: grocy
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/grocy:/config
    environment:
      PUID: ${PUID}
      PGID: ${PDIG}
      TZ: ${TZ}
      GROCY_CURRENCY: EUR
      GROCY_CULTURE: fr
    networks:
      - proxy

  homebox:
    image: ghcr.io/sysadminsmedia/homebox:latest
    container_name: homebox
    hostname: homebox
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/homebox/data:/data
    environment:
      HBOX_LOG_LEVEL: info
      HBOX_WEB_MAX_UPLOAD_SIZE: 10
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ}
    networks:
      - proxy

  actual-budget:
    image: actualbudget/actual-server:latest
    container_name: actual-budget
    hostname: actual-budget
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/actual-budget/data:/data
    environment:
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ}
    networks:
      - proxy

###################
## Stack Maybe
###################

  maybe-db:
    image: postgres:17-alpine
    container_name: maybe-db
    hostname: maybe-db
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/maybe/db:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: maybe
      POSTGRES_USER: maybe
      POSTGRES_PASSWORD: MEXjr51zI7wd0EqFJy9xbYA7hHKR
      TZ: ${TZ}
    networks:
      - maybe-internal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U maybe -d maybe"]
      interval: 10s
      timeout: 5s
      retries: 5

  maybe-redis:
    image: redis:7-alpine
    container_name: maybe-redis
    hostname: maybe-redis
    restart: unless-stopped
    networks:
      - maybe-internal

  maybe:
    image: ghcr.io/maybe-finance/maybe:stable
    container_name: maybe
    hostname: maybe
    restart: unless-stopped
    depends_on:
      maybe-db:
        condition: service_healthy
      maybe-redis:
        condition: service_started
    volumes:
      - ${CONFIG_DIR}/maybe/storage:/rails/storage
    environment:
      # Base de données
      DB_HOST: maybe-db
      DB_PORT: 5432
      POSTGRES_DB: maybe
      POSTGRES_USER: maybe
      POSTGRES_PASSWORD: MEXjr51zI7wd0EqFJy9xbYA7hHKR
      # Redis
      REDIS_URL: redis://maybe-redis:6379/1
      # App
      SECRET_KEY_BASE: c2358bf6668a835db8a24ded955d38343854854d83d67211d46147b3adde94de929730938afd3548ed9065bcb36aae70cdead3496efb5184953f911d325f5df4
      SELF_HOSTING_ENABLED: "true"
      RAILS_FORCE_SSL: "false"
      RAILS_ASSUME_SSL: "true"
      GOOD_JOB_EXECUTION_MODE: async
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ}
    networks:
      - maybe-internal
      - proxy

###################
###################

  homehub:
    image: ghcr.io/surajverma/homehub:latest
    container_name: homehub
    hostname: homehub
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/homehub/config.yml:/app/config.yml:ro
      - ${CONFIG_DIR}/homehub/uploads:/app/uploads
      - ${CONFIG_DIR}/homehub/data:/app/data
    environment:
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ}
      FLASK_ENV: production
      SECRET_KEY: JGHAb7ClldpEl56Rwj9W4KxaEfRx
    networks:
      - proxy

#######################
## Stack Homechart
#######################

  homechart-db:
    image: postgres:17-alpine
    container_name: homechart-db
    hostname: homechart-db
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/homechart/db:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: homechart
      POSTGRES_USER: homechart
      POSTGRES_PASSWORD: vFY1a9mbBT0W9pQPA7bBYJEOSfza
      TZ: ${TZ}
    networks:
      - homechart-internal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U homechart"]
      interval: 10s
      timeout: 5s
      retries: 5

  homechart:
    image: ghcr.io/candiddev/homechart:latest
    container_name: homechart
    hostname: homechart
    restart: unless-stopped
    depends_on:
      homechart-db:
        condition: service_healthy
    environment:
      HOMECHART_POSTGRESQL_HOSTNAME: homechart-db
      HOMECHART_POSTGRESQL_DATABASE: homechart
      HOMECHART_POSTGRESQL_USERNAME: homechart
      HOMECHART_POSTGRESQL_PASSWORD: vFY1a9mbBT0W9pQPA7bBYJEOSfza
      HOMECHART_APP_BASEURL: https://homechart.jujub.eu
      HOMECHART_APP_DISABLESIGNUP: "false"   # passer à true après création du compte
      HOMECHART_WEBPUSH_VAPIDPRIVATEKEY: 
      HOMECHART_WEBPUSH_VAPIDPUBLICKEY: 
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ}
    networks:
      - homechart-internal
      - proxy

#######################
#######################

#######################
## Stack Monica
#######################

  monica:
    image: ghcr.io/monicahq/monica-next:main
    container_name: monica
    restart: unless-stopped
    depends_on:
      monica-db:
        condition: service_healthy
      monica-redis:
        condition: service_started
    volumes:
      - ${CONFIG_DIR}/monica/storage:/var/www/html/storage
    environment:
      APP_ENV: production
      APP_URL: https://monica.jujub.eu
      APP_KEY: base64:RgWw94PIPxl8I4F1BrwTe4oP5GLkNlt43K0gxTriR+M=
      APP_TRUSTED_PROXIES: "*"
      DB_CONNECTION: pgsql
      DB_HOST: monica-db
      DB_PORT: 5432
      DB_DATABASE: monica
      DB_USERNAME: monica
      DB_PASSWORD: aFA85noqzLEFpymOUG0Wiw0lLEtm
      CACHE_DRIVER: redis
      SESSION_DRIVER: redis
      # Mettre sync au PREMIER démarrage, puis repasser à redis
      QUEUE_CONNECTION: redis
      REDIS_HOST: monica-redis
      # Email via Google
      MAIL_MAILER: smtp
      MAIL_HOST: smtp-relay.gmail.com
      MAIL_PORT: 587
      MAIL_USERNAME:
      MAIL_PASSWORD:
      MAIL_ENCRYPTION: tls
      MAIL_FROM_ADDRESS: noreply@jujub.eu
    networks:
      - monica-internal
      - proxy

  monica-cron:
    image: ghcr.io/monicahq/monica-next:main
    container_name: monica-cron
    restart: unless-stopped
    command: cron.sh
    depends_on:
      - monica
    volumes:
      - ${CONFIG_DIR}/monica/storage:/var/www/html/storage
    environment:
      APP_ENV: production
      APP_URL: https://monica.jujub.eu
      APP_KEY: base64:RgWw94PIPxl8I4F1BrwTe4oP5GLkNlt43K0gxTriR+M=
      APP_TRUSTED_PROXIES: "*"
      DB_CONNECTION: pgsql
      DB_HOST: monica-db
      DB_PORT: 5432
      DB_DATABASE: monica
      DB_USERNAME: monica
      DB_PASSWORD: aFA85noqzLEFpymOUG0Wiw0lLEtm
      CACHE_DRIVER: redis
      SESSION_DRIVER: redis
      QUEUE_CONNECTION: sync
      REDIS_HOST: monica-redis
      MAIL_MAILER: log
    networks:
      - monica-internal

  monica-queue:
    image: ghcr.io/monicahq/monica-next:main
    container_name: monica-queue
    restart: unless-stopped
    command: queue.sh
    depends_on:
      - monica
    volumes:
      - ${CONFIG_DIR}/monica/storage:/var/www/html/storage
    environment:
      APP_ENV: production
      APP_URL: https://monica.jujub.eu
      APP_KEY: base64:RgWw94PIPxl8I4F1BrwTe4oP5GLkNlt43K0gxTriR+M=
      APP_TRUSTED_PROXIES: "*"
      DB_CONNECTION: pgsql
      DB_HOST: monica-db
      DB_PORT: 5432
      DB_DATABASE: monica
      DB_USERNAME: monica
      DB_PASSWORD: aFA85noqzLEFpymOUG0Wiw0lLEtm
      CACHE_DRIVER: redis
      SESSION_DRIVER: redis
      QUEUE_CONNECTION: sync
      REDIS_HOST: monica-redis
      MAIL_MAILER: log
    networks:
      - monica-internal

  monica-db:
    image: postgres:17-alpine
    container_name: monica-db
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/monica/db:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: monica
      POSTGRES_USER: monica
      POSTGRES_PASSWORD: aFA85noqzLEFpymOUG0Wiw0lLEtm
    networks:
      - monica-internal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U monica"]
      interval: 10s
      timeout: 5s
      retries: 5

  monica-redis:
    image: redis:7-alpine
    container_name: monica-redis
    restart: unless-stopped
    command: redis-server --save "" --appendonly no
    networks:
      - monica-internal

#######################
#######################
