Skip to main content
GACS will never ask for your seed phrase, private keys, or payment. free and ad-free.
Back to lessonLab · Module 9 / 12
Lab

Deployment

Hands-on lab with starter code you can copy + run, and guided steps to produce the artifact for this module.

Setup

  1. Open a fresh terminal in a new folder, e.g. mkdir lab-9 && cd lab-9.
  2. Create a Python 3.11 venv: python -m venv .venv && source .venv/bin/activate.
  3. Install the dependencies noted on each starter snippet (the small pip install … line above the code).
  4. Copy each starter into a file with the suggested name, then run it and capture the output.

Starter code

01 · FastAPI wrapper around an agent
pip install fastapi uvicorn
save as: 09_01_lab.py
python
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class Ask(BaseModel):
    question: str

@app.post("/ask")
def ask(body: Ask):
    return {"answer": react(body.question)}

# uvicorn server:app --host 0.0.0.0 --port 8080
Run with: python 09_01_lab.py
02 · Dockerfile for the agent service
save as: 09_02_lab.sh
bash
# Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8080"]
Run with: bash 09_02_lab.sh

Guided steps

Work through each step in order. Stop when your output matches the expected artifact — then push your work to your lab folder.

  1. 1
    FastAPI wrapper

    Do — Expose your agent at POST /ask. Return JSON {answer, steps}.

    Expected artifact — `curl -X POST localhost:8080/ask -d '{"question":"..."}'` returns valid JSON.

    Run free:
  2. 2
    Dockerize

    Do — Write a Dockerfile and run the container locally. Confirm the endpoint works from the host.

    Expected artifact — `docker run -p 8080:8080 my-agent` serves /ask successfully.

    Run free:
  3. 3
    Smoke + health checks

    Do — Add /healthz and a smoke test script that POSTs 3 known-good prompts.

    Expected artifact — smoke.sh exits 0 when service is healthy and answers are sane.

    Run free:

Authoritative sources

Independent primary sources used to check and corroborate the guidance on this page.