Skip to content

borisdev/stack-sandbox

 
 

Repository files navigation

Cheatsheet to run my new stack for Nobsmed.com

az containerapp compose https://learn.microsoft.com/en-us/cli/azure/containerapp/compose?view=azure-cli-latest

Stack

  • uv
  • Docker multi-stage builds
  • Backend: FastAPI (shift to LangGraph Platform)
  • Frontend: Next.js, React components, Tailwind CSS, TypeScript
  • Azure Search DB
  • Azure Registry
  • Azure Container app
  • Azure Redis

Best template to start with

https://github.com/fastapi/full-stack-fastapi-template

Why uv?

Patch deployments for quick A/B test experiments

[project]
name = "my-project"
version = "0.1.0"
dependencies = [
    "my-internal-package"
]

[tool.uv.sources]
my-internal-package = { git = "https://your-internal-repo.com/my-internal-package.git", branch = "development-branch" }

Stack

  • uv workspace - deployment is captured in one repo but you still play around with different service versions
  • Docker multi-stage builds (3x smaller images)
  • Backend: FastAPI (shift to LangGraph Platform)
    • async LLM calls
    • sentence transformer to fine tune embedding models
    • sklearn to create simple ML models to predict doc line relevance and user question topic
  • Frontend: Next.js, React components, Tailwind CSS, TypeScript
  • Search DB - sparse vector embedding search (coming soon)
  • Azure registry and container app deployment -- I got funding from Microsoft
  • Redis cache (coming soon)

Principles for a 1 person team

  • Transparency over automation
    • no github actions until CI/CD is needed due to more team members going faster
  • Simplicity - no Terraform - stick w/ Azure CLI until the infrastructure is more complex

Steps to run my stack

  1. Build the images locally
  2. Push the images to cloud registry
  3. Deploy cloud container based on new image in registry

Source: Azure Container Registry for launch in Azure Container Apps.

Assumptions:

  • Azure: Azure CLI installed and your logged into it
  • you have created a resource group in Azure (e.g., for me its nobsmed)

Pre-requisites steps

I prefix names with nobs because my company is called Nobsmed.

# create the registry

az acr create --resource-group nobsmed --name nobsregistry --sku Basic

# sanity check

az acr show --name nobsregistry --query loginServer --output table
Result
--------------------------
nobsmedregistry.azurecr.io

Ongoing launch steps

# Build backend and frontend docker images:

docker build --tag nobs_backend --file docker/Dockerfile .
docker build --tag nobs_frontend --file docker/Dockerfile .

# Tag the images for Azure Container Registry

docker tag nobs_backend nobsregistry.azurecr.io/nobs_backend:v1

# Sanity check

docker images
REPOSITORY                             TAG       IMAGE ID       CREATED        SIZE
nobsregistry.azurecr.io/nobs_backend      v1        585a4696bedd   44 hours ago   197MB
nobs_backend                           latest    585a4696bedd   43 hours ago   197MB
nobs_frontend                          latest    585a4696bedd   43 hours ago   197MB

# Login to Azure Container Registry

az acr login --name nobsregistry

# Push image to Azure Container Registry

docker push nobsregistry.azurecr.io/nobs_backend:v1

**# Sanity check .....you see the output below**

The push refers to repository [nobsregistry.azurecr.io/nobs_backend]
5f70bf18a086: Preparing
7d577052c02c: Preparing
ac42807ce093: Preparing
d54c60f73cbb: Preparing
d559dc6e6c29: Preparing
8f697a207321: Waiting


# Sanity check that the image is in the registry

az acr repository list --name nobsregistry
[
"nobs_backend",
]
source azure_env
source azure_deploy

az containerapp create \
  --name $API_NAME \
  --resource-group $RESOURCE_GROUP \
  --environment $ENVIRONMENT \
  --image $ACR_NAME.azurecr.io/$API_NAME \
  --target-port 8080 \
  --ingress external \
  --registry-server $ACR_NAME.azurecr.io \
  --user-assigned "$IDENTITY_ID" \
  --registry-identity "$IDENTITY_ID" \
  --query properties.configuration.ingress.fqdn

az container delete --name sampleapp --resource-group nobsmed

About

Stack Sandbox: uv & FastAPI & NextJS & Azure

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 65.5%
  • Python 28.1%
  • Shell 6.4%