From d6b208342edf97bafa5b1dcc986b782f9879d141 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Thu, 21 May 2026 17:30:08 +0900 Subject: feat: SQLite database for all credentials, keys, wake schedule, and usage cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add SQLite database at ~/.local/share/dispatch/dispatch.db with tables: credentials, api_keys, wake_schedule, usage_cache - Store Claude OAuth credentials in DB with import button in Model Status UI - Store OpenCode/Copilot API keys in DB with paste-to-import modal - Store OpenCode cookie and workspace IDs in DB - Migrate wake schedule from .wake-schedule.json to DB - Migrate usage cache from in-memory Map + localStorage to DB - Remove all env var and file fallbacks — DB is the single source of truth - Add seed scripts: bin/import-credentials.ts, bin/seed-opencode-keys.ts - Docker: container runs as host UID/GID with matching home directory - Clean up dispatch.toml: remove env fields, update comments - Progress bar time markers for usage cycle tracking --- docker/entrypoint.dev.sh | 52 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) (limited to 'docker') diff --git a/docker/entrypoint.dev.sh b/docker/entrypoint.dev.sh index b28b44f..8378585 100644 --- a/docker/entrypoint.dev.sh +++ b/docker/entrypoint.dev.sh @@ -1,11 +1,47 @@ #!/bin/bash set -euo pipefail -# Install/update dependencies. -# Source code is bind-mounted from the host; node_modules lives on the host -# filesystem via the bind mount so it persists across container restarts -# and is shared between the api and frontend services. -bun install - -# Execute the main command -exec "$@" +# ─── Match host user inside container ──────────────────────────── +# Ensures the process runs as the host UID/GID with a matching +# home directory so volume mounts and config paths are consistent. + +HOST_UID="${HOST_UID:-1000}" +HOST_GID="${HOST_GID:-1000}" +HOST_USER="${HOST_USER:-dispatch}" + +USER_HOME="/home/$HOST_USER" + +# Create group if it doesn't exist +if ! getent group "$HOST_GID" > /dev/null 2>&1; then + groupadd -g "$HOST_GID" "$HOST_USER" +fi + +# Ensure user with this UID has the correct home directory +if id -u "$HOST_UID" > /dev/null 2>&1; then + USER_NAME=$(getent passwd "$HOST_UID" | cut -d: -f1) + usermod -d "$USER_HOME" "$USER_NAME" 2>/dev/null || true +else + useradd -u "$HOST_UID" -g "$HOST_GID" -d "$USER_HOME" -m -s /bin/bash "$HOST_USER" + USER_NAME="$HOST_USER" +fi + +# Ensure home and data directories exist with correct ownership +mkdir -p "$USER_HOME" "$USER_HOME/.local/share/dispatch" +chown "$HOST_UID:$HOST_GID" "$USER_HOME" +chown -R "$HOST_UID:$HOST_GID" "$USER_HOME/.local/share/dispatch" + +# Ensure .claude is accessible +if [ -d "$USER_HOME/.claude" ]; then + chown -R "$HOST_UID:$HOST_GID" "$USER_HOME/.claude" 2>/dev/null || true +fi + +# Ensure node_modules is writable (created as root during build) +if [ -d /app/node_modules ]; then + chown -R "$HOST_UID:$HOST_GID" /app/node_modules +fi + +# Install/update dependencies as the target user +su -s /bin/bash - "$USER_NAME" -c "export HOME=$USER_HOME && cd /app && bun install" + +# Execute the main command as the target user +exec su -s /bin/bash - "$USER_NAME" -c "export HOME=$USER_HOME && cd /app && exec $*" -- cgit v1.2.3