version: '3.9'

services:
  postgres:
    image: postgres:latest
    environment:
      POSTGRES_USER: ${TYPEORM_USERNAME}
      POSTGRES_PASSWORD: ${TYPEORM_PASSWORD}
      POSTGRES_DB: ${TYPEORM_DATABASE}
    ports:
      - "5432:5432"
    volumes:
      - ./ibmed-db:/ibmed-db

  init-script:
    image: ubuntu:20.04
    volumes:
      - ./ibmed-db:/ibmed-db
    environment:
      POSTGRES_USER: ${TYPEORM_USERNAME}
      POSTGRES_PASSWORD: ${TYPEORM_PASSWORD}
      POSTGRES_DB: ${TYPEORM_DATABASE}
    depends_on:
      - postgres
    command: /bin/bash -c "/scripts/init_db.sh"
