Skip engine free-port probe in containers (fixed port)

This commit is contained in:
Anthony Stirling
2026-06-11 20:18:54 +01:00
parent 37b4d24a95
commit d48017a5b5
2 changed files with 36 additions and 4 deletions
+32 -4
View File
@@ -37,9 +37,23 @@ tasks:
dir: src
vars:
# When PORT is provided (e.g. from dev:all), use it directly.
# When running standalone, probe for a free port starting at 5001.
# With ENGINE_PORT_PROBE=false (Docker), use the fixed STIRLING_ENGINE_PORT
# (default 5001) without probing. Otherwise probe for a free port from 5001.
PORT:
sh: '{{if .PORT}}echo {{.PORT}}{{else if eq OS "windows"}}{{.ENGINE_FIND_FREE_PORT_PS}} 5001{{else}}{{.ENGINE_FIND_FREE_PORT_SH}} 5001{{end}}'
sh: |
if [ -n "{{.PORT}}" ]; then
echo "{{.PORT}}"
elif [ -f /.dockerenv ] || [ "${ENGINE_PORT_PROBE:-true}" = "false" ]; then
# Never probe in a container: the port is fixed and the probe script
# isn't shipped in the image. /.dockerenv auto-detects Docker; the
# ENGINE_PORT_PROBE=false flag forces fixed-port mode anywhere else.
# The probe is a dev-only convenience for avoiding local port clashes.
echo "${STIRLING_ENGINE_PORT:-5001}"
elif [ "{{OS}}" = "windows" ]; then
{{.ENGINE_FIND_FREE_PORT_PS}} 5001
else
{{.ENGINE_FIND_FREE_PORT_SH}} 5001
fi
env:
PYTHONUNBUFFERED: "1"
cmds:
@@ -52,9 +66,23 @@ tasks:
dir: src
vars:
# When PORT is provided (e.g. from dev:all), use it directly.
# When running standalone, probe for a free port starting at 5001.
# With ENGINE_PORT_PROBE=false (Docker), use the fixed STIRLING_ENGINE_PORT
# (default 5001) without probing. Otherwise probe for a free port from 5001.
PORT:
sh: '{{if .PORT}}echo {{.PORT}}{{else if eq OS "windows"}}{{.ENGINE_FIND_FREE_PORT_PS}} 5001{{else}}{{.ENGINE_FIND_FREE_PORT_SH}} 5001{{end}}'
sh: |
if [ -n "{{.PORT}}" ]; then
echo "{{.PORT}}"
elif [ -f /.dockerenv ] || [ "${ENGINE_PORT_PROBE:-true}" = "false" ]; then
# Never probe in a container: the port is fixed and the probe script
# isn't shipped in the image. /.dockerenv auto-detects Docker; the
# ENGINE_PORT_PROBE=false flag forces fixed-port mode anywhere else.
# The probe is a dev-only convenience for avoiding local port clashes.
echo "${STIRLING_ENGINE_PORT:-5001}"
elif [ "{{OS}}" = "windows" ]; then
{{.ENGINE_FIND_FREE_PORT_PS}} 5001
else
{{.ENGINE_FIND_FREE_PORT_SH}} 5001
fi
env:
PYTHONUNBUFFERED: "1"
cmds:
+4
View File
@@ -27,6 +27,10 @@ COPY .taskfiles/ ./.taskfiles/
ENV PATH="/app/engine/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1
ENV STIRLING_ENGINE_WORKERS=4
# Container runs on a fixed port; skip the host-only free-port probe (its script
# is not shipped in the image). engine:run honours these.
ENV ENGINE_PORT_PROBE=false
ENV STIRLING_ENGINE_PORT=5001
EXPOSE 5001