Files
openchamber/scripts/docker-entrypoint.sh
T
nzlov 6ca2b0da05 feat(container): add Docker deployment and terminal shell fallback (#520)
* feat(container): add Docker deployment and terminal shell fallback

Add Docker runtime assets (Dockerfile, compose file, and entrypoint) to run OpenChamber in containers with persistent config/data mounts.

Improve terminal PTY startup reliability by probing multiple shell candidates and falling back automatically across Unix and Windows environments.

* fix: add OMO install env

* docs: add Docker Compose instructions to README
2026-02-26 20:13:23 +02:00

67 lines
1.8 KiB
Bash

#!/usr/bin/env sh
set -eu
if [ -z "${HOME:-}" ]; then
HOME="$(getent passwd "$(id -u)" | cut -d: -f6 2>/dev/null || true)"
fi
if [ -z "${HOME:-}" ]; then
HOME="/home/bun"
fi
OPENCODE_CONFIG_DIR="${OPENCODE_CONFIG_DIR:-${HOME}/.config/opencode}"
export OPENCODE_CONFIG_DIR
SSH_DIR="${HOME}/.ssh"
SSH_PRIVATE_KEY_PATH="${SSH_DIR}/id_ed25519"
SSH_PUBLIC_KEY_PATH="${SSH_PRIVATE_KEY_PATH}.pub"
mkdir -p "${SSH_DIR}"
if ! chmod 700 "${SSH_DIR}" 2>/dev/null; then
echo "[entrypoint] warning: cannot chmod ${SSH_DIR}, continuing with existing permissions"
fi
if [ ! -f "${SSH_PRIVATE_KEY_PATH}" ] || [ ! -f "${SSH_PUBLIC_KEY_PATH}" ]; then
if [ ! -w "${SSH_DIR}" ]; then
echo "[entrypoint] error: ssh key missing and ${SSH_DIR} is not writable" >&2
exit 1
fi
echo "[entrypoint] generating SSH key..."
ssh-keygen -t ed25519 -N "" -f "${SSH_PRIVATE_KEY_PATH}" >/dev/null
fi
if ! chmod 600 "${SSH_PRIVATE_KEY_PATH}" 2>/dev/null; then
echo "[entrypoint] warning: cannot chmod ${SSH_PRIVATE_KEY_PATH}, continuing"
fi
if ! chmod 644 "${SSH_PUBLIC_KEY_PATH}" 2>/dev/null; then
echo "[entrypoint] warning: cannot chmod ${SSH_PUBLIC_KEY_PATH}, continuing"
fi
echo "[entrypoint] SSH public key:"
cat "${SSH_PUBLIC_KEY_PATH}"
OMO_INSTALL_ARGS="--no-tui --claude=no --openai=no --gemini=no --copilot=no --opencode-zen=no --zai-coding-plan=no --kimi-for-coding=no --skip-auth"
if [ "${OH_MY_OPENCODE:-false}" = "true" ]; then
echo "[entrypoint] npm installing oh-my-opencode..."
npm install -g oh-my-opencode
OMO_CONFIG_FILE="${OPENCODE_CONFIG_DIR}/oh-my-opencode.json"
if [ ! -f "${OMO_CONFIG_FILE}" ]; then
echo "[entrypoint] oh-my-opencode installing..."
oh-my-opencode install ${OMO_INSTALL_ARGS}
fi
fi
echo "[entrypoint] starting..."
if [ "$#" -gt 0 ]; then
exec "$@"
fi
exec bun packages/web/server/index.js --port "${OPENCHAMBER_PORT:-3000}"