Skip to content
Closed
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
51 changes: 51 additions & 0 deletions .github/workflows/build-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Push Agent Image

on:
push:
tags:
- "release-*"

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install BeeAI CLI
run: pip install beeai-cli

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker
uses: docker/setup-docker-action@v4
with:
daemon-config: '{"features": {"containerd-snapshotter": true}}'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract version from tag
id: extract_version
run: |
# Extract version from tag (e.g., release-1.2.3 -> 1.2.3)
VERSION=${GITHUB_REF#refs/tags/release-}
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Build and Push
run: |
beeai build ./ --tag ghcr.io/${{ github.repository }}/content-planner:${{ steps.extract_version.outputs.version }} --no-import --multi-platform --push --dockerfile ./samples/python/agents/content_planner/Dockerfile
32 changes: 32 additions & 0 deletions samples/python/agents/content_planner/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM python:3.13-slim-trixie

RUN apt-get update && apt-get install -y curl git && \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && rm -rf /var/lib/apt/lists/*
Comment on lines +3 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

To minimize the Docker image size, it's a good practice to use the --no-install-recommends flag with apt-get install. This prevents the installation of packages that are only "recommended" and not strictly "depended" upon, which are often not needed and can increase the image size unnecessarily.

RUN apt-get update && apt-get install -y --no-install-recommends curl git && \
    curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y --no-install-recommends nodejs && \
    apt-get clean && rm -rf /var/lib/apt/lists/*


COPY --from=ghcr.io/astral-sh/uv:0.7.15 /uv /bin/

ENV UV_LINK_MODE=copy \
PRODUCTION_MODE=true
Comment on lines +10 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The environment variable PRODUCTION_MODE is set here and then again on line 18. This is redundant, and the second declaration will overwrite the first. To avoid confusion and keep the Dockerfile clean, you should set this variable only once. I recommend removing this declaration and only keeping the one on line 18.

ENV UV_LINK_MODE=copy


COPY samples/python/agents/content_planner/ /app
WORKDIR /app

RUN uv sync --no-cache --locked --link-mode copy
Comment on lines +13 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To better leverage Docker's layer caching, you should first copy only the dependency-related files (pyproject.toml and uv.lock) and install the dependencies before copying the rest of the application source code. This way, Docker won't need to reinstall all dependencies every time you make a change to your source code, which will significantly speed up your builds.

WORKDIR /app
COPY samples/python/agents/content_planner/pyproject.toml samples/python/agents/content_planner/uv.lock ./
RUN uv sync --no-cache --locked --link-mode copy
COPY samples/python/agents/content_planner/ .


ENV PRODUCTION_MODE=True \
PATH="/app/.venv/bin:$PATH" \
HOME=/tmp

# Create a startup script
RUN echo '#!/bin/bash' > /app/start.sh && \
echo 'uv run . &' >> /app/start.sh && \
echo 'npx --yes tomkis/beeai-a2a-proxy start -p 8000 -r GOOGLE_API_KEY &' >> /app/start.sh && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The npx --yes tomkis/beeai-a2a-proxy command downloads and runs the proxy every time the container starts. This can introduce startup delays and makes your container's behavior dependent on network availability and the state of the npm registry. For better performance and reproducibility, it's recommended to install this tool during the image build process.

You can achieve this by:

  1. Adding npm install -g tomkis/beeai-a2a-proxy to your package installation RUN step (e.g., on line 5).
  2. Changing this line to call the globally installed proxy directly.
    echo 'beeai-a2a-proxy start -p 8000 -r GOOGLE_API_KEY &' >> /app/start.sh && \

echo 'wait' >> /app/start.sh && \
chmod +x /app/start.sh

EXPOSE 8000

CMD ["/bin/bash", "/app/start.sh"]

Loading