mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-07 22:44:16 +00:00
feat(docker): add init script support via /openclaw-init.d/
Adds an ENTRYPOINT script that runs user-provided init scripts from /openclaw-init.d/ before starting the gateway. This is the standard Docker pattern (used by nginx, postgres, etc.) for customizing container startup without overriding the entire entrypoint. Usage: docker run -v ./my-init-scripts:/openclaw-init.d:ro openclaw Scripts must be executable. Non-executable files are skipped with a warning. Scripts run in alphabetical order with output prefixed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
717caa97fb
commit
53af9f7437
@@ -43,6 +43,11 @@ RUN chown -R node:node /app
|
||||
# This reduces the attack surface by preventing container escape via root privileges
|
||||
USER node
|
||||
|
||||
# Support custom init scripts mounted at /openclaw-init.d/
|
||||
# Scripts must be executable. They run before the gateway starts.
|
||||
# Example: docker run -v ./my-scripts:/openclaw-init.d:ro openclaw
|
||||
ENTRYPOINT ["/app/scripts/docker-entrypoint.sh"]
|
||||
|
||||
# Start gateway server with default config.
|
||||
# Binds to loopback (127.0.0.1) by default for security.
|
||||
#
|
||||
|
||||
29
scripts/docker-entrypoint.sh
Executable file
29
scripts/docker-entrypoint.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# OpenClaw Docker entrypoint with init script support.
|
||||
#
|
||||
# Runs any executable scripts found in /openclaw-init.d/ before starting
|
||||
# the main process. This allows users to mount custom initialization
|
||||
# scripts (e.g., install dependencies, apply patches, start services)
|
||||
# without overriding the entire entrypoint.
|
||||
#
|
||||
# Usage in docker-compose.yml:
|
||||
# volumes:
|
||||
# - ./my-init-scripts:/openclaw-init.d:ro
|
||||
|
||||
INIT_DIR="/openclaw-init.d"
|
||||
|
||||
if [ -d "$INIT_DIR" ] && [ "$(ls -A "$INIT_DIR" 2>/dev/null)" ]; then
|
||||
echo "[openclaw-init] Running init scripts from $INIT_DIR..."
|
||||
for script in "$INIT_DIR"/*; do
|
||||
[ -f "$script" ] || continue
|
||||
if [ -x "$script" ]; then
|
||||
echo "[openclaw-init] Running $(basename "$script")..."
|
||||
"$script" 2>&1 | sed "s/^/ /"
|
||||
else
|
||||
echo "[openclaw-init] Skipping $(basename "$script") (not executable)"
|
||||
fi
|
||||
done
|
||||
echo "[openclaw-init] Done."
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user