Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 9 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}"
Loading