fix openclaw init container: escape shell vars, fix image path [ci skip]

- Use $$ for shell variable escaping in Terraform ($ is Terraform interpolation)
- Fix image: docker.io/alpine/git (not library/alpine/git)
- Inline command instead of heredoc to avoid Terraform interpolation issues
This commit is contained in:
Viktor Barzin 2026-03-15 17:19:03 +00:00
parent 3aba29e7a3
commit 1fe7798609

View file

@ -317,33 +317,9 @@ resource "kubernetes_deployment" "openclaw" {
# Init 2: install skills/agents/hooks from dotfiles repo
init_container {
name = "install-dotfiles"
image = "docker.io/library/alpine/git:2.47.2"
command = ["sh", "-c", <<-EOF
apk add --no-cache rsync >/dev/null 2>&1
export OPENCLAW_HOME=/home/node/.openclaw
export DOTFILES_DIR=$OPENCLAW_HOME/dotfiles
export DOTFILES_REPO=https://github.com/ViktorBarzin/dot_files.git
SRC=$DOTFILES_DIR/dot_claude
# Clone or pull
if [ -d "$DOTFILES_DIR/.git" ]; then
git -C "$DOTFILES_DIR" pull --ff-only 2>/dev/null || git -C "$DOTFILES_DIR" pull --rebase || true
else
git clone --depth 1 "$DOTFILES_REPO" "$DOTFILES_DIR"
fi
# Run install script if present, otherwise inline install
if [ -f "$SRC/executable_openclaw-install.sh" ]; then
sh "$SRC/executable_openclaw-install.sh"
else
# Fallback: direct copy
for d in skills agents hooks commands; do
[ -d "$SRC/$d" ] && mkdir -p "$OPENCLAW_HOME/$d" && rsync -a --delete "$SRC/$d/" "$OPENCLAW_HOME/$d/"
done
[ -f "$SRC/CLAUDE.md" ] && cp "$SRC/CLAUDE.md" "$OPENCLAW_HOME/CLAUDE.md"
fi
chown -R 1000:1000 "$OPENCLAW_HOME" 2>/dev/null || true
EOF
]
name = "install-dotfiles"
image = "docker.io/alpine/git:2.47.2"
command = ["sh", "-c", "apk add --no-cache rsync >/dev/null 2>&1 && export OPENCLAW_HOME=/home/node/.openclaw && export DOTFILES_DIR=$$OPENCLAW_HOME/dotfiles && export DOTFILES_REPO=https://github.com/ViktorBarzin/dot_files.git && SRC=$$DOTFILES_DIR/dot_claude && if [ -d $$DOTFILES_DIR/.git ]; then git -C $$DOTFILES_DIR pull --ff-only 2>/dev/null || git -C $$DOTFILES_DIR pull --rebase || true; else git clone --depth 1 $$DOTFILES_REPO $$DOTFILES_DIR; fi && if [ -f $$SRC/executable_openclaw-install.sh ]; then sh $$SRC/executable_openclaw-install.sh; else for d in skills agents hooks commands; do [ -d $$SRC/$$d ] && mkdir -p $$OPENCLAW_HOME/$$d && rsync -a --delete $$SRC/$$d/ $$OPENCLAW_HOME/$$d/; done; [ -f $$SRC/CLAUDE.md ] && cp $$SRC/CLAUDE.md $$OPENCLAW_HOME/CLAUDE.md; fi && chown -R 1000:1000 $$OPENCLAW_HOME 2>/dev/null || true"]
volume_mount {
name = "openclaw-home"
mount_path = "/home/node/.openclaw"