Skip to content

feat: containerize marketing_strategy example #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions marketing_strategy/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!pyproject.toml
!poetry.lock
!src
*.pyc
23 changes: 23 additions & 0 deletions marketing_strategy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.12-slim

RUN apt-get update && apt-get install -y build-essential && \
rm -rf /var/lib/apt/lists/*
RUN pip install poetry
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-interaction --no-root
COPY . .
RUN poetry install
COPY <<EOF /entrypoint.sh
#!/bin/sh
set -e
if test -z \${OPENAI_API_KEY}; then
echo "OPENAI_API_KEY is not set, using Docker Model Runner \${MODEL_RUNNER_URL}"
export OPENAI_BASE_URL=\${MODEL_RUNNER_URL}
export OPENAI_MODEL_NAME=openai/\${MODEL_RUNNER_MODEL}
export OPENAI_API_KEY=does_not_matter_but_cannot_be_empty
fi
exec poetry run marketing_posts
EOF
RUN chmod +x /entrypoint.sh
CMD ["/entrypoint.sh"]
4 changes: 4 additions & 0 deletions marketing_strategy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ It uses GPT-4o by default so you should have access to that to run it.
- **Customize Further**: Check `src/marketing_posts/config/agents.yaml` to update your agents and `src/marketing_posts/config/tasks.yaml` to update your tasks.
- **Execute the Script**: Run `poetry run marketing_posts` and input your project details.

## Running the Script in Docker
Run `docker compose up`. There's no need to configure any keys, by default the containerized script uses
[Docker Model Runner](https://docs.docker.com/ai/model-runner/) and [Docker MCP Catalog](https://hub.docker.com/catalogs/mcp).

## Details & Explanation
- **Running the Script**: Execute `poetry run marketing_posts`. The script will leverage the CrewAI framework to generate a detailed marketing strategy.
- **Key Components**:
Expand Down
32 changes: 32 additions & 0 deletions marketing_strategy/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
services:
agents:
build:
context: .
environment:
- OPENAI_API_KEY=$OPENAI_API_KEY
- SERPER_API_KEY=$SERPER_API_KEY
- MCP_SERVER_URL=http://mcp_gateway:8811/sse
restart: no
extra_hosts:
- host.docker.internal:host-gateway
depends_on:
- model_runner
- mcp_gateway

mcp_gateway:
image: docker/agents_gateway:v2
ports:
- 8811:8811
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
command:
- --transport=sse
- --servers=duckduckgo
- --tools=search
- --tools=fetch_content

model_runner:
provider:
type: model
options:
model: ai/qwen3
6,370 changes: 6,370 additions & 0 deletions marketing_strategy/poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions marketing_strategy/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ authors = [
]
requires-python = ">=3.10,<=3.13"
dependencies = [
"crewai[tools]==0.85.0",
"crewai-tools>=0.4.6",
"crewai[tools]>=0.85.0",
"crewai-tools[mcp]>=0.4.6",
"setuptools (>=80.9.0,<81.0.0)",
]

[project.scripts]
Expand Down
4,233 changes: 2,119 additions & 2,114 deletions marketing_strategy/uv.lock

Large diffs are not rendered by default.