erpnext/scripts/ci/jenkins-bootstrap.sh
epistemophiliac e1facdec3d Install docker buildx in Jenkins CI for BuildKit secret mounts.
Bootstrap downloads the buildx plugin; image build uses buildx build --load with a persistent builder.
2026-06-16 19:21:50 -04:00

55 lines
1.8 KiB
Bash
Executable file

#!/usr/bin/env bash
# Install docker + docker-compose CLI and verify socket access (Jenkins on Coolify).
set -euo pipefail
mkdir -p .ci-bin dist .ci-bin/docker-config/cli-plugins
if [ ! -x .ci-bin/docker ]; then
echo "Downloading docker CLI..."
curl -fsSL "https://download.docker.com/linux/static/stable/x86_64/docker-27.4.1.tgz" \
| tar xz --strip-components=1 -C .ci-bin docker/docker
chmod +x .ci-bin/docker
fi
if [ ! -x .ci-bin/docker-compose ]; then
echo "Downloading docker-compose..."
curl -fsSL "https://github.com/docker/compose/releases/download/v2.32.4/docker-compose-linux-x86_64" \
-o .ci-bin/docker-compose
chmod +x .ci-bin/docker-compose
fi
if [ ! -x .ci-bin/docker-config/cli-plugins/docker-buildx ]; then
echo "Downloading docker buildx plugin..."
curl -fsSL "https://github.com/docker/buildx/releases/download/v0.21.1/buildx-v0.21.1.linux-amd64" \
-o .ci-bin/docker-config/cli-plugins/docker-buildx
chmod +x .ci-bin/docker-config/cli-plugins/docker-buildx
fi
DOCKER=./.ci-bin/docker
COMPOSE=./.ci-bin/docker-compose
DOCKER_CONFIG="${PWD}/.ci-bin/docker-config"
export DOCKER_CONFIG
if ! $DOCKER version >/dev/null 2>&1; then
if command -v sudo >/dev/null 2>&1 && sudo -n env DOCKER_CONFIG="$DOCKER_CONFIG" $DOCKER version >/dev/null 2>&1; then
DOCKER="sudo env DOCKER_CONFIG=$DOCKER_CONFIG $DOCKER"
COMPOSE="sudo $COMPOSE"
else
echo "ERROR: cannot access /var/run/docker.sock"
echo "Set DOCKER_GID on the Jenkins Coolify service to: $(stat -c '%g' /var/run/docker.sock 2>/dev/null || echo unknown)"
ls -la /var/run/docker.sock 2>/dev/null || true
id
exit 1
fi
fi
cat > .ci-bin/ci-env.sh <<EOF
export DOCKER='$DOCKER'
export COMPOSE='$COMPOSE'
export DOCKER_CONFIG='${DOCKER_CONFIG}'
export DOCKER_BUILDKIT=1
EOF
$DOCKER buildx version
$DOCKER version
$COMPOSE version