You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Valon Januzaj b7685ad15f
Add fastapi to the list of compose projects
* Fastapi base Dockerfile
* requirements.txt for fastapi project
* Add documentation on how to run the application
* Add entrypoint for fastapi application
* Add docker-compose.yml for fastapi

Signed-off-by: vjanz <valon.januzaj98@gmail.com>
3 years ago
..
app Add fastapi to the list of compose projects 3 years ago
Dockerfile Add fastapi to the list of compose projects 3 years ago
README.md Add fastapi to the list of compose projects 3 years ago
docker-compose.yml Add fastapi to the list of compose projects 3 years ago
requirements.txt Add fastapi to the list of compose projects 3 years ago

README.md

Compose sample application

Python/FastAPI application

Project structure:

├── docker-compose.yaml
├── Dockerfile
├── requirements.txt
├── app
    ├── main.py
    ├── __init__.py

docker-compose.yaml

services:
  api:
    build: .
    container_name: fastapi-application
    environment:
      PORT: 8000
    ports:
      - '8000:8000'
    restart: "no"

Deploy with docker-compose

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