37 lines
870 B
Bash
37 lines
870 B
Bash
#!/bin/bash
|
|
set -euxo pipefail
|
|
GOI="golang:1.19.3-bullseye"
|
|
CII="golangci/golangci-lint:v1.50.1"
|
|
|
|
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
|
|
|
|
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
|
|
}
|
|
|
|
function loadImageCache() {
|
|
docker image ls $CII || \
|
|
zstdmt -d --stdout $DICD/ci.tzst | pv | docker load
|
|
|
|
docker image ls $GOI || \
|
|
zstdmt -d --stdout $DICD/go.tzst | pv | docker load
|
|
}
|
|
|
|
buildImageCache
|
|
|
|
loadImageCache
|