Skip to content

Commit 160f86a

Browse files
Merge pull request #9 from marcinkantyka/feat/docker_compose
Add NETWORK_ALLOWED_HOSTS configuration and update LLM provider logic
2 parents 5635f8c + 1650825 commit 160f86a

7 files changed

Lines changed: 36 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export LLM_PROVIDER=ollama
205205
export LLM_API_KEY=your-key-here # Optional
206206
export LLM_TIMEOUT=60000
207207
export LLM_SEED=42 # Optional
208+
export NETWORK_ALLOWED_HOSTS=ollama,localhost,127.0.0.1,::1
208209
```
209210

210211
Run `pr-review config init` to generate a default config file with all the available options.

docker/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ cd /path/to/your/repo
7171
./run-review.sh review --base main
7272
```
7373

74+
### Run via docker-compose (manual profile):
75+
76+
Set `REPO_PATH` to the repository you want to scan, then run:
77+
78+
```bash
79+
REPO_PATH=/path/to/your/repo docker-compose up pr-review
80+
```
81+
82+
This mounts the repo read-only at `/workspace` and writes outputs to `docker/output`.
83+
7484
### Alternative: Manual docker run
7585

7686
If you prefer to use docker run directly:

docker/docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ services:
3131
# Use run-review.sh script or docker run to execute commands
3232
profiles:
3333
- manual
34+
volumes:
35+
- ${REPO_PATH:?Set REPO_PATH to the target git repo}:/workspace:ro
36+
- ./output:/output
37+
environment:
38+
- LLM_PROVIDER=ollama
39+
- LLM_ENDPOINT=http://ollama:11434
40+
- LLM_MODEL=deepseek-coder:6.7b
41+
- NETWORK_ALLOWED_HOSTS=ollama,localhost,127.0.0.1,::1
42+
- NETWORK_STRICT_MODE=true
43+
working_dir: /workspace
3444

3545
networks:
3646
pr-review-network:

docker/run-review.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ docker run --rm -it \
7878
-v "$SCRIPT_DIR/output:/output" \
7979
-e LLM_ENDPOINT=http://ollama:11434 \
8080
-e LLM_MODEL=deepseek-coder:6.7b \
81+
-e NETWORK_ALLOWED_HOSTS=ollama,localhost,127.0.0.1,::1 \
8182
-e NETWORK_STRICT_MODE=true \
8283
-w /workspace \
8384
pr-reviewer-pr-review:${VERSION} \

src/core/llm/providers.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,26 +358,27 @@ export class MockProvider implements LLMProvider {
358358
/**
359359
* Provider Factory
360360
*/
361-
export function createLLMProvider(config: LLMConfig): LLMProvider {
361+
export function createLLMProvider(config: LLMConfig, allowedHosts?: string[]): LLMProvider {
362362
const { provider, endpoint, apiKey } = config;
363363

364364
if (provider === 'mock') {
365365
return new MockProvider();
366366
}
367367

368368
// SECURITY: Validate endpoint is localhost only
369-
const allowedHosts = ['localhost', '127.0.0.1', '::1'];
370-
validateEndpoint(endpoint, allowedHosts);
369+
const resolvedAllowedHosts =
370+
allowedHosts && allowedHosts.length > 0 ? allowedHosts : ['localhost', '127.0.0.1', '::1'];
371+
validateEndpoint(endpoint, resolvedAllowedHosts);
371372

372373
switch (provider) {
373374
case 'ollama':
374-
return new OllamaProvider(endpoint, apiKey, allowedHosts);
375+
return new OllamaProvider(endpoint, apiKey, resolvedAllowedHosts);
375376
case 'vllm':
376-
return new VLLMProvider(endpoint, apiKey, allowedHosts);
377+
return new VLLMProvider(endpoint, apiKey, resolvedAllowedHosts);
377378
case 'llamacpp':
378-
return new LlamaCppProvider(endpoint, apiKey, allowedHosts);
379+
return new LlamaCppProvider(endpoint, apiKey, resolvedAllowedHosts);
379380
case 'openai-compatible':
380-
return new OpenAICompatibleProvider(endpoint, apiKey, allowedHosts);
381+
return new OpenAICompatibleProvider(endpoint, apiKey, resolvedAllowedHosts);
381382
default:
382383
throw new ConfigError(`Unknown LLM provider: ${provider}`);
383384
}

src/core/review/engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ReviewEngine {
1818
private analyzer: ReviewAnalyzer;
1919

2020
constructor(private readonly config: AppConfig) {
21-
const provider = createLLMProvider(config.llm);
21+
const provider = createLLMProvider(config.llm, config.network.allowedHosts);
2222
this.llmClient = new LLMClient(
2323
provider,
2424
config.llm.timeout,

src/core/storage/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ export async function loadConfig(configPath?: string): Promise<AppConfig> {
131131
if (process.env.LLM_SEED) {
132132
config.llm!.seed = parseInt(process.env.LLM_SEED, 10);
133133
}
134+
if (process.env.NETWORK_ALLOWED_HOSTS) {
135+
config.network!.allowedHosts = process.env.NETWORK_ALLOWED_HOSTS.split(',')
136+
.map((host) => host.trim())
137+
.filter((host) => host.length > 0);
138+
}
134139

135140
try {
136141
return validateConfig(config) as AppConfig;

0 commit comments

Comments
 (0)