build-image.sh: Support building the image on Docker.

This commit is contained in:
Etienne Perot 2023-10-08 16:16:07 -07:00
parent bdf3f8babc
commit aa3227fbfb
No known key found for this signature in database
GPG key ID: 4D061903EEDA047E

View file

@ -1,14 +1,25 @@
#!/bin/sh
set -e
set -euo pipefail
TAG=dangerzone.rocks/dangerzone:latest
echo "Building container image"
podman build --pull dangerzone/ -f Dockerfile --tag $TAG
container_runtime() {
if hash podman &>/dev/null; then
podman "$@"
elif hash docker &>/dev/null; then
docker "$@"
else
echo 'No container runtime installed.' >&2
exit 1
fi
}
echo "Saving and compressing container image"
podman save $TAG | gzip > share/container.tar.gz
echo "Building container image" >&2
container_runtime build --pull dangerzone/ -f Dockerfile --tag "$TAG"
echo "Looking up the image id"
podman images -q --filter=reference=$TAG > share/image-id.txt
echo "Saving and compressing container image" >&2
container_runtime save "$TAG" | gzip > share/container.tar.gz
echo "Looking up the image id" >&2
container_runtime images -q --filter=reference="$TAG" > share/image-id.txt