version: '3.1'

services:
    dim:
        build: .
        ports:
            - "8000:8000"
        volumes:
            - .:/code
        links:
            - postgres
        command: bash -c "bash ./wait-for-it.sh postgres:5432 -q -- cargo run"

    postgres:
        image: postgres
        ports:
          - "127.0.0.1:5432:5432"
        restart: always
        volumes:
            - pgdata:/var/lib/postgresql/data/pgdata
        environment:
            POSTGRES_PASSWORD: dimpostgres
            PGDATA: /var/lib/postgresql/data/pgdata

            # cargo will try to redownload packages @ docker-compose up so store them here.
volumes:
    pgdata: {}
