#works after i run rootless buildkitd
buildctl --addr unix:///run/user/1005/buildkit/buildkitd.sock build --frontend=dockerfile.v0 --local context=. --local dockerfile=. --output type=image,name=docker.io/ashpect/testimage,push=true
sudo /home/ashish/bin/buildctl build
--frontend=dockerfile.v0
--local context=.
--local dockerfile=.
--output type=image,name=docker.io/ashpect/testimage,push=true
#push doesn't work on poseidon
if [ "$(id -u)" -eq 0 ] || sudo -v >/dev/null 2>&1; then
echo "You are root or have sudo privileges."
else
echo "You are not root and do not have sudo privileges."
fi
rootlesskit buildkitd unix://run/user/1005/buildkit/buildkitd.sock
rootlesskit buildkitd
./main py node rb
#!/bin/sh
# buildctl-daemonless.sh spawns ephemeral buildkitd for executing buildctl.
#
# Usage: buildctl-daemonless.sh build ...
#
# Flags for buildkitd can be specified as $BUILDKITD_FLAGS .
#
# The script is compatible with BusyBox shell.
set -eu
: ${BUILDCTL=buildctl}
: ${BUILDCTL_CONNECT_RETRIES_MAX=10}
: ${BUILDKITD=buildkitd}
: ${BUILDKITD_FLAGS=}
: ${ROOTLESSKIT=rootlesskit}
: ${LIMACTL=limactl}
# $tmp holds the following files:
# * pid
# * addr
# * log
tmp=$(mktemp -d /tmp/buildctl-daemonless.XXXXXX)
if [ "$(uname)" == "Darwin" ]; then
echo "$tmp"
trap "rm -rf $tmp" EXIT
else
trap "kill \\$(cat $tmp/pid) || true; wait \\$(cat $tmp/pid) || true; rm -rf $tmp" EXIT
fi
startBuildkitd() {
addr=
helper=
if [ "$(uname)" == "Darwin" ]; then
echo "MacOS: $(sw_vers -productName) $(sw_vers -productVersion) detected"
if which buildctl >/dev/null 2>&1; then
echo "buildctl is installed at $(which buildctl)"
if which lima > /dev/null 2>&1; then
echo "lima is installed at $(which lima)"
addr="unix://$HOME/.lima/buildkit/sock/buildkitd.sock"
echo "$addr" > "$tmp/addr"
return
else
echo "Please install lima for running buildkitd using : brew install lima"
exit 1
fi
else
echo "builtctl is not installed. Please install it via brew install buildkit or build it using the moby/buildkit repo."
exit 1
fi
elif [ $(id -u) = 0 ]; then
addr=unix:///run/buildkit/buildkitd.sock
else
addr=unix://$XDG_RUNTIME_DIR/buildkit/buildkitd.sock
helper=$ROOTLESSKIT
fi
$helper $BUILDKITD $BUILDKITD_FLAGS --addr=$addr >$tmp/log 2>&1 &
pid=$!
echo $pid >$tmp/pid
echo $addr >$tmp/addr
}
# buildkitd supports NOTIFY_SOCKET but as far as we know, there is no easy way
# to wait for NOTIFY_SOCKET activation using busybox-builtin commands...
waitForBuildkitd() {
addr=$(cat $tmp/addr)
try=0
max=$BUILDCTL_CONNECT_RETRIES_MAX
until $BUILDCTL --addr=$addr debug workers >/dev/null 2>&1; do
if [ $try -gt $max ]; then
echo >&2 "could not connect to $addr after $max trials"
echo >&2 "========== log =========="
cat >&2 $tmp/log
exit 1
fi
sleep $(awk "BEGIN{print (100 + $try * 20) * 0.001}")
try=$(expr $try + 1)
done
}
startBuildkitd
waitForBuildkitd
$BUILDCTL --addr=$(cat $tmp/addr) "$@"
https://www.docker.com/blog/compiling-containers-dockerfiles-llvm-and-buildkit/
https://www.freecodecamp.org/news/the-basic-design-patterns-all-developers-need-to-know/
https://dev.to/kittipat1413/understanding-the-builder-pattern-in-go-gp9