-
Notifications
You must be signed in to change notification settings - Fork 0
fix: docker permissions and db path configuration #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d1cac60
92c6232
a611a04
22b27df
ec1ac2b
cfb6321
3cfd75c
0fdd257
82fa7fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,8 @@ while [ $# -gt 0 ]; do | |
| export MC_URL="$2"; shift 2 ;; | ||
| --fleet-api-key) | ||
| export CLAWMETRY_FLEET_KEY="$2"; shift 2 ;; | ||
| --fleet-db-path) | ||
| export FLEET_DB_PATH="$2"; shift 2 ;; | ||
| --no-debug|--debug) | ||
| # Debug mode is not applicable under gunicorn; silently ignore. | ||
| shift ;; | ||
|
|
@@ -40,7 +42,45 @@ while [ $# -gt 0 ]; do | |
| esac | ||
| done | ||
|
|
||
| exec /venv/bin/gunicorn \ | ||
| # Ensure HOME is set correctly for the non-root user. | ||
| export HOME="${HOME:-/home/clawmetry}" | ||
| export OPENCLAW_HOME="${OPENCLAW_HOME:-/home/clawmetry/.openclaw}" | ||
|
||
|
|
||
| # The container starts as root. We ensure the data directory exists and | ||
| # has the correct permissions before dropping privileges. | ||
| # We intentionally do NOT recurse into existing content to avoid mutating | ||
| # host-side ownership when DATA_DIR is a bind mount where the host user's | ||
| # UID differs from the container's 'clawmetry' user (UID 1000). | ||
| DATA_DIR="${OPENCLAW_DATA_DIR:-/home/clawmetry/.openclaw}" | ||
| mkdir -p "$DATA_DIR" | ||
| # Only fix ownership when the directory is still owned by root (e.g. just | ||
| # created above or a brand-new Docker-managed volume). This preserves the | ||
| # original ownership on pre-existing bind mounts. | ||
| # Safety guard: never chown '/' or an empty path. | ||
| if [ -n "$DATA_DIR" ] && [ "$DATA_DIR" != "/" ] && \ | ||
| [ "$(stat -c '%u' "$DATA_DIR")" = "0" ]; then | ||
| chown clawmetry:clawmetry "$DATA_DIR" | ||
| fi | ||
|
|
||
| # Also ensure the fleet DB directory exists if FLEET_DB_PATH is set. | ||
| if [ -n "$FLEET_DB_PATH" ]; then | ||
| DB_DIR=$(dirname "$FLEET_DB_PATH") | ||
| # Normalise DB_DIR to an absolute path when FLEET_DB_PATH is relative. | ||
| case "$DB_DIR" in | ||
| /*) ;; | ||
| *) DB_DIR="$HOME/$DB_DIR" ;; | ||
| esac | ||
| mkdir -p "$DB_DIR" | ||
| # Safety guard: never chown '/' (e.g. FLEET_DB_PATH='/fleet.db') | ||
| # or an empty string. | ||
| if [ -n "$DB_DIR" ] && [ "$DB_DIR" != "/" ] && \ | ||
| [ "$(stat -c '%u' "$DB_DIR")" = "0" ]; then | ||
| chown clawmetry:clawmetry "$DB_DIR" | ||
| fi | ||
| fi | ||
|
|
||
| echo "Dropping privileges to clawmetry user and starting gunicorn..." | ||
| exec gosu clawmetry /venv/bin/gunicorn \ | ||
| --bind "${HOST}:${PORT}" \ | ||
| --workers 1 \ | ||
| --threads 16 \ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
--fleet-db-pathflag andFLEET_DB_PATHenvironment variable are not documented in the README.md or docs/guide/configuration.md. According to the stored memory about configuration documentation conventions (docs/guide/configuration.md:9-17), all environment variables should be documented in the configuration reference with per-variable subsections. Add documentation for this new variable including its CLI equivalent, description, and usage example.