Skip to content

Commit 123d795

Browse files
committed
testing-farm-sse-bridge: Add container build configuration
The Testing Farm SSE bridge uses a multi-stage Containerfile to build both production and debug images. The Makefile provides common tasks for building and running the containers. Container images need to be built securely with minimal dependencies and proper user permissions. Development environments need additional tools for debugging and testing. This commit addresses that by adding a multi-stage Containerfile that produces both minimal production images and feature-rich debug images. The Makefile simplifies common development tasks like building and running containers.
1 parent f1ccdcc commit 123d795

File tree

6 files changed

+178
-0
lines changed

6 files changed

+178
-0
lines changed

.github/workflows/build-and-push.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,17 @@ jobs:
4848
docker_context: "beeai/"
4949
image_name: "mcp-server"
5050
# tag: "staging"
51+
52+
build-and-push-testing-farm-sse-bridge:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Build and push testing-farm-sse-bridge to quay.io registry
56+
uses: sclorg/build-and-push-action@v4
57+
with:
58+
registry: "quay.io"
59+
registry_namespace: "jotnar"
60+
registry_username: ${{ secrets.REGISTRY_LOGIN }}
61+
registry_token: ${{ secrets.REGISTRY_TOKEN }}
62+
dockerfile: "testing-farm-sse-bridge/Containerfile"
63+
docker_context: "testing-farm-sse-bridge/"
64+
image_name: "testing-farm-sse-bridge"

compose.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ services:
3131
timeout: 2s
3232
retries: 30
3333

34+
testing-farm-sse-bridge:
35+
image: testing-farm-sse-bridge:latest
36+
build:
37+
context: ./testing-farm-sse-bridge
38+
dockerfile: Containerfile
39+
target: ${BUILD_TARGET:-production}
40+
args:
41+
BASE_IMAGE: registry.fedoraproject.org/fedora:42
42+
ports:
43+
- published: "${TESTING_FARM_SSE_BRIDGE_PORT:-10000}"
44+
target: 10000
45+
env_file:
46+
- .secrets/testing-farm-sse-bridge.env
47+
restart: unless-stopped
48+
healthcheck:
49+
test: wget --spider -q "http://127.0.0.1:10000/healthz"
50+
interval: 2s
51+
timeout: 2s
52+
retries: 30
53+
3454
goose:
3555
depends_on:
3656
mcp-atlassian: { condition: service_healthy }

