Files
git.taskfile.build/image/entrypoint.sh
T
Janik von Rotz 57fce1cb8a feat(image): integrate opencode-ai CLI with persistent config support
- Install opencode-ai globally via pnpm with build allowance
- Fix pnpm global bin path by adding $PNPM_HOME/bin to PATH
- Create /app/.config/opencode for persistent config storage
- Document OpenCode usage and persistence in README.md
- Log opencode version at container startup in entrypoint.sh
2026-06-19 08:01:26 +02:00

80 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
echo "pnpm version: $(pnpm --version)"
echo "hugo version: $(hugo version)"
echo "git version: $(git -v)"
echo "curl version: $(curl -V)"
echo "opencode version: $(opencode --version)"
if [[ -z "$GIT_URL" ]]; then
echo 'Error: GIT_URL environment variable is required.' >&2
exit 1
fi
GIT_PATH="/app/repo"
if [[ ! -d "$GIT_PATH" ]]; then
echo "Cloning git repo: $GIT_URL (shallow clone)"
git clone --depth 1 "$GIT_URL" "$GIT_PATH"
else
echo "Pull git repo: $GIT_URL"
git -C "$GIT_PATH" reset --hard
git -C "$GIT_PATH" pull
fi
if [[ -f "$GIT_PATH/.gitmodules" ]]; then
echo 'Found .gitmodules, initializing submodules (shallow).'
git -C "$GIT_PATH" submodule init
git -C "$GIT_PATH" submodule update --recursive --depth 1
fi
if [[ -f "${GIT_PATH}/task" ]]; then
if [[ -z "$TASK_COMMANDS" ]]; then
echo 'Error: TASK_COMMANDS environment variable is required.' >&2
exit 1
fi
echo "Ensure task file is executable."
chmod +x "${GIT_PATH}/task"
cd "$GIT_PATH"
COMMANDS=$(echo "$TASK_COMMANDS" | tr "," "\n")
for COMMAND in $COMMANDS; do
echo "Run task command: $COMMAND"
./task "$COMMAND"
done
fi
echo 'Template Caddyfile.'
cat > /etc/caddy/Caddyfile <<EOF
:80 {
root * ${GIT_PATH}/${CADDY_ROOT}
file_server
try_files {path} {path}/ /index.html
encode gzip
header {
X-Content-Type-Options nosniff
X-Frame-Options DENY
X-XSS-Protection "1; mode=block"
Referrer-Policy strict-origin-when-cross-origin
}
@static {
file
path *.css *.js *.png *.jpg *.jpeg *.gif *.ico *.svg *.woff *.woff2 *.ttf *.eot
}
header @static Cache-Control "public, max-age=31536000, immutable"
}
EOF
case "$1" in
caddy)
echo 'Start Caddy.'
exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
;;
*)
exec "$@"
;;
esac