Skip to content

Commit c47b661

Browse files
committed
Add Docker support for openapi-bridge
1 parent 2b64443 commit c47b661

File tree

2 files changed

+61
-34
lines changed

2 files changed

+61
-34
lines changed

app/openapi-bridge/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM eclipse-temurin:21-jdk AS builder
2+
WORKDIR /work
3+
4+
COPY . .
5+
6+
RUN chmod +x ./gradlew && ./gradlew --no-daemon :app:openapi-bridge:installDist -x test
7+
8+
FROM eclipse-temurin:21-jdk
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
WORKDIR /opt
11+
12+
RUN apt-get update \
13+
&& apt-get install -y --no-install-recommends curl ca-certificates unzip \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
ENV CODEQL_VERSION=2.16.6
17+
RUN mkdir -p /opt/codeql \
18+
&& curl -L "https://github.com/github/codeql-action/releases/download/codeql-bundle-v${CODEQL_VERSION}/codeql-bundle-linux64.tar.gz" \
19+
-o /tmp/codeql.tgz \
20+
&& tar -xzf /tmp/codeql.tgz -C /opt/codeql --strip-components=1 \
21+
&& rm /tmp/codeql.tgz
22+
ENV PATH="/opt/codeql:${PATH}"
23+
24+
COPY --from=builder /work/app/openapi-bridge/build/install/openapi-bridge /opt/openapi-bridge
25+
26+
ENV PORT="8080"
27+
ENV OLLAMA_BASE_URL="http://host.docker.internal:11434"
28+
ENV OLLAMA_KEEP_ALIVE="5m"
29+
30+
EXPOSE 8080
31+
32+
ENTRYPOINT ["/opt/openapi-bridge/bin/openapi-bridge"]

app/openapi-bridge/README.md

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,50 @@
11
# OpenAPI Bridge Server
22
This module contains the HTTP server. It exposes a minimal OpenAI-style `POST /v1/chat/completions` endpoint backed by the SecureCoder engine.
33

4-
## Prerequisites
5-
- JDK 21
6-
- Optional but recommended for security analysis features: CodeQL CLI in `PATH` (the Guardian uses it when analyzing code). If not present, some security analysis steps may fail.
4+
## Run with Docker
75

6+
### Configuration
7+
- OpenRouter mode:
8+
- `OPENROUTER_KEY` — your OpenRouter API key
9+
- `MODEL` — model ID (e.g.: `openai/gpt-oss-20b`)
10+
- Ollama mode (used when `OPENROUTER_KEY` is not set):
11+
- `MODEL` — Ollama model name (e.g.: `gpt-oss:20`)
12+
- `OLLAMA_BASE_URL` — base URL to Ollama (default: 11434 on the host)
13+
- `OLLAMA_KEEP_ALIVE` — keep-alive duration (default: `5m`)
814

9-
## Configuration (Environment Variables or -D system properties)
10-
The server reads its configuration from either environment variables or JVM system properties (`-DNAME=value`).
11-
12-
- `PORT` — HTTP port (default: `8080`)
13-
- LLM selection (EngineFactory picks the first matching provider):
14-
- OpenRouter mode:
15-
- `OPENROUTER_KEY` — your OpenRouter API key
16-
- `MODEL` — model ID (default: `openai/gpt-oss-20b`)
17-
- Ollama mode (used when `OPENROUTER_KEY` is not set):
18-
- `MODEL` — Ollama model name, e.g. `llama3.1:8b`
19-
- `OLLAMA_BASE_URL` — base URL to Ollama (default: `http://127.0.0.1:11434`)
20-
- `OLLAMA_KEEP_ALIVE` — keep-alive duration (default: `5m`)
21-
22-
23-
## How to run the server
24-
25-
On macOS/Linux (using -D system properties):
26-
15+
### Build and run
16+
Make sure you have Docker installed and are in the project root directory.
2717
```
28-
./gradlew :app:openapi-bridge:run -DOPENROUTER_KEY=... -DMODEL=...
18+
docker build -f app/openapi-bridge/Dockerfile -t openapi-bridge:latest .
2919
```
3020

31-
Or with environment variables:
32-
21+
Run with Ollama on the host (macOS/Windows):
3322
```
34-
export OPENROUTER_KEY=...
35-
export MODEL=...
36-
./gradlew :app:openapi-bridge:run
23+
docker run --rm -p 8080:8080 \
24+
-e MODEL="llama3.1:8b" \
25+
openapi-bridge:latest
3726
```
3827

39-
On Windows
28+
Run with Ollama on the host (Linux):
29+
```
30+
docker run --rm -p 8080:8080 \
31+
--add-host=host.docker.internal:host-gateway \
32+
-e MODEL="llama3.1:8b" \
33+
openapi-bridge:latest
34+
```
4035

36+
Run using OpenRouter instead of Ollama:
4137
```
42-
set OPENROUTER_KEY=...
43-
set MODEL=...
44-
gradlew.bat :app:openapi-bridge:run
38+
docker run --rm -p 8080:8080 \
39+
-e OPENROUTER_KEY=... \
40+
-e MODEL=openai/gpt-oss-20b \
41+
openapi-bridge:latest
4542
```
4643

4744
## Endpoint
48-
4945
- `POST /v1/chat/completions` — accepts a minimal OpenAI-style request and returns a single choice with the SecureCoder engine’s response.
5046

51-
Example request (curl):
52-
47+
Example request (from host):
5348
```
5449
curl -X POST "http://localhost:8080/v1/chat/completions" \
5550
-H "Content-Type: application/json" \

0 commit comments

Comments
 (0)