diff options
| author | Adam Malczewski <[email protected]> | 2026-05-21 17:30:08 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-05-21 17:30:08 +0900 |
| commit | d6b208342edf97bafa5b1dcc986b782f9879d141 (patch) | |
| tree | c6d8f9bffa86f78e3b1369b811bef9642df788d0 /docker | |
| parent | 1f309ccca20aabbd0ee3fb8fbb3c8192124edd95 (diff) | |
| download | dispatch-d6b208342edf97bafa5b1dcc986b782f9879d141.tar.gz dispatch-d6b208342edf97bafa5b1dcc986b782f9879d141.zip | |
feat: SQLite database for all credentials, keys, wake schedule, and usage cache
- 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
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/entrypoint.dev.sh | 52 |
1 files changed, 44 insertions, 8 deletions
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 $*" |
