version: "3.7"

services:

  cbwebreader:
    build: .
    env_file: .env
    links:
      - database
    depends_on:
      - database
    expose:
      - 8000
    volumes:
      - ${COMIC_BOOK_VOLUME}:${COMIC_BOOK_VOLUME}
      - static_files:/static
      - media_files:/media
      - .env:/src/.env
    command:  /bin/bash entrypoint.sh

  cbwebreader-cron:
    build: .
    env_file: .env
    links:
      - database
    depends_on:
      - database
    volumes:
      - ${COMIC_BOOK_VOLUME}:${COMIC_BOOK_VOLUME}
      - media_files:/media
      - .env:/src/.env
    command: /bin/bash entrypoint-cron.sh

  database:
    image: postgres:11.4-alpine
    expose:
      - 5432
    volumes:
      - /var/lib/postgresql/data
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASS}
      - POSTGRES_DB=${DB_DATABASE}

  nginx:
    image: nginx
    volumes:
      - static_files:/static
      - media_files:/media
      - ./cbreader/settings/nginx.conf:/etc/nginx/conf.d/default.conf
    ports:
      - 1337:80
    depends_on:
      - cbwebreader
volumes:
  static_files:
  media_files: