services:
  redis:
    image: 'redis:latest'
    ports:
      - 6379:6379

    environment:
      - TZ=Europe/Paris

  database:
    image: 'postgres:latest'
    ports:
      - 5432:5432
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: school
      TZ: Europe/Paris
  
  docuseal:
    image: docuseal/docuseal:latest
    depends_on:
      - database
    ports:
      - 3001:3000
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@database:5432/docuseal

  backend:
    build:
      context: ./Back-End
    ports:
      - 8080:8080
    volumes:
      - ./Back-End:/Back-End
    environment:
      - TZ=Europe/Paris
      - TEST_MODE=True
      - CORS_ALLOWED_ORIGINS=http://localhost:3000
      - CSRF_TRUSTED_ORIGINS=http://localhost:3000
    links:
      - "database:database"
      - "redis:redis"
    depends_on:
      - redis
      - database
      - docuseal
    command: python start.py

  init_docuseal_users:
    build:
      context: .
      dockerfile: Dockerfile
    depends_on:
      - docuseal
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      USER_FIRST_NAME: n3wt
      USER_LAST_NAME: school
      USER_COMPANY: n3wt.innov
      USER_EMAIL: n3wt.school@gmail.com
      USER_PASSWORD: n3wt1234
    volumes:
      - ./initDocusealUsers.sh:/docker-entrypoint-initdb.d/initDocusealUsers.sh

  # frontend:
  #   build:
  #     context: ./Front-End
  #     args:
  #       - BUILD_MODE=development
  #   ports:
  #     - 3000:3000
  #   volumes:
  #     - ./Front-End:/app
  #   env_file:
  #     - .env
  #   environment:
  #     - TZ=Europe/Paris
  #   depends_on:
  #     - backend

