Skip to content

Commit 72ef714

Browse files
authored
Merge pull request #332 from tjsullivan1/main
Dockerfiles for MCP and FastAPI
2 parents 483aad6 + 7827c45 commit 72ef714

File tree

12 files changed

+1956
-1871
lines changed

12 files changed

+1956
-1871
lines changed

.devcontainer/devcontainer.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@
77

88
// Features to add to the dev container. More info: https://containers.dev/features.
99
"features": {
10-
"ghcr.io/devcontainers/features/azure-cli:1": {},
11-
"ghcr.io/devcontainers-extra/features/uv:1": {}
12-
},
10+
"ghcr.io/devcontainers/features/azure-cli:1": {},
11+
"ghcr.io/devcontainers-extra/features/uv:1": {},
12+
"ghcr.io/devcontainers/features/github-cli:1": {},
13+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
14+
},
15+
"secrets": {
16+
"AZURE_OPENAI_ENDPOINT": {
17+
"description": " Replace with your model-deployment endpoint in Azure AI Foundry",
18+
"documentationUrl": "https://YOUR-OPENAI-SERVICE-ENDPOINT.openai.azure.com"
19+
},
20+
"AZURE_OPENAI_API_KEY": {
21+
"description": " Replace with your Foundry project’s API key",
22+
"documentationUrl": "YOUR-OPENAI-API-KEY"
23+
},
1324

1425
// Configure tool-specific properties.
1526
"customizations": {
@@ -39,4 +50,5 @@
3950

4051
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
4152
// "remoteUser": "root"
53+
}
4254
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Build and Push Docker Image for FastAPI Backend
4+
5+
# Controls when the action will run.
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the main branch
8+
pull_request:
9+
branches: [ main ]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
env:
15+
PROJECT_NAME: aoaiwkshp-backend
16+
PROJECT_SUBPATH: agentic_ai/
17+
SPECIFIC_RELEASE_TAG: ${{ vars.SPECIFIC_RELEASE_TAG || '' }}
18+
19+
20+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
21+
jobs:
22+
# This workflow contains a single job called "build"
23+
build:
24+
# The type of runner that the job will run on
25+
runs-on: ubuntu-latest
26+
# Only run if the required variables exist
27+
if: vars.REGISTRY_LOGIN_SERVER != '' && vars.REGISTRY_LOGIN_SERVER != null
28+
29+
# Steps represent a sequence of tasks that will be executed as part of the job
30+
steps:
31+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32+
- uses: actions/checkout@v2
33+
34+
- uses: docker/login-action@v3
35+
with:
36+
registry: ${{ vars.REGISTRY_LOGIN_SERVER }}
37+
username: ${{ secrets.REGISTRY_USERNAME }}
38+
password: ${{ secrets.REGISTRY_PASSWORD }}
39+
40+
- name: Build registry prefix
41+
id: prefix
42+
run: |
43+
if [[ "${{ vars.REGISTRY_LOGIN_SERVER }}" == *"docker.io"* ]]; then
44+
echo "prefix=${{ vars.REGISTRY_LOGIN_SERVER }}/${{ secrets.REGISTRY_USERNAME }}/${{ env.PROJECT_NAME }}" >> $GITHUB_OUTPUT
45+
else
46+
echo "prefix=${{ vars.REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME }}" >> $GITHUB_OUTPUT
47+
fi
48+
49+
50+
- run: |
51+
if [ -z "${{ env.SPECIFIC_RELEASE_TAG }}" ]; then
52+
docker build ${{ env.PROJECT_SUBPATH }} -t ${{ steps.prefix.outputs.prefix }}:${{ github.sha }} -t ${{ steps.prefix.outputs.prefix }}:latest
53+
else
54+
docker build ${{ env.PROJECT_SUBPATH }} -t ${{ steps.prefix.outputs.prefix }}:${{ env.SPECIFIC_RELEASE_TAG }} -t ${{ steps.prefix.outputs.prefix }}:latest
55+
fi
56+
57+
- run: |
58+
docker push ${{ steps.prefix.outputs.prefix }} --all-tags

.github/workflows/docker-mcp.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Build and Push Docker Image for MCP
4+
5+
# Controls when the action will run.
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the main branch
8+
pull_request:
9+
branches: [ main ]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
env:
15+
PROJECT_NAME: aoaiwkshp-mcp
16+
PROJECT_SUBPATH: mcp/
17+
SPECIFIC_RELEASE_TAG: ${{ vars.SPECIFIC_RELEASE_TAG || '' }}
18+
19+
20+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
21+
jobs:
22+
# This workflow contains a single job called "build"
23+
build:
24+
# The type of runner that the job will run on
25+
runs-on: ubuntu-latest
26+
# Only run if the required variables exist
27+
if: vars.REGISTRY_LOGIN_SERVER != '' && vars.REGISTRY_LOGIN_SERVER != null
28+
29+
# Steps represent a sequence of tasks that will be executed as part of the job
30+
steps:
31+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32+
- uses: actions/checkout@v2
33+
34+
- uses: docker/login-action@v3
35+
with:
36+
registry: ${{ vars.REGISTRY_LOGIN_SERVER }}
37+
username: ${{ secrets.REGISTRY_USERNAME }}
38+
password: ${{ secrets.REGISTRY_PASSWORD }}
39+
40+
- name: Build registry prefix
41+
id: prefix
42+
run: |
43+
if [[ "${{ vars.REGISTRY_LOGIN_SERVER }}" == *"docker.io"* ]]; then
44+
echo "prefix=${{ vars.REGISTRY_LOGIN_SERVER }}/${{ secrets.REGISTRY_USERNAME }}/${{ env.PROJECT_NAME }}" >> $GITHUB_OUTPUT
45+
else
46+
echo "prefix=${{ vars.REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME }}" >> $GITHUB_OUTPUT
47+
fi
48+
49+
50+
- run: |
51+
if [ -z "${{ env.SPECIFIC_RELEASE_TAG }}" ]; then
52+
docker build ${{ env.PROJECT_SUBPATH }} -t ${{ steps.prefix.outputs.prefix }}:${{ github.sha }} -t ${{ steps.prefix.outputs.prefix }}:latest
53+
else
54+
docker build ${{ env.PROJECT_SUBPATH }} -t ${{ steps.prefix.outputs.prefix }}:${{ env.SPECIFIC_RELEASE_TAG }} -t ${{ steps.prefix.outputs.prefix }}:latest
55+
fi
56+
57+
- run: |
58+
docker push ${{ steps.prefix.outputs.prefix }} --all-tags

SETUP_UV.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![alt text](media/image-1.png)
1+
![alt text](docs/media/image-1.png)
22
# Microsoft AI Agentic Workshop Setup
33

44
This document describes how to setup and run your AI Agents for the workshop if you are using UV as your python manager.

agentic_ai/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# syntax=docker/dockerfile:1
2+
3+
########## BUILD STAGE ##########
4+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS build
5+
6+
# We'll treat /app as the project root inside the container
7+
WORKDIR /app
8+
9+
# Copy dependency metadata from your repo
10+
# (pyproject.toml lives at app/applications/pyproject.toml on host)
11+
COPY applications/pyproject.toml ./pyproject.toml
12+
COPY applications/uv.lock ./uv.lock
13+
# If you have a uv.lock, keep this; otherwise delete/comment it
14+
# COPY app/applications/uv.lock ./uv.lock
15+
16+
ENV UV_COMPILE_BYTECODE=1 \
17+
UV_LINK_MODE=copy
18+
19+
# Install all dependencies (including uvicorn) into /app/.venv
20+
RUN --mount=type=cache,target=/root/.cache/uv \
21+
uv sync --frozen --no-dev
22+
23+
# Now bring in the actual source code
24+
# applications package (where backend.py lives)
25+
COPY applications ./applications
26+
# agents directory (no __init__.py needed)
27+
COPY agents ./agents
28+
29+
30+
########## RUNTIME STAGE ##########
31+
FROM python:3.12-slim AS runtime
32+
33+
WORKDIR /app
34+
35+
# Ensure we use the venv's python + scripts (uvicorn, etc.)
36+
ENV PATH="/app/.venv/bin:$PATH" \
37+
PYTHONUNBUFFERED=1 \
38+
PYTHONDONTWRITEBYTECODE=1 \
39+
# let Python see /app so "import agents" works
40+
PYTHONPATH="/app"
41+
42+
# Copy the venv and source code from build stage
43+
COPY --from=build /app /app
44+
45+
# Sanity: this should run backend.py exactly like:
46+
# uv run applications/backend.py
47+
# but using the venv python directly
48+
CMD ["python", "applications/backend.py"]

0 commit comments

Comments
 (0)