Skip to content

aswinandro/devops-microservice-fastapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevOps Microservice with FastAPI

This repository is a template for a Python FastAPI microservice with full DevOps workflow:

  • Dockerized application
  • Automated tests (pytest)
  • CI/CD pipeline (GitHub Actions)
  • Deployment to Azure Web App for Containers

Features

  • Simple CRUD API (POST, GET, PUT, DELETE for /items/{item_id})
  • OpenAPI/Swagger documentation (auto-generated)
  • CI pipeline: build, test, and deploy to Azure

Local Development

Requirements

  • Python 3.11+
  • Docker

Run Locally

# Install dependencies
pip install -r requirements.txt

# Run the app
uvicorn app.main:app --reload

The API will be available at http://localhost:8000

Run Tests

pytest app/test_main.py

Docker

docker build -t devops-microservice-fastapi .
docker run -p 8000:8000 devops-microservice-fastapi

API Documentation

CI/CD with GitHub Actions & Azure

  1. Create an Azure Container Registry
  2. Create an Azure Web App for Containers
  3. Add these secrets to your GitHub repository:
    • AZURE_CONTAINER_REGISTRY_LOGIN_SERVER
    • AZURE_CONTAINER_REGISTRY_USERNAME
    • AZURE_CONTAINER_REGISTRY_PASSWORD
    • AZURE_WEBAPP_NAME
  4. On push to main, your app will be built, tested, and deployed automatically.

License

MIT

About

Docker FastAPI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published