services:
  minio:
    image: minio/minio
    user: "1000"
    environment:
      - MINIO_ROOT_USER=$MINIO_ROOT_USER
      - MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD
    volumes:
      - ./storage/minio:/data
    command: [ "minio", "server", "/data", "--console-address", ":9090" ]
    ports:
      - 9000:9000
      - 9090:9090
    expose:
      - 9000

  db:
    image: postgres
    user: "1000"
    ports:
      - "5432:5432"
    expose:
      - 5432
    environment:
      - POSTGRES_USER=$DB_USER
      - POSTGRES_PASSWORD=$DB_PASSWORD
      - POSTGRES_DB=moneymgr
    volumes:
      - ./storage/db:/var/lib/postgresql/data

  oidc:
    image: pierre42100/basic_oidc
    user: "1000"
    environment:
      - LISTEN_ADDRESS=0.0.0.0:9001
      - STORAGE_PATH=/storage
      - TOKEN_KEY=$AUTH_SECRET_KEY
      - WEBSITE_ORIGIN=http://localhost:9001
      - OIDC_CLIENT_ID=$OIDC_CLIENT_ID
      - OIDC_CLIENT_SECRET=$OIDC_CLIENT_SECRET
      - APP_ORIGIN=$WEBSITE_ORIGIN
    expose:
      - 9001
    ports:
      - 9001:9001
    volumes:
      - ./auth:/storage

  redis:
    image: redis:alpine
    user: "1000"
    command: redis-server --requirepass ${REDIS_PASS:-secretredis}
    expose:
      - 6379
    volumes:
      - ./storage/redis-data:/data
      - ./storage/redis-conf:/usr/local/etc/redis/redis.conf

  moneymgr:
    image: pierre42100/moneymgr_backend
    user: "1000"
    ports:
      - 8000:8000
    environment:
      - WEBSITE_ORIGIN=${WEBSITE_ORIGIN}
      - SECRET=${APP_SECRET}
      - DB_HOST=db
      - DB_USERNAME=$DB_USER
      - DB_PASSWORD=$DB_PASSWORD
      - DB_NAME=moneymgr
      - OIDC_CONFIGURATION_URL=http://oidc:9001/.well-known/openid-configuration
      - OIDC_PROVIDER_NAME=OIDC
      - OIDC_CLIENT_ID=$OIDC_CLIENT_ID
      - OIDC_CLIENT_SECRET=$OIDC_CLIENT_SECRET
      - S3_ENDPOINT=http://minio:9000
      - S3_ACCESS_KEY=$MINIO_ROOT_USER
      - S3_SECRET_KEY=$MINIO_ROOT_PASSWORD
      - REDIS_HOSTNAME=redis
      - REDIS_PASSWORD=${REDIS_PASS:-secretredis}
      - UNSECURE_AUTO_LOGIN_EMAIL=$UNSECURE_AUTO_LOGIN_EMAIL
