From d3cd1be1ffd5e2c6def93714a2d3e1dd26856e50 Mon Sep 17 00:00:00 2001 From: vjanz Date: Sun, 10 Oct 2021 22:46:25 +0200 Subject: [PATCH] Add documentation on how to run the application Signed-off-by: vjanz --- fastapi/README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 fastapi/README.md diff --git a/fastapi/README.md b/fastapi/README.md new file mode 100644 index 0000000..2dd0ff8 --- /dev/null +++ b/fastapi/README.md @@ -0,0 +1,55 @@ +## Compose sample application +### Python/FastAPI application + +Project structure: +``` +├── docker-compose.yaml +├── Dockerfile +├── requirements.txt +├── app +    ├── main.py +    ├── __init__.py + +``` + +[_docker-compose.yaml_](docker-compose.yaml) +``` +services: + api: + build: . + container_name: fastapi-application + environment: + PORT: 8000 + ports: + - '8000:8000' + restart: "no" + +``` + +## Deploy with docker-compose + +```shell +docker-compose up -d --build +``` +## Expected result + +Listing containers must show one container running and the port mapping as below: +``` +$ docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +7087a6e79610 5c1778a60cf8 "/start.sh" About a minute ago Up About a minute 80/tcp, 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp fastapi-application +``` + +After the application starts, navigate to `http://localhost:8000` in your web browser and you should see the following json response: +``` +{ +"message": "OK" +} +``` + +Stop and remove the containers +``` +$ docker-compose down +``` + +