From 07bbd38dd682d425ffeaf472b579b472886dc1a2 Mon Sep 17 00:00:00 2001 From: Patrick Gower Date: Wed, 18 Mar 2026 12:27:57 +0000 Subject: [PATCH 1/3] fix(docker): fixed port mapping to allow custom ports to be reachable and healthchecks to work --- docker-compose.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0b155e8..33a815d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,13 +6,14 @@ services: env_file: .env environment: - CHATGPT_LOCAL_HOME=/data + - PORT=${PORT:-8000} ports: - - "8000:8000" + - "${PORT:-8000}:${PORT:-8000}" volumes: - chatmock_data:/data - ./prompt.md:/app/prompt.md:ro healthcheck: - test: ["CMD-SHELL", "python -c \"import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8000/health').status==200 else 1)\" "] + test: ["CMD-SHELL", "python -c \"import os,urllib.request,sys; port=os.getenv('PORT', '8000'); sys.exit(0 if urllib.request.urlopen(f'http://127.0.0.1:{port}/health').status==200 else 1)\" "] interval: 10s timeout: 5s retries: 5 From 048a716dfd01b6811e24ea11455da67afac92f0f Mon Sep 17 00:00:00 2001 From: Patrick Gower Date: Wed, 18 Mar 2026 12:28:57 +0000 Subject: [PATCH 2/3] docs(custom ports): made language about custom ports more clear --- DOCKER.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DOCKER.md b/DOCKER.md index db9191f..4148293 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -14,11 +14,13 @@ 3) Start the server: docker compose up -d chatmock + - Compose publishes the same host port as `PORT` from `.env`, so changing `PORT` changes the URL you should use. + 4) Free to use it in whichever chat app you like! ## Configuration Set options in `.env` or pass environment variables: -- `PORT`: Container listening port (default 8000) +- `PORT`: Container listening port and published host port for the `chatmock` service (default 8000) - `CHATMOCK_IMAGE`: image tag to run (default `storagetime/chatmock:latest`) - `VERBOSE`: `true|false` to enable request/stream logs - `CHATGPT_LOCAL_REASONING_EFFORT`: minimal|low|medium|high|xhigh @@ -34,8 +36,8 @@ Set `VERBOSE=true` to include extra logging for debugging issues in upstream or ## Test -``` -curl -s http://localhost:8000/v1/chat/completions \ +```bash +curl -s "http://localhost:${PORT:-8000}/v1/chat/completions" \ -H 'Content-Type: application/json' \ -d '{"model":"gpt-5-codex","messages":[{"role":"user","content":"Hello world!"}]}' | jq . ``` From a8ec7dd7e246c55f40f0778123712951e78ef60b Mon Sep 17 00:00:00 2001 From: Patrick Gower Date: Wed, 18 Mar 2026 12:33:10 +0000 Subject: [PATCH 3/3] feat(bind to localhost): bind ports to localhost to prevent exposing server docker often bypasses firewalls like UFW in Linux meaning that if running on a server without binding to localhost it could lead expose your instance --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 33a815d..5503081 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: - CHATGPT_LOCAL_HOME=/data - PORT=${PORT:-8000} ports: - - "${PORT:-8000}:${PORT:-8000}" + - "127.0.0.1:${PORT:-8000}:${PORT:-8000}" volumes: - chatmock_data:/data - ./prompt.md:/app/prompt.md:ro @@ -25,11 +25,11 @@ services: command: ["login"] environment: - CHATGPT_LOCAL_HOME=/data - - CHATGPT_LOCAL_LOGIN_BIND=0.0.0.0 + - CHATGPT_LOCAL_LOGIN_BIND=127.0.0.1 volumes: - chatmock_data:/data ports: - - "1455:1455" + - "127.0.0.1:1455:1455" volumes: chatmock_data: