# This is a docker-compose made only for testing purpose
#
# If any change has been done :
# > docker-compose -p onebet up --build -d

# Else :
# > docker-compose -p onebet up -d

version: "3.7"

services:
  app:
    build: .
    image: onebet
    environment:
      DJANGO_SECRET: test
      DJANGO_DEBUG: 1
      POSTGRES_DATABASE: onebet
      POSTGRES_USERNAME: onebet
      POSTGRES_PASSWORD: onebet
      POSTGRES_HOST: db
      POSTGRES_PORT: 5432
    depends_on:
      - db
    ports:
      - 127.0.0.1:8000:8000
    command:
      - /bin/sh
      - -c
      - |
        echo "waiting postgres database..."
        sleep 5
        echo "setting postgres schema..."
        python manage.py migrate
        echo "initialising postgres with default keys"
        python manage.py initdb
        echo "compling scss files..."
        python manage.py compilescss
        echo "running django server..."
        python manage.py runserver 0.0.0.0:8000

  db:
    image: postgres:11.7-alpine
    environment:
      POSTGRES_USER: onebet
      POSTGRES_PASSWORD: onebet
      POSTGRES_DB: onebet
    ports:
      - 127.0.0.1:5432:5432