templates/compose.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# CONFIGURATION SPECIFIC TO CONTAINER INVOCATION
22
MCP_ATLASSIAN_PORT=9000
33
MCP_TESTING_FARM_PORT=9010
4+
TESTING_FARM_SSE_BRIDGE_PORT=10000
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Testing Farm SSE Bridge Configuration
2+
# Copy this file to .secrets/testing-farm-sse-bridge.env and adjust values
3+
4+
# Server configuration
5+
HOST=0.0.0.0
6+
PORT=10000
7+
LOG_LEVEL=info
8+
9+
# Testing Farm configuration
10+
TESTING_FARM_API_URL=https://api.testing-farm.io
11+
TESTING_FARM_API_TOKEN=your-token-here
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# This Containerfile contains several stages:
2+
#
3+
# runtime-platform: Fedora base image with the required dependencies
4+
# added on top to run the SSE bridge.
5+
#
6+
# production: Production build with minimal dependencies
7+
#
8+
# debug: Debug build with additional tools
9+
10+
ARG BASE_IMAGE=registry.fedoraproject.org/fedora:42
11+
12+
#
13+
# runtime-platform: Fedora base image with the required dependencies
14+
#
15+
FROM ${BASE_IMAGE} AS runtime-platform
16+
17+
# Install required system packages
18+
RUN dnf -y update \
19+
&& dnf -y install --setopt=install_weak_deps=False python3 uv wget \
20+
&& dnf clean all \
21+
&& rm -rf /var/cache/dnf
22+
23+
# Create non-root user
24+
RUN useradd -m -U bridge \
25+
&& mkdir -p /app \
26+
&& chown -R bridge:bridge /app
27+
28+
USER bridge
29+
WORKDIR /app
30+
31+
#
32+
# production: Production build with minimal dependencies
33+
#
34+
FROM runtime-platform AS production
35+
36+
# Copy only dependency metadata first to maximize layer cache
37+
COPY --chown=bridge:bridge pyproject.toml README.md LICENSE uv.lock ./
38+
39+
# Resolve and install project dependencies into the system environment
40+
USER root
41+
RUN uv export --frozen --no-dev -o /tmp/requirements.txt \
42+
&& uv pip install --system --no-cache -r /tmp/requirements.txt \
43+
&& rm -f /tmp/requirements.txt
44+
USER bridge
45+
46+
# Copy the rest of the project
47+
COPY --chown=bridge:bridge testing_farm_sse_bridge ./testing_farm_sse_bridge
48+
49+
# Install the application itself without re-resolving dependencies
50+
USER root
51+
RUN uv pip install --system --no-cache --no-deps .
52+
USER bridge
53+
54+
EXPOSE 10000
55+
56+
ENV HOST=0.0.0.0 \
57+
PORT=10000
58+
59+
CMD ["testing-farm-sse-bridge"]
60+
61+
#
62+
# debug: Debug build with additional tools
63+
#
64+
FROM runtime-platform AS debug
65+
66+
# Install debug tools
67+
USER root
68+
RUN dnf -y install \
69+
python3-pip \
70+
python3-ipython \
71+
python3-pytest \
72+
&& dnf clean all \
73+
&& rm -rf /var/cache/dnf
74+
USER bridge
75+
76+
# Copy only dependency metadata first to maximize layer cache
77+
COPY --chown=bridge:bridge pyproject.toml README.md LICENSE uv.lock ./
78+
79+
# Resolve and install project dependencies including dev extras
80+
USER root
81+
RUN uv export --frozen --dev -o /tmp/requirements.txt \
82+
&& uv pip install --system --no-cache -r /tmp/requirements.txt \
83+
&& rm -f /tmp/requirements.txt
84+
USER bridge
85+
86+
# Copy the rest of the project
87+
COPY --chown=bridge:bridge pyproject.toml README.md LICENSE ./
88+
COPY --chown=bridge:bridge testing_farm_sse_bridge ./testing_farm_sse_bridge
89+
90+
# Install the application itself without re-resolving dependencies
91+
USER root
92+
RUN uv pip install --system --no-cache --no-deps .
93+
USER bridge
94+
95+
CMD ["testing-farm-sse-bridge", "--host=0.0.0.0", "--port=10000", "--log-level=debug"]

testing-farm-sse-bridge/Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.PHONY: build test clean run
2+
3+
# Default target
4+
all: build
5+
6+
# Build container image
7+
build:
8+
podman build -t testing-farm-sse-bridge:latest -f Containerfile .
9+
10+
# Build debug container image
11+
build-debug:
12+
podman build -t testing-farm-sse-bridge:debug -f Containerfile --target debug .
13+
14+
# Run tests
15+
test:
16+
python3 -m pytest
17+
18+
# Clean build artifacts
19+
clean:
20+
rm -rf build/ dist/ *.egg-info/ __pycache__/ .pytest_cache/
21+
22+
# Run locally with uv
23+
run:
24+
uv pip install -e .
25+
testing-farm-sse-bridge --host=0.0.0.0 --port=10000 --log-level=debug
26+
27+
# Run container
28+
run-container:
29+
podman run --rm -p 10000:10000 \
30+
--env-file ../.secrets/testing-farm-sse-bridge.env \
31+
testing-farm-sse-bridge:latest
32+
33+
# Run debug container
34+
run-container-debug:
35+
podman run --rm -it -p 10000:10000 \
36+
--env-file ../.secrets/testing-farm-sse-bridge.env \
37+
testing-farm-sse-bridge:debug

0 commit comments

Comments
 (0)