Example FastAPI.
.
├── docker-compose.yml
├── Dockerfile
├── README.md
├── requirements.txt
└── src
└── api.py
1 directory, 5 files
- Create an environment
- Install
requirements.txt
- Run
src/api.py
- API docs available in http://localhost:8000/api/v1/docs
conda create -n api python=3.10
conda activate api
pip install -r requirements.txt
python src/api.py
docker build -t api-template .
docker run -p 8000:8000 api-template
- Force rebuild:
docker build -t api-template . --no-cache
- Custom name:
docker run -d --name custom-api-template-name api-template
- Custom name and open port:
docker run --name api-template -p 8000:8000 api-template
docker-compose up
http://localhost:8000/
docker-compose down