mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
feat(docker): expose OpenCode port with required authentication
- Expose port 5551 in docker-compose.yml for direct OpenCode access - Add OPENCODE_HOST=0.0.0.0 environment variable for Docker deployments - Require OPENCODE_SERVER_PASSWORD when exposing OpenCode externally - Update internal connection logic to use 127.0.0.1 when bound to 0.0.0.0 - Update .env.example and Docker documentation with security requirements
This commit is contained in:
1 parent
26a8532cc6
commit
986554df66
5 files changed
+12
-4
No files matched your search
+2
-2
@@ -17,9 +17,9 @@ LOG_LEVEL=info
|
||||
OPENCODE_SERVER_PORT=5551
|
||||
OPENCODE_HOST=127.0.0.1
|
||||
|
||||
# Optional - bearer password required to talk to the spawned OpenCode server.
|
||||
# Required if OPENCODE_HOST is set to 0.0.0.0 or port 5551 is published.
|
||||
# When set, the backend spawns OpenCode with this password and attaches it to
|
||||
# every proxied request. Leave unset to disable OpenCode-level auth.
|
||||
# every proxied request. Leave unset only when OpenCode is bound to localhost.
|
||||
# OPENCODE_SERVER_PASSWORD=
|
||||
|
||||
# Optional - import an existing standalone OpenCode install on first startup
|
||||
|
||||
@@ -24,6 +24,7 @@ import { patchOpenCodeConfig } from './proxy'
|
||||
|
||||
const OPENCODE_SERVER_PORT = ENV.OPENCODE.PORT
|
||||
const OPENCODE_SERVER_HOST = ENV.OPENCODE.HOST
|
||||
const OPENCODE_SERVER_CONNECT_HOST = OPENCODE_SERVER_HOST === '0.0.0.0' ? '127.0.0.1' : OPENCODE_SERVER_HOST
|
||||
const OPENCODE_SERVER_PUBLIC_URL = ENV.OPENCODE.PUBLIC_URL
|
||||
const OPENCODE_SERVER_PASSWORD = ENV.OPENCODE.SERVER_PASSWORD
|
||||
const OPENCODE_SERVER_USERNAME = ENV.OPENCODE.SERVER_USERNAME
|
||||
@@ -549,7 +550,7 @@ class OpenCodeServerManager {
|
||||
if (OPENCODE_BASIC_AUTH) {
|
||||
headers.Authorization = OPENCODE_BASIC_AUTH
|
||||
}
|
||||
const response = await fetch(`http://${OPENCODE_SERVER_HOST}:${OPENCODE_SERVER_PORT}/doc`, {
|
||||
const response = await fetch(`http://${OPENCODE_SERVER_CONNECT_HOST}:${OPENCODE_SERVER_PORT}/doc`, {
|
||||
signal: AbortSignal.timeout(3000),
|
||||
headers
|
||||
})
|
||||
|
||||
@@ -3,7 +3,8 @@ import { ENV } from '@opencode-manager/shared/config/env'
|
||||
import { parseJsonc } from '@opencode-manager/shared/utils'
|
||||
import { timingSafeEqual } from 'crypto'
|
||||
|
||||
export const OPENCODE_SERVER_URL = `http://${ENV.OPENCODE.HOST}:${ENV.OPENCODE.PORT}`
|
||||
const OPENCODE_CONNECT_HOST = ENV.OPENCODE.HOST === '0.0.0.0' ? '127.0.0.1' : ENV.OPENCODE.HOST
|
||||
export const OPENCODE_SERVER_URL = `http://${OPENCODE_CONNECT_HOST}:${ENV.OPENCODE.PORT}`
|
||||
const OPENCODE_SERVER_PASSWORD = ENV.OPENCODE.SERVER_PASSWORD
|
||||
const OPENCODE_SERVER_USERNAME = ENV.OPENCODE.SERVER_USERNAME
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ services:
|
||||
container_name: opencode-manager
|
||||
ports:
|
||||
- "5003:5003"
|
||||
- "5551:5551"
|
||||
- "5100:5100"
|
||||
- "5101:5101"
|
||||
- "5102:5102"
|
||||
@@ -15,6 +16,8 @@ services:
|
||||
- HOST=0.0.0.0
|
||||
- PORT=5003
|
||||
- OPENCODE_SERVER_PORT=5551
|
||||
- OPENCODE_HOST=0.0.0.0
|
||||
- OPENCODE_SERVER_PASSWORD=${OPENCODE_SERVER_PASSWORD:?Set OPENCODE_SERVER_PASSWORD before exposing OpenCode on port 5551}
|
||||
- DATABASE_PATH=/app/data/opencode.db
|
||||
- WORKSPACE_PATH=/workspace
|
||||
- PROCESS_START_WAIT_MS=2000
|
||||
|
||||
@@ -38,6 +38,7 @@ services:
|
||||
container_name: opencode-manager
|
||||
ports:
|
||||
- "5003:5003"
|
||||
- "5551:5551"
|
||||
- "5100:5100"
|
||||
- "5101:5101"
|
||||
- "5102:5102"
|
||||
@@ -47,6 +48,8 @@ services:
|
||||
- HOST=0.0.0.0
|
||||
- PORT=5003
|
||||
- OPENCODE_SERVER_PORT=5551
|
||||
- OPENCODE_HOST=0.0.0.0
|
||||
- OPENCODE_SERVER_PASSWORD=${OPENCODE_SERVER_PASSWORD:?Set OPENCODE_SERVER_PASSWORD before exposing OpenCode on port 5551}
|
||||
- DATABASE_PATH=/app/data/opencode.db
|
||||
- WORKSPACE_PATH=/workspace
|
||||
- PROCESS_START_WAIT_MS=2000
|
||||
|
||||
Reference in new issue
Block a user