41 lines
1.5 KiB
Bash
Executable file
41 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
|
source ${ABSDIR}/../functions.sh
|
|
source ${ABSDIR}/vars.sh
|
|
|
|
ensure_pwd_is_scriptdir
|
|
ensure_not_root
|
|
|
|
buildfolder=/tmp/synapse-$$
|
|
|
|
if [[ $(uname -i) == 'aarch64' ]]; then
|
|
buildkitarch='arm64'
|
|
elif [[ $(uname -i) == 'x86_64' ]]; then
|
|
buildkitarch='amd64'
|
|
else
|
|
# defaults to amd64
|
|
buildkitarch='amd64'
|
|
fi
|
|
|
|
if ! podman image exists localhost/matrixdotorg/synapse:${synapse_version}; then
|
|
mkdir ${buildfolder} &&
|
|
curl -sSfL -- "https://github.com/matrix-org/synapse/archive/refs/tags/${synapse_version}.tar.gz" | \tar xz --strip-components 1 -C ${buildfolder}/ && {
|
|
podman run -d --name buildkitd --privileged docker.io/moby/buildkit:latest &&
|
|
curl -sSLf https://github.com/moby/buildkit/releases/download/v0.9.3/buildkit-v0.9.3.linux-${buildkitarch}.tar.gz | \
|
|
tar xz -C ~/ bin/buildctl &&
|
|
~/bin/buildctl --addr=podman-container://buildkitd build \
|
|
--frontend dockerfile.v0 \
|
|
--local context=${buildfolder}/ \
|
|
--local dockerfile=${buildfolder}/docker/ \
|
|
--output type=oci,name="fixme:synapse_${synapse_version}" | \
|
|
podman load &&
|
|
podman image tag localhost/synapse_${synapse_version}:latest ${synapse_image}:${synapse_version} &&
|
|
podman image rm localhost/synapse_${synapse_version}:latest &&
|
|
podman rm --force buildkitd &&
|
|
podman rmi docker.io/moby/buildkit:latest &&
|
|
rm -f ~/bin/buildctl
|
|
}
|
|
rm -rf ${buildfolder}
|
|
fi
|