CD and infrastructure as code

docker

dockerfilebuildimageruncontainer
FROM python:3.12

WORKDIR /app  # create \app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .  # copy the appication

CMD ["python", "app.py"]  # when launched, run app.py
docker build ...

# example image
detector-model:v3
├── Linux filesystem
├── Python 3.12
├── numpy
├── scikit-learn
├── application code
├── model-serving code
└── startup configuration
# changing code in v17
change source code
  ↓
commit
  ↓
build NEW image
  ↓
detector-model:v18
  ↓
test
  ↓
deploy v18

continuous integration (CI)

git push
   ↓
GitHub
   ↓
CI WORKFLOW
   ├── install dependencies
   ├── lint
   ├── unit tests
   ├── integration tests
   ├── security checks
   └── perhaps build container

continuous delivery/deployment (CD)

git push
   ↓
CI
   ↓
tests pass
   ↓
build image
   ↓
push image to registry
   ↓
deploy staging
   ↓
integration checks
   ↓
deploy production
on:
  push:

jobs:
  test:
    steps:
      - checkout-code
      - install-dependencies
      - run-tests

infrastructure as code (IaC)

resource workspace 'Microsoft.MachineLearningServices/workspaces@...' = {
  name: 'my-ml-workspace'
  location: 'uksouth'
}
az something create ...
az something show ...
az something delete ...
GitHub Actions
      ↓
Azure CLI
      ↓
deploy Bicep template
      ↓
Azure resources
project/
│
├── src/
│   └── train.py  # application/ML code
│
├── tests/
│   └── test_model.py
│
├── infra/
│   └── main.bicep  # infrastructure definition
│
├── .github/
│   └── workflows/
│       └── deploy.yml  # automation/workflow
│
├── Dockerfile  # runtime/env definition
└── requirements.txt

# secrets stored elsewhere