'How to reload __init__ files in FastApi every 5 minutes using the docker --reload?

I'm trying to use the parameter --reload in my dockerfile to reload files inside the init function every 5 minutes in my FastAPI code, but i cannot seem to achieve that. Someone knows what i'm doing wrong?

version: "3.9"

services:
  people:
    container_name: people
    build: .
    working_dir: /code/app
    command: uvicorn main:app --host 0.0.0.0 --reload
    environment:
      DEBUG: 1
    volumes:
      - ./app:/code/app
    ports:
      - 8008:8000
    restart: on-failure

And the init code:

class Files:
    def __init__(self):
       df = # here i will load file from an azure bucket...

Also, i don't want to restart the whole container and rebuild it, but just reload the file.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source