https://github.com/itaru2622/docker-fastapi
Docker container for fastapi python
https://github.com/itaru2622/docker-fastapi
docker fastapi
Last synced: 2 months ago
JSON representation
Docker container for fastapi python
- Host: GitHub
- URL: https://github.com/itaru2622/docker-fastapi
- Owner: itaru2622
- Created: 2022-12-31T04:32:09.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2026-03-14T05:46:48.000Z (4 months ago)
- Last Synced: 2026-03-14T16:40:35.502Z (4 months ago)
- Topics: docker, fastapi
- Language: Makefile
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## simple usage on linux:
```bash
make start
# or
docker run --rm -it -p 8000:8000 -v ${PWD}:${PWD} -w ${PWD} itaru2622/fastapi:bookworm
# the above cmd start docker container with:
apt install -y ${PWD}/requirements-apt.txt
pip3 install -r ${PWD}/requirements.txt
uvicorn main:app
```
## test and play with embeded sample(/3catchall):
```bash
make test
# then, access http://localhost:8000/docs for swagger UI
```
## other usage on linux:
you can:
- set any uvicorn options by opts environment variable.
- change app name by app environment according to your implementation
- change requirement file path for apt install by apt_requirements environment variable.
- change requirement file path for pip install by py_requirements environment variable.
- change upgrade strategy for pip install by pip_install_opt environment variable.
- use your own start.sh (boot up script) to full control boot procedure. in below case, ${PWD}/start.sh or ${PWD}/bin/start.sh if exists and it is executable.
```bash
docker run --rm -it -p 8000:8000 -v ${PWD}:${PWD} -w ${PWD} -e py_requirements=${PWD}/requirements.txt -e pip_install_opt='--upgrade --upgrade-strategy eager' -e apt_requirements=${PWD}/requirements-apt.txt -e app=main:app -e opts='--host 0.0.0.0 --reload --reload-include "*.py" --reload-include "*.conf"' itaru2622/fastapi:bookworm
#
# the above cmd starts docker container via (/usr/local/bin/)start.sh with:
#
apt install -y ${apt_requirements}
pip3 install -r ${py_requirements} ${pip_install_opt}
uvicorn ${opts} ${app}
```
## build docker image
```bash
make build
# or
docker build --build-arg base=python:3-bookworm --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} -t itaru2622/fastapi:bookworm .
```