mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 10:12:38 +02:00
install: Do not create intermediate tarfile for container
Skip the creation of the `share/container.tar` file, since it's not used anywhere. Instead, pipe our `docker/podman save` invocations to `gzip` directly, which will compress the tarfile on the fly. This saves both time and disk space.
This commit is contained in:
parent
a0503c8c40
commit
624d480cca
3 changed files with 16 additions and 24 deletions
|
@ -3,11 +3,8 @@
|
||||||
echo "Building container image"
|
echo "Building container image"
|
||||||
podman build container --platform linux/amd64 --tag dangerzone.rocks/dangerzone
|
podman build container --platform linux/amd64 --tag dangerzone.rocks/dangerzone
|
||||||
|
|
||||||
echo "Saving container image"
|
echo "Saving and compressing container image"
|
||||||
podman save dangerzone.rocks/dangerzone -o share/container.tar
|
podman save dangerzone.rocks/dangerzone | gzip > share/container.tar.gz
|
||||||
|
|
||||||
echo "Compressing container image"
|
|
||||||
gzip -f share/container.tar
|
|
||||||
|
|
||||||
echo "Looking up the image id"
|
echo "Looking up the image id"
|
||||||
podman image ls dangerzone.rocks/dangerzone | grep "dangerzone.rocks/dangerzone" | tr -s ' ' | cut -d' ' -f3 > share/image-id.txt
|
podman image ls dangerzone.rocks/dangerzone | grep "dangerzone.rocks/dangerzone" | tr -s ' ' | cut -d' ' -f3 > share/image-id.txt
|
||||||
|
|
|
@ -3,11 +3,8 @@
|
||||||
echo "Building container image"
|
echo "Building container image"
|
||||||
docker build container --platform linux/amd64 --tag dangerzone.rocks/dangerzone
|
docker build container --platform linux/amd64 --tag dangerzone.rocks/dangerzone
|
||||||
|
|
||||||
echo "Saving container image"
|
echo "Saving and compressing container image"
|
||||||
docker save dangerzone.rocks/dangerzone -o share/container.tar
|
docker save dangerzone.rocks/dangerzone | gzip > share/container.tar.gz
|
||||||
|
|
||||||
echo "Compressing container image"
|
|
||||||
gzip -f share/container.tar
|
|
||||||
|
|
||||||
echo "Looking up the image id"
|
echo "Looking up the image id"
|
||||||
docker image ls dangerzone.rocks/dangerzone | grep "dangerzone.rocks/dangerzone" | tr -s ' ' | cut -d' ' -f3 > share/image-id.txt
|
docker image ls dangerzone.rocks/dangerzone | grep "dangerzone.rocks/dangerzone" | tr -s ' ' | cut -d' ' -f3 > share/image-id.txt
|
||||||
|
|
|
@ -18,28 +18,26 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Saving container image")
|
print("Saving container image")
|
||||||
subprocess.run(
|
cmd = subprocess.Popen(
|
||||||
[
|
[
|
||||||
"docker",
|
"docker",
|
||||||
"save",
|
"save",
|
||||||
"dangerzone.rocks/dangerzone",
|
"dangerzone.rocks/dangerzone",
|
||||||
"-o",
|
],
|
||||||
"share/container.tar",
|
stdout=subprocess.PIPE,
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Compressing container image")
|
print("Compressing container image")
|
||||||
chunk_size = 1024
|
chunk_size = 4 << 12
|
||||||
with open("share/container.tar", "rb") as f:
|
|
||||||
with gzip.open("share/container.tar.gz", "wb") as gzip_f:
|
with gzip.open("share/container.tar.gz", "wb") as gzip_f:
|
||||||
while True:
|
while True:
|
||||||
chunk = f.read(chunk_size)
|
chunk = cmd.stdout.read(chunk_size)
|
||||||
if len(chunk) > 0:
|
if len(chunk) > 0:
|
||||||
gzip_f.write(chunk)
|
gzip_f.write(chunk)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
os.remove("share/container.tar")
|
cmd.wait(5)
|
||||||
|
|
||||||
print("Looking up the image id")
|
print("Looking up the image id")
|
||||||
image_id = subprocess.check_output(
|
image_id = subprocess.check_output(
|
||||||
|
|
Loading…
Reference in a new issue