2022-03-04 22:55:57 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
|
|
|
source ${ABSDIR}/../functions.sh
|
|
|
|
source ${ABSDIR}/vars.sh
|
|
|
|
|
|
|
|
ensure_pwd_is_scriptdir
|
|
|
|
ensure_not_root
|
|
|
|
|
2022-03-05 09:30:15 +00:00
|
|
|
buildfolder=/tmp/synapse-$$
|
|
|
|
|
2023-07-26 21:05:49 +00:00
|
|
|
buildkitd_version='latest'
|
|
|
|
buildkitd_args='--oci-worker-snapshotter=native' # needed as of v0.12.0
|
2023-07-26 19:07:01 +00:00
|
|
|
|
2022-05-25 19:22:15 +00:00
|
|
|
if ! podman image exists ${synapse_image}:${synapse_version}; then
|
2022-03-05 09:30:15 +00:00
|
|
|
mkdir ${buildfolder} &&
|
2022-03-05 09:48:02 +00:00
|
|
|
curl -sSfL -- "https://github.com/matrix-org/synapse/archive/refs/tags/${synapse_version}.tar.gz" | \tar xz --strip-components 1 -C ${buildfolder}/ && {
|
2023-07-26 19:07:01 +00:00
|
|
|
podman image pull docker.io/moby/buildkit:${buildkitd_version}
|
2023-07-26 21:05:49 +00:00
|
|
|
podman container run -d --name buildkitd --privileged docker.io/moby/buildkit:${buildkitd_version} ${buildkitd_args} &&
|
|
|
|
sleep 3
|
2023-05-23 16:40:12 +00:00
|
|
|
my_buildctl --addr=podman-container://buildkitd build \
|
|
|
|
--frontend dockerfile.v0 \
|
|
|
|
--local context=${buildfolder}/ \
|
|
|
|
--local dockerfile=${buildfolder}/docker/ \
|
|
|
|
--output type=oci,name="${synapse_image}:${synapse_version}" | \
|
|
|
|
podman image load &&
|
|
|
|
podman container rm --force buildkitd &&
|
2023-07-26 19:07:01 +00:00
|
|
|
podman image rm docker.io/moby/buildkit:${buildkitd_version}
|
2022-03-04 22:55:57 +00:00
|
|
|
}
|
2022-03-05 09:30:15 +00:00
|
|
|
rm -rf ${buildfolder}
|
2022-08-12 18:34:42 +00:00
|
|
|
else
|
|
|
|
echo "Image ${synapse_image}:${synapse_version} already built"
|
|
|
|
fi &&
|
|
|
|
|
|
|
|
oci_push_to_registry ${synapse_image}:${synapse_version}
|