services:
  db:
    image: mcr.microsoft.com/mssql/server:2019-latest
    user: root
    #container_name: mssql_db
    environment:
      SA_PASSWORD: "StrongPassw0rd!"
      ACCEPT_EULA: "Y"
    ports:
      - "1433:1433"
    volumes:
      - db_data:/var/opt/mssql/data
      - ./db-init:/init-scripts  # Add this line to mount the initialization script
      - ./entrypoint.sh:/usr/local/bin/entrypoint.sh
    #command: /bin/bash -c "/opt/mssql/bin/sqlservr && sleep 5 && /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P StrongPassw0rd! -i /init-scripts/create-database.sql"
    #healthcheck:
      #test: ["CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P StrongPassw0rd! -Q 'SELECT 1'"]
      #interval: 10s
      #timeout: 5s
      #retries: 5
    entrypoint: ["/usr/local/bin/entrypoint.sh"]
    restart: always

  web:
    build: .
    #container_name: django_web
    volumes:
      - ./app:/app
    ports:
      - "8039:8000"
    depends_on:
      db:
        condition: service_started
        #condition: service_healthy
    environment:
      DJANGO_ENV: "dev"
      DB_NAME: "coi_db"
      DB_USER: "sa"
      DB_PASSWORD: "StrongPassw0rd!"
      DB_HOST: "db"
      DB_PORT: "1433"
    restart: always

volumes:
  db_data:
