services:
  ffsaf:
    container_name: ffsaf
    hostname: ffsaf
    restart: always
    build:
      context: .
      dockerfile: src/main/docker/Dockerfile.native
    volumes:
      - ${PWD}/ffsaf.properties:/work/config/application.properties
      - ${PWD}/ffsaf_cle_prive.jks:/work/cle_prive.jks
      - ${PWD}/mail-truststore.p12:/work/mail-truststore.p12
      - ${PWD}/sign.jpg:/work/sign.jpg
      - ${PWD}/ffsaf-media:/work/media
    depends_on:
      ffsaf-db:
        condition: service_healthy
        restart: true
    networks:
      - default
      - intra
      - nginx

  ffsaf-db:
    image: public.ecr.aws/docker/library/postgres:17.2
    hostname: ffsaf-db
    container_name: ffsaf-db
    user: postgres
    restart: always
    networks:
      - pgadmin
      - default
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready" ]
      interval: 5s
      timeout: 3s
      retries: 10
    volumes:
      - ${PWD}/postgres-data:/var/lib/postgresql/data
    env_file: prod.env

networks:
  intra:
    name: intra
    driver: bridge
  pgadmin:
    name: pgadmin
    external: true
  nginx:
    name: ${NETWORK_NAME:-gateway}
    external: true