Skip to content

Commit 4a3adb6

Browse files
authored
feat: add Support Tickets demo Docker image + consolidated CI (#18)
feat: Support Tickets demo Docker image + consolidated CI. Refs devonartis/agentwrit#31, Refs devonartis/agentwrit#33
1 parent 351dc2f commit 4a3adb6

4 files changed

Lines changed: 182 additions & 0 deletions

File tree

.github/workflows/docker-demos.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build & Push Demo Images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "demo/**"
8+
- "demo2/**"
9+
- "src/**"
10+
- "pyproject.toml"
11+
- "uv.lock"
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
build-medassist:
19+
name: Build & Push MedAssist
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Log in to Docker Hub
28+
uses: docker/login-action@v3
29+
with:
30+
username: ${{ secrets.DOCKERHUB_USERNAME }}
31+
password: ${{ secrets.DOCKERHUB_TOKEN }}
32+
33+
- name: Extract version from pyproject.toml
34+
id: version
35+
run: |
36+
VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
37+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
38+
39+
- name: Build and push
40+
uses: docker/build-push-action@v6
41+
with:
42+
context: .
43+
file: demo/Dockerfile
44+
push: true
45+
tags: |
46+
devonartis/agentwrit-medassist:latest
47+
devonartis/agentwrit-medassist:${{ steps.version.outputs.version }}
48+
cache-from: type=gha
49+
cache-to: type=gha,mode=max
50+
51+
build-support-tickets:
52+
name: Build & Push Support Tickets
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
60+
- name: Log in to Docker Hub
61+
uses: docker/login-action@v3
62+
with:
63+
username: ${{ secrets.DOCKERHUB_USERNAME }}
64+
password: ${{ secrets.DOCKERHUB_TOKEN }}
65+
66+
- name: Extract version from pyproject.toml
67+
id: version
68+
run: |
69+
VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
70+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
71+
72+
- name: Build and push
73+
uses: docker/build-push-action@v6
74+
with:
75+
context: .
76+
file: demo2/Dockerfile
77+
push: true
78+
tags: |
79+
devonartis/agentwrit-support-tickets:latest
80+
devonartis/agentwrit-support-tickets:${{ steps.version.outputs.version }}
81+
cache-from: type=gha
82+
cache-to: type=gha,mode=max

demo2/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM python:3.13-slim AS base
2+
3+
# System deps for cryptography wheel
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
gcc libffi-dev curl \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
# Install uv
9+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
10+
11+
WORKDIR /app
12+
13+
# Copy build metadata (hatchling needs README.md)
14+
COPY pyproject.toml uv.lock README.md ./
15+
16+
# Install all dependencies including demo deps (layer cache)
17+
COPY src/ src/
18+
RUN uv sync --frozen
19+
20+
# Copy demo2 app
21+
COPY demo2/ demo2/
22+
23+
# Demo entrypoint
24+
COPY demo2/entrypoint.sh /entrypoint.sh
25+
RUN chmod +x /entrypoint.sh
26+
27+
EXPOSE 5001
28+
29+
# Runtime config — secrets passed at run time, not baked in
30+
ENV AGENTWRIT_BROKER_URL=http://broker:8080
31+
ENV LLM_BASE_URL=https://api.openai.com/v1
32+
ENV LLM_MODEL=gpt-4o-mini
33+
34+
ENTRYPOINT ["/entrypoint.sh"]

demo2/entrypoint.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Wait for broker to be healthy
5+
echo "Waiting for broker at ${AGENTWRIT_BROKER_URL}..."
6+
until curl -sf "${AGENTWRIT_BROKER_URL}/v1/health" > /dev/null 2>&1; do
7+
sleep 1
8+
done
9+
echo "Broker is ready."
10+
11+
# Auto-register app if no client credentials provided
12+
if [ -z "${AGENTWRIT_CLIENT_ID}" ] || [ -z "${AGENTWRIT_CLIENT_SECRET}" ]; then
13+
echo "No client credentials — registering app with broker..."
14+
15+
if [ -z "${AGENTWRIT_ADMIN_SECRET}" ]; then
16+
echo "ERROR: AGENTWRIT_ADMIN_SECRET required for auto-registration"
17+
exit 1
18+
fi
19+
20+
# Authenticate as admin
21+
ADMIN_TOKEN=$(curl -sf -X POST "${AGENTWRIT_BROKER_URL}/v1/admin/auth" \
22+
-H "Content-Type: application/json" \
23+
-d "{\"secret\":\"${AGENTWRIT_ADMIN_SECRET}\"}" \
24+
| python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])")
25+
26+
# Register the support ticket demo app
27+
APP_JSON=$(curl -sf -X POST "${AGENTWRIT_BROKER_URL}/v1/admin/apps" \
28+
-H "Content-Type: application/json" \
29+
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
30+
-d '{
31+
"name": "support-ticket-demo",
32+
"scopes": [
33+
"read:tickets:*", "read:customers:*", "write:customers:*",
34+
"read:kb:*", "read:billing:*", "write:billing:*",
35+
"write:notes:*", "write:email:internal", "delete:account:*"
36+
],
37+
"token_ttl": 1800
38+
}')
39+
40+
export AGENTWRIT_CLIENT_ID=$(echo "${APP_JSON}" | python3 -c "import sys,json; print(json.load(sys.stdin)['client_id'])")
41+
export AGENTWRIT_CLIENT_SECRET=$(echo "${APP_JSON}" | python3 -c "import sys,json; print(json.load(sys.stdin)['client_secret'])")
42+
43+
echo "App registered: ${AGENTWRIT_CLIENT_ID}"
44+
fi
45+
46+
echo "Starting Support Ticket Demo on port 5001..."
47+
exec uv run flask --app demo2.app run --host 0.0.0.0 --port 5001

docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,24 @@ services:
3838
broker:
3939
condition: service_healthy
4040

41+
support-tickets:
42+
image: devonartis/agentwrit-support-tickets:latest
43+
build:
44+
context: .
45+
dockerfile: demo2/Dockerfile
46+
ports:
47+
- "${AGENTWRIT_SUPPORT_PORT:-5001}:5001"
48+
environment:
49+
- AGENTWRIT_BROKER_URL=http://broker:8080
50+
- AGENTWRIT_ADMIN_SECRET=${AGENTWRIT_ADMIN_SECRET:-}
51+
- AGENTWRIT_CLIENT_ID=${AGENTWRIT_CLIENT_ID:-}
52+
- AGENTWRIT_CLIENT_SECRET=${AGENTWRIT_CLIENT_SECRET:-}
53+
- LLM_BASE_URL=${LLM_BASE_URL:-https://api.openai.com/v1}
54+
- LLM_API_KEY=${LLM_API_KEY:-}
55+
- LLM_MODEL=${LLM_MODEL:-gpt-4o-mini}
56+
depends_on:
57+
broker:
58+
condition: service_healthy
59+
4160
volumes:
4261
broker-data:

0 commit comments

Comments
 (0)