version: '3.2'

services:
## Bases de datos
  static_gtfs:
    build:
          dockerfile: Docker/Dockerfile.db_base
          context: .
    image: docker.ilab.cl/tpmc_static_gtfs:devel
    restart: "no"
    environment:
      - DEBUG=False
      - POSTGRES_PASSWORD=docker
    ports:
      - 5401:5432

  work_gtfs:
    build:
          dockerfile: Docker/Dockerfile.db_base
          context: .
    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:
      - 5402:5432

  system_db:
    build:
          dockerfile: Docker/Dockerfile.db_web
          context: .
    image: docker.ilab.cl/tpmc_system_db:devel
    restart: "no"
    volumes:
      - pgdata_web:/var/lib/postgresql/data
    environment:
      - DEBUG=False
      - POSTGRES_PASSWORD=docker
    ports:
      - 5403:5432

## Contenedor de sitios estáticos
  front-static:
    build:
          dockerfile: Docker/Dockerfile.front_static
          context: .
    image: docker.ilab.cl/tpmc_front_static:devel
    restart: "no"
    environment:
      - DEBUG=False
      - SECRET_KEY=4d6f45a5fc12445dbac2f59c3b6c7cb2
    ports:
      - 5001:8000

## Contenedor del proceso de inicio de session
  login-logic:
    build:
          dockerfile: Docker/Dockerfile.login_system
          context: .
    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:
      - 5002:8000

## Contenedor de contenido dinamico
  public-dynamic:
    build:
          dockerfile: Docker/Dockerfile.public_dynamic
          context: .
    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:
      - 5003:8000

## Contenedor de contenido dinamico
  private-app:
    build:
          dockerfile: Docker/Dockerfile.private_dynamic
          context: .
    image: docker.ilab.cl/tpmc_private_app:devel
    restart: "no"
    depends_on:
      - system_db
      - work_gtfs
      - static_gtfs
    volumes:
      - static_gtfs_volume:/srv/webservice/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:
      - 5004:8000


## Carga GTFS en la DB
  load-gtfs:
    build:
          dockerfile: Docker/Dockerfile.load_gtfs
          context: .
    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


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