version: "3.3"
services:
  traefik:
    image: "traefik:v2.8"
    container_name: "traefik"
    command:
      #- "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
  rest:
    build: .
    image: bee42/carpool:0.1.0
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.car.rule=Host(`car.localhost`)"
      - "traefik.http.routers.car.entrypoints=web"
      - "traefik.http.services.car.loadbalancer.server.port=5000"
    environment:
      FLASK_APP: python_rest
      POSTGRES_DB: esentricar
      POSTGRES_USER: cnbc
      POSTGRES_PASSWORD: postgres
      POSTGRES_HOST: postgres
  postgres:
    image: postgres
    container_name: postgres
    restart: always
    environment:
      POSTGRES_DB: postgres_db
      POSTGRES_USER: cnbc
      POSTGRES_PASSWORD: postgres
      PGDATA: /var/lib/postgresql/data/pgdata
    volumes:
      - postgres:/var/lib/postgresql/data
      - ./esentricar.sql:/docker-entrypoint-initdb.d/esentricar.sql
volumes:
  postgres:

  curl -i -X POST car.localhost/car \
  -H "Content-Type: application/json" \
  --data-binary "@car_2.json"