Update docs, configs, and scripts
Co-Authored-By: Oz <oz-agent@warp.dev>
This commit is contained in:
@ -4,15 +4,49 @@ set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
ENV_FILE="${REPO_ROOT}/.env"
|
||||
|
||||
log() {
|
||||
printf '[install] %s
|
||||
' "$*"
|
||||
printf '[install] %s\n' "$*"
|
||||
}
|
||||
|
||||
err() {
|
||||
printf '[install][error] %s
|
||||
' "$*" >&2
|
||||
printf '[install][error] %s\n' "$*" >&2
|
||||
}
|
||||
|
||||
load_env_file() {
|
||||
if [[ ! -f "${ENV_FILE}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
source "${ENV_FILE}"
|
||||
set +a
|
||||
|
||||
: "${GEMMA_MODEL_ID:?GEMMA_MODEL_ID must be set in .env}"
|
||||
}
|
||||
|
||||
sync_service_env_files() {
|
||||
cat > "${REPO_ROOT}/backend/config/model.env" <<EOF
|
||||
HF_TOKEN=${HF_TOKEN:-YOUR_HF_TOKEN_HERE}
|
||||
VLLM_API_KEY=${VLLM_API_KEY:-YOUR_LOCAL_API_KEY_HERE}
|
||||
GEMMA_MODEL_ID=${GEMMA_MODEL_ID}
|
||||
BACKEND_PORT=${BACKEND_PORT:-8000}
|
||||
HUGGINGFACE_CACHE_DIR=${HUGGINGFACE_CACHE_DIR:-/home/${USER}/.cache/huggingface}
|
||||
VLLM_MAX_MODEL_LEN=${VLLM_MAX_MODEL_LEN:-512}
|
||||
VLLM_GPU_MEMORY_UTILIZATION=${VLLM_GPU_MEMORY_UTILIZATION:-0.7}
|
||||
EOF
|
||||
|
||||
cat > "${REPO_ROOT}/frontend/config/frontend.env" <<EOF
|
||||
FRONTEND_PORT=${FRONTEND_PORT:-3000}
|
||||
OPENAI_API_BASE_URL=${OPENAI_API_BASE_URL:-http://gemma3-vllm:8000/v1}
|
||||
VLLM_API_KEY=${VLLM_API_KEY:-YOUR_LOCAL_API_KEY_HERE}
|
||||
GEMMA_MODEL_ID=${GEMMA_MODEL_ID}
|
||||
OPEN_WEBUI_DATA_DIR=${OPEN_WEBUI_DATA_DIR:-./frontend/data/open-webui}
|
||||
EOF
|
||||
|
||||
log "Synced backend/config/model.env and frontend/config/frontend.env from .env."
|
||||
}
|
||||
|
||||
require_linux() {
|
||||
@ -39,7 +73,8 @@ install_docker_ubuntu() {
|
||||
local codename
|
||||
codename="${VERSION_CODENAME:-jammy}"
|
||||
|
||||
echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu ${codename} stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
||||
echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu ${codename} stable" \
|
||||
| sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
@ -89,23 +124,17 @@ check_or_install_docker() {
|
||||
}
|
||||
|
||||
prepare_env_files() {
|
||||
if [[ ! -f "${REPO_ROOT}/.env" ]]; then
|
||||
cp "${REPO_ROOT}/.env.example" "${REPO_ROOT}/.env"
|
||||
if [[ ! -f "${ENV_FILE}" ]]; then
|
||||
cp "${REPO_ROOT}/.env.example" "${ENV_FILE}"
|
||||
log "Created .env from .env.example."
|
||||
err "IMPORTANT: edit .env and set HF_TOKEN (and optionally VLLM_API_KEY) before production use."
|
||||
err "IMPORTANT: edit .env and set HF_TOKEN, VLLM_API_KEY, GEMMA_MODEL_ID, and other values before production use."
|
||||
fi
|
||||
|
||||
if [[ ! -f "${REPO_ROOT}/backend/config/model.env" ]]; then
|
||||
cp "${REPO_ROOT}/backend/config/model.env.example" "${REPO_ROOT}/backend/config/model.env"
|
||||
log "Created backend/config/model.env from example."
|
||||
fi
|
||||
mkdir -p "${REPO_ROOT}/backend/config" "${REPO_ROOT}/frontend/config" "${REPO_ROOT}/models" "${REPO_ROOT}/frontend/data/open-webui"
|
||||
|
||||
if [[ ! -f "${REPO_ROOT}/frontend/config/frontend.env" ]]; then
|
||||
cp "${REPO_ROOT}/frontend/config/frontend.env.example" "${REPO_ROOT}/frontend/config/frontend.env"
|
||||
log "Created frontend/config/frontend.env from example."
|
||||
fi
|
||||
|
||||
mkdir -p "${REPO_ROOT}/models" "${REPO_ROOT}/frontend/data/open-webui"
|
||||
load_env_file
|
||||
log "Using GEMMA_MODEL_ID=${GEMMA_MODEL_ID}"
|
||||
sync_service_env_files
|
||||
}
|
||||
|
||||
warn_if_rocm_devices_missing() {
|
||||
@ -117,27 +146,24 @@ warn_if_rocm_devices_missing() {
|
||||
|
||||
start_stack() {
|
||||
log "Pulling container images."
|
||||
docker compose -f "${REPO_ROOT}/docker-compose.yml" --env-file "${REPO_ROOT}/.env" pull
|
||||
docker compose -f "${REPO_ROOT}/docker-compose.yml" --env-file "${ENV_FILE}" pull
|
||||
|
||||
log "Starting containers in detached mode."
|
||||
docker compose -f "${REPO_ROOT}/docker-compose.yml" --env-file "${REPO_ROOT}/.env" up -d
|
||||
docker compose -f "${REPO_ROOT}/docker-compose.yml" --env-file "${ENV_FILE}" up -d --force-recreate
|
||||
}
|
||||
|
||||
show_status_and_urls() {
|
||||
local backend_port frontend_port
|
||||
backend_port="$(grep -E '^BACKEND_PORT=' "${REPO_ROOT}/.env" | tail -n1 | cut -d'=' -f2 || true)"
|
||||
frontend_port="$(grep -E '^FRONTEND_PORT=' "${REPO_ROOT}/.env" | tail -n1 | cut -d'=' -f2 || true)"
|
||||
backend_port="${backend_port:-8000}"
|
||||
frontend_port="${frontend_port:-3000}"
|
||||
backend_port="${BACKEND_PORT:-8000}"
|
||||
frontend_port="${FRONTEND_PORT:-3000}"
|
||||
|
||||
log "Backend status:"
|
||||
docker compose -f "${REPO_ROOT}/docker-compose.yml" --env-file "${REPO_ROOT}/.env" ps gemma3-vllm || true
|
||||
docker compose -f "${REPO_ROOT}/docker-compose.yml" --env-file "${ENV_FILE}" ps gemma3-vllm || true
|
||||
|
||||
log "Frontend status:"
|
||||
docker compose -f "${REPO_ROOT}/docker-compose.yml" --env-file "${REPO_ROOT}/.env" ps chat-ui || true
|
||||
docker compose -f "${REPO_ROOT}/docker-compose.yml" --env-file "${ENV_FILE}" ps chat-ui || true
|
||||
|
||||
printf '
|
||||
'
|
||||
printf '\n'
|
||||
log "API endpoint: http://localhost:${backend_port}/v1"
|
||||
log "Chat UI endpoint: http://localhost:${frontend_port}"
|
||||
log "If startup fails, inspect logs with: docker compose logs --tail=200 gemma3-vllm chat-ui"
|
||||
|
||||
Reference in New Issue
Block a user