## Example Docker Compose configuration
##
## Use this as a template to set up docker-compose, or as guide to set up other
## orchestration services

version: '2'
services:

  ## Python3 container for backend API
  backend:
    build:
      context: ./server
    depends_on:
      - sql
      - elasticsearch
    environment: # Commented Values are Default
      ## These should be the names of the dependent containers listed above, or
      ## accessible hostnames/IP addresses if these services are running
      ## outside of Docker
      POSTGRES_HOST: sql
      ESEARCH_HOST: elasticsearch
      ## Credentials for database
      POSTGRES_USER: szuru
      POSTGRES_PASSWORD: badpass
      ## Leave commented if using the official postgres container,
      ## it will default to the value in POSTGRES_USER
      #POSTGRES_DB:
      ## Leave commented if using the default port 5432
      #POSTGRES_PORT: 5432
      ## Leave commented if using the default port 9200
      #ESEARCH_PORT: 9200
      ## Uncomment and change if you want to use a different index
      #ESEARCH_INDEX: szurubooru
      ## Leave commented unless you want verbose SQL in the container logs
      #LOG_SQL: 1
    volumes:
      - data:/data
      ## If more customizations that are not covered in `config.yaml.dist` are needed
      ## Comment this line if you are not going
      ## to supply a YAML file
      - ./server/config.yaml:/opt/app/config.yaml

  ## HTTP container for frontend
  frontend:
    build:
      context: ./client
      args:
        ## This shows up on the homescreen, indicating build information
        ## Change as desired
        BUILD_INFO: docker-example
    depends_on:
      - backend
    environment:
      ## This should be the name of the previous container
      BACKEND_HOST: backend
    volumes:
      - data:/data:ro
    ports:
      ## If you want to expose the website on another port like 80,
      ## change to 80:80
      - 8080:80

  ## PostgreSQL container for database
  sql:
    image: postgres:alpine
    restart: unless-stopped
    environment:
      ## These should equal the same credentials as used on the first container
      POSTGRES_USER: szuru
      POSTGRES_PASSWORD: badpass
    volumes:
      - database:/var/lib/postgresql/data

  ## ElasticSearch container for image indexing
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.1
    environment:
      ## Specifies the Java heap size used
      ## Read
      ##  https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
      ## for more info
      ES_JAVA_OPTS: -Xms512m -Xmx512m
    volumes:
      - index:/usr/share/elasticsearch/data

volumes:
## IMPORTANT FOR PRODUCTION USE:
##   To avoid data loss, you should read and understand how Docker volumes work
##   before proceeding. Information can be found on
##     https://docs.docker.com/storage/volumes/
##   These mounts should be configured with drivers apporpriate for your system.
##   For small deployments, bind mounts or using the local-persist driver should
##   be fine. Make sure you mount to a directory that is safe and backed up.
##   local-persist driver can be found at:
##     https://github.com/CWSpear/local-persist
## It is okay to leave these as-is for development or testing purposes

  data: # This volume will hold persistant Image and User data for the board

  database: # This holds the SQL database

  index: # Scratch space for ElasticSearch Index