Skip to content

Commit d3b8c5c

Browse files
authored
Merge pull request packit#90 from halfline/add-testing-farm-sse-bridge
Add testing farm sse bridge
2 parents 5bdf6cb + 123d795 commit d3b8c5c

File tree

15 files changed

+886
-0
lines changed

15 files changed

+886
-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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
__pycache__/
2+
*.py[cod]
3+
*.egg-info/
4+
.dist-info/
5+
.eggs/
6+
.git/
7+
.gitignore
8+
venv/
9+
.venv/
10+
.env
11+
.cache/
12+
.pytest_cache/
13+
dist/
14+
build/
15+
.coverage
16+
junit.xml
17+
Containerfile
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/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Red Hat, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

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

testing-farm-sse-bridge/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Testing Farm SSE Bridge
2+
3+
A FastAPI-based SSE bridge for Testing Farm requests.
4+
5+
## Overview
6+
7+
The Testing Farm SSE Bridge provides a Server-Sent Events (SSE) interface for Testing Farm requests, making it easier to integrate Testing Farm with other services.
8+
9+
## Features
10+
11+
- SSE endpoint for Testing Farm requests
12+
- FastAPI-based REST API
13+
- Configurable via environment variables
14+
- Container-ready with multi-stage builds
15+
16+
## Quick Start
17+
18+
### Using Podman Compose
19+
20+
1. Copy the environment template:
21+
```bash
22+
cp templates/testing-farm-sse-bridge.env .secrets/testing-farm-sse-bridge.env
23+
```
24+
25+
2. Edit `.secrets/testing-farm-sse-bridge.env` and set your Testing Farm token.
26+
27+
3. Start the service:
28+
```bash
29+
podman compose up testing-farm-sse-bridge
30+
```
31+
32+
### Manual Setup
33+
34+
1. Install dependencies:
35+
```bash
36+
pip install .
37+
```
38+
39+
2. Set required environment variables:
40+
```bash
41+
export TESTING_FARM_API_TOKEN=your-token-here
42+
export TESTING_FARM_API_URL=https://api.testing-farm.io
43+
```
44+
45+
3. Run the service:
46+
```bash
47+
testing-farm-sse-bridge --host=0.0.0.0 --port=10000
48+
```
49+
50+
## Container Images
51+
52+
Pre-built container images are available on Quay.io:
53+
54+
```bash
55+
podman pull quay.io/jotnar/testing-farm-sse-bridge:latest
56+
```
57+
58+
### Building Locally
59+
60+
Build the production image:
61+
```bash
62+
podman build -t testing-farm-sse-bridge:latest -f Containerfile .
63+
```
64+
65+
Build with debug tools:
66+
```bash
67+
podman build -t testing-farm-sse-bridge:debug -f Containerfile --target debug .
68+
```
69+
70+
## Configuration
71+
72+
The service is configured via environment variables:
73+
74+
| Variable | Description | Default |
75+
|----------|-------------|---------|
76+
| HOST | Server host | 0.0.0.0 |
77+
| PORT | Server port | 10000 |
78+
| LOG_LEVEL | Logging level (debug, info, warning, error) | info |
79+
| TESTING_FARM_API_URL | Testing Farm API URL | https://api.testing-farm.io |
80+
| TESTING_FARM_API_TOKEN | Testing Farm API token | Required |
81+
| TESTING_FARM_POLL_INTERVAL | Poll interval in seconds | 5.0 |
82+
| TESTING_FARM_TIMEOUT | Request timeout in seconds | 30.0 |
83+
84+
## Development
85+
86+
Install development dependencies:
87+
```bash
88+
pip install ".[dev]"
89+
```
90+
91+
Run tests:
92+
```bash
93+
pytest
94+
```
95+
96+
## License
97+
98+
MIT License - see LICENSE file for details.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[project]
2+
name = "testing-farm-sse-bridge"
3+
version = "0.1.0"
4+
description = "FastAPI-based SSE bridge for Testing Farm requests"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
license = { text = "MIT" }
8+
authors = [
9+
{ name = "Ray Strode", email = "[email protected]" },
10+
]
11+
keywords = ["testing-farm", "sse", "fastapi", "uvicorn"]
12+
classifiers = [
13+
"Programming Language :: Python :: 3",
14+
"Programming Language :: Python :: 3 :: Only",
15+
"Programming Language :: Python :: 3.10",
16+
"Programming Language :: Python :: 3.11",
17+
"Programming Language :: Python :: 3.12",
18+
"License :: OSI Approved :: MIT License",
19+
"Framework :: FastAPI",
20+
"Topic :: Internet :: WWW/HTTP",
21+
]
22+
23+
# Runtime dependencies
24+
dependencies = [
25+
"fastapi>=0.111.0",
26+
"httpx>=0.27.0",
27+
"uvicorn>=0.30.0",
28+
]
29+
30+
[build-system]
31+
requires = ["hatchling>=1.25.0"]
32+
build-backend = "hatchling.build"
33+
34+
[project.scripts]
35+
# CLI entrypoint: `testing-farm-sse-bridge` → launches uvicorn
36+
"testing-farm-sse-bridge" = "testing_farm_sse_bridge.__main__:main"
37+
# Convenience scripts for container build and run
38+
"container-build" = "testing_farm_sse_bridge.build_container:main"
39+
"container" = "testing_farm_sse_bridge.run_container:main"
40+
41+
42+
[tool.hatch.build]
43+
include = [
44+
"testing_farm_sse_bridge",
45+
"README.md",
46+
"LICENSE",
47+
]

0 commit comments

Comments
 (0)