diff --git a/README.md b/README.md index c6ee7be..134d92e 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,8 @@ The server starts on port 4096. Mount your project at `/home/opencode` to persis | `OPENCODE_PORT` | `4096` | Port the server listens on | | `OPENCODE_SERVER_PASSWORD` | *(none)* | Optional auth password for the server | | `OPENCODE_CORS_ORIGIN` | *(none)* | Optional CORS origin; omit to disable CORS | +| `OPENCODE_PRINT_LOGS` | `false` | Set to `true` to print OpenCode logs to container stderr | +| `OPENCODE_LOG_LEVEL` | *(OpenCode default)* | Optional `DEBUG`, `INFO`, `WARN`, or `ERROR` log level | ### Examples diff --git a/entrypoint.sh b/entrypoint.sh index dd896fd..1e7651a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,7 +4,14 @@ set -euo pipefail mkdir -p "${HOME}/.config/opencode" "${HOME}/workspace" cd "${HOME}/workspace" +args=(serve --hostname 0.0.0.0 --port "${OPENCODE_PORT:-4096}") +if [ "${OPENCODE_PRINT_LOGS:-false}" = "true" ]; then + args+=(--print-logs) +fi +if [ -n "${OPENCODE_LOG_LEVEL:-}" ]; then + args+=(--log-level "${OPENCODE_LOG_LEVEL}") +fi if [ -n "${OPENCODE_CORS_ORIGIN:-}" ]; then - exec opencode serve --hostname 0.0.0.0 --port "${OPENCODE_PORT:-4096}" --cors "${OPENCODE_CORS_ORIGIN}" + args+=(--cors "${OPENCODE_CORS_ORIGIN}") fi -exec opencode serve --hostname 0.0.0.0 --port "${OPENCODE_PORT:-4096}" +exec opencode "${args[@]}"