mfer/bin/docker-prereqs.sh

48 lines
1.2 KiB
Bash
Raw Normal View History

2022-12-04 18:55:22 +00:00
#!/bin/bash
set -euxo pipefail
GOI="golang:1.19.3-bullseye"
2022-12-05 22:59:08 +00:00
#CII="golangci/golangci-lint:v1.50.1"
2022-12-04 18:55:22 +00:00
if [[ ! -d "$DOCKER_IMAGE_CACHE_DIR" ]]; then
mkdir -p "$DOCKER_IMAGE_CACHE_DIR"
fi
DICD="$DOCKER_IMAGE_CACHE_DIR"
function buildImageCache() {
if [[ ! -e "$DICD/go.tzst" ]]; then
docker pull $GOI
docker save $GOI | pv | zstdmt -19 > $DICD/go.tzst.tmp && \
mv $DICD/go.tzst.tmp $DICD/go.tzst
fi
2022-12-05 22:59:08 +00:00
#if [[ ! -e "$DICD/ci.tzst" ]]; then
# docker pull $CII
# docker save $CII | pv | zstdmt -19 > $DICD/ci.tzst.tmp && \
# mv $DICD/ci.tzst.tmp $DICD/ci.tzst
#fi
2022-12-04 18:55:22 +00:00
}
function loadImageCache() {
2022-12-05 22:59:08 +00:00
# zstdmt -d --stdout $DICD/ci.tzst | pv | docker load
zstdmt -d --stdout $DICD/go.tzst | pv | docker load
#docker image ls $CII
docker image ls $GOI
2022-12-04 18:55:22 +00:00
}
2022-12-05 22:59:08 +00:00
function writeModuleCache() {
if [[ ! -e $DICD/modcache.tar ]]; then
cd $(go env GOMODCACHE)
tar -c . | pv > $DICD/modcache.tar.tmp && mv $DICD/modcache.tar.tmp $DICD/modcache.tar
cd -
fi
cp -av $DICD/modcache.tar ./builddeps/modcache.tar.tmp && mv ./builddeps/modcache.tar.tmp ./builddeps/modcache.tar
}
2022-12-04 18:55:22 +00:00
2022-12-05 22:59:08 +00:00
buildImageCache
2022-12-04 18:55:22 +00:00
loadImageCache
2022-12-05 22:59:08 +00:00
writeModuleCache