version: '3.2'

services:
## Bases de datos
  static_gtfs:
    image: docker.ilab.cl/tpmc_static_gtfs:devel
    restart: "no"
    environment:
      - DEBUG=False
      - POSTGRES_PASSWORD=docker
    ports:
      - target: 5432
        published: 5401
    deploy:
      mode: replicated
      replicas: 1

  work_gtfs:
    image: docker.ilab.cl/tpmc_work_gtfs:devel
    restart: "no"
    volumes:
      - pgdata_hot_gtfs:/var/lib/postgresql/data
    environment:
      - DEBUG=False
      - POSTGRES_PASSWORD=docker
    ports:
      - target: 5432
        published: 5402
    deploy:
      mode: replicated
      replicas: 1

  system_db:
    image: docker.ilab.cl/tpmc_system_db:devel
    restart: "no"
    volumes:
      - pgdata_web:/var/lib/postgresql/data
    environment:
      - DEBUG=False
      - POSTGRES_PASSWORD=docker
    ports:
      - target: 5432
        published: 5403
    deploy:
      mode: replicated
      replicas: 1

## Contenedor de sitios estáticos
  front-static:
    image: docker.ilab.cl/tpmc_front_static:devel
    restart: "no"
    environment:
      - DEBUG=False
      - SECRET_KEY=4d6f45a5fc12445dbac2f59c3b6c7cb2
    ports:
      - target: 8000
        published: 5001
    deploy:
      mode: replicated
      replicas: 1

## Contenedor del proceso de inicio de session
  login-logic:
    image: docker.ilab.cl/tpmc_login_logic:devel
    restart: "no"
    depends_on:
      - system_db
      - work_gtfs
      - static_gtfs
    environment:
      - DEBUG=False
      - SECRET_KEY=4d6f45a5fc12445dbac2f59c3b6c7cb2
      - COOKIE_DOMAIN=tpmc.ilab.cl
      - SQLALCHEMY_WEBDB_URI=postgresql://docker:docker@system_db/docker
      - SQLALCHEMY_HOTDB_URI=postgresql://docker:docker@work_gtfs/docker
      - SQLALCHEMY_GTFSDB_URI=postgresql://docker:docker@static_gtfs/docker
    ports:
      - target: 8000
        published: 5002
    deploy:
      mode: replicated
      replicas: 1

## Contenedor de contenido dinamico
  public-dynamic:
    image: docker.ilab.cl/tpmc_public_dynamic:devel
    restart: "no"
    depends_on:
      - system_db
      - work_gtfs
      - static_gtfs
    volumes:
      - static_gtfs_volume:/srv/webinterface/static/gtfs_static
    environment:
      - DEBUG=False
      - SECRET_KEY=4d6f45a5fc12445dbac2f59c3b6c7cb2
      - SQLALCHEMY_WEBDB_URI=postgresql://docker:docker@system_db/docker
      - SQLALCHEMY_HOTDB_URI=postgresql://docker:docker@work_gtfs/docker
      - SQLALCHEMY_GTFSDB_URI=postgresql://docker:docker@static_gtfs/docker
      - COOKIE_DOMAIN=tpmc.ilab.cl
    ports:
      - target: 8000
        published: 5003
    deploy:
      mode: replicated
      replicas: 1

## Contenedor de contenido dinamico
  private-app:
    image: docker.ilab.cl/tpmc_private_app:devel
    restart: "no"
    depends_on:
      - system_db
      - work_gtfs
      - static_gtfs
    volumes:
      - static_gtfs_volume:/srv/webinterface/static/gtfs_static
    environment:
      - DEBUG=False
      - SECRET_KEY=4d6f45a5fc12445dbac2f59c3b6c7cb2
      - SQLALCHEMY_WEBDB_URI=postgresql://docker:docker@system_db/docker
      - SQLALCHEMY_HOTDB_URI=postgresql://docker:docker@work_gtfs/docker
      - SQLALCHEMY_GTFSDB_URI=postgresql://docker:docker@static_gtfs/docker
      - COOKIE_DOMAIN=tpmc.ilab.cl
    ports:
      - target: 8000
        published: 5004
    deploy:
      mode: replicated
      replicas: 1

## Carga GTFS en la DB
  load-gtfs:
    image: docker.ilab.cl/tpmc_load_gtfs:devel
    restart: "no"
    depends_on:
      - work_gtfs
      - static_gtfs
    volumes:
      - static_gtfs_volume:/srv/webinterface/static/gtfs_static
    environment:
      - DEBUG=False
      - SQLALCHEMY_HOTDB_URI=postgresql://docker:docker@work_gtfs/docker
      - SQLALCHEMY_GTFSDB_URI=postgresql://docker:docker@static_gtfs/docker
    deploy:
      mode: replicated
      replicas: 1

volumes:
    static_gtfs_volume:
       external: true
    pgdata_web:
       external: true
    pgdata_hot_gtfs:
       external: true
