version: '3'

# set database password in .env
# please don't use quote (') or (") symbols in variables

services:
  db:
    image: postgres:12-alpine
    restart: unless-stopped
    volumes:
      - db:/var/lib/postgresql/data
    environment:    
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_USER=${POSTGRES_USER}

  app:
    image: cthulhoo/ttrss-fpm-pgsql-static:${BUILD_TAG}
    build: 
      context:
        ./app
    restart: unless-stopped
    environment:
      - DB_TYPE=pgsql
      - DB_HOST=db
      - DB_NAME=${POSTGRES_USER}
      - DB_USER=${POSTGRES_USER}
      - DB_PASS=${POSTGRES_PASSWORD}
      - OWNER_UID=${OWNER_UID}
      - OWNER_GID=${OWNER_GID}
      - SELF_URL_PATH=${SELF_URL_PATH}
    volumes:
      - app:/var/www/html
    depends_on:
      - db

  updater:
    image: cthulhoo/ttrss-fpm-pgsql-static:${BUILD_TAG}
    build: 
      context:
        ./app
    restart: unless-stopped
    environment:
      - DB_TYPE=pgsql
      - DB_HOST=db
      - DB_NAME=${POSTGRES_USER}
      - DB_USER=${POSTGRES_USER}
      - DB_PASS=${POSTGRES_PASSWORD}
      - OWNER_UID=${OWNER_UID}
      - OWNER_GID=${OWNER_GID}
      - SELF_URL_PATH=${SELF_URL_PATH}
    volumes:
      - app:/var/www/html
    depends_on:
      - app
    command: /updater.sh

  backups:
    image: cthulhoo/ttrss-fpm-pgsql-static:${BUILD_TAG}
    build:
      context:
        ./app
    restart: unless-stopped
    environment:
      - DB_TYPE=pgsql
      - DB_HOST=db
      - DB_NAME=${POSTGRES_USER}
      - DB_USER=${POSTGRES_USER}
      - DB_PASS=${POSTGRES_PASSWORD}
      - OWNER_UID=${OWNER_UID}
      - OWNER_GID=${OWNER_GID}
    volumes:
      - backups:/backups
      - app:/var/www/html
    depends_on:
      - db
    command: /dcron.sh -f

  web:
    image: cthulhoo/ttrss-web:latest
    build: ./web
    restart: unless-stopped
    ports:
      - ${HTTP_PORT}:2015
    volumes:
      - app:/var/www/html:ro
    depends_on:
      - app

  web-ssl:
    image: cthulhoo/ttrss-web-ssl:latest
    build: ./web-ssl
    restart: unless-stopped
    environment:
      - CADDYPATH=/certs
      - HTTP_HOST=${HTTP_HOST}
    ports:
      - 80:80
      - 443:443
    volumes:
      - app:/var/www/html:ro
      - certs:/certs
    depends_on:
      - app

  web-nginx:
    image: cthulhoo/ttrss-web-nginx:latest
    build: ./web-nginx
    restart: unless-stopped
    ports:
      - ${HTTP_PORT}:80
    volumes:
      - app:/var/www/html:ro
    depends_on:
      - app

volumes:
  db:
  app:  
  certs:
  backups: