forked from BtbN/FFmpeg-Builds
-
Notifications
You must be signed in to change notification settings - Fork 2
/
makeimage.sh
executable file
·63 lines (55 loc) · 2.08 KB
/
makeimage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -xeo pipefail
cd "$(dirname "$0")"
source util/vars.sh
TMPCFG="$(mktemp --suffix=.toml)"
cat <<EOF >"$TMPCFG"
[worker.oci]
max-parallelism = 4
EOF
trap "rm -f '$TMPCFG'" EXIT
docker buildx inspect ffbuilder &>/dev/null || docker buildx create \
--bootstrap \
--name ffbuilder \
--config "$TMPCFG" \
--driver-opt network=host \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=-1 \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=-1
if [[ -z "$QUICKBUILD" ]]; then
BASE_IMAGE_TARGET="${PWD}/.cache/images/base"
if [[ ! -d "${BASE_IMAGE_TARGET}" ]]; then
docker buildx --builder ffbuilder build \
--cache-from=type=local,src=.cache/"${BASE_IMAGE/:/_}" \
--cache-to=type=local,mode=max,dest=.cache/"${BASE_IMAGE/:/_}" \
--load --tag "${BASE_IMAGE}" \
"images/base"
mkdir -p "${BASE_IMAGE_TARGET}"
docker image save "${BASE_IMAGE}" | tar -x -C "${BASE_IMAGE_TARGET}"
fi
IMAGE_TARGET="${PWD}/.cache/images/base-${TARGET}"
if [[ ! -d "${IMAGE_TARGET}" ]]; then
docker buildx --builder ffbuilder build \
--cache-from=type=local,src=.cache/"${TARGET_IMAGE/:/_}" \
--cache-to=type=local,mode=max,dest=.cache/"${TARGET_IMAGE/:/_}" \
--build-arg GH_REPO="${REGISTRY}/${REPO}" \
--build-context "${BASE_IMAGE}=oci-layout://${BASE_IMAGE_TARGET}" \
--load --tag "${TARGET_IMAGE}" \
"images/base-${TARGET}"
mkdir -p "${IMAGE_TARGET}"
docker image save "${TARGET_IMAGE}" | tar -x -C "${IMAGE_TARGET}"
fi
CONTEXT_SRC="oci-layout://${IMAGE_TARGET}"
else
CONTEXT_SRC="docker-image://${TARGET_IMAGE}"
fi
./download.sh
./generate.sh "$TARGET" "$VARIANT" "${ADDINS[@]}"
docker buildx --builder ffbuilder build \
--cache-from=type=local,src=.cache/"${IMAGE/:/_}" \
--cache-to=type=local,mode=max,dest=.cache/"${IMAGE/:/_}" \
--build-context "${TARGET_IMAGE}=${CONTEXT_SRC}" \
--load --tag "$IMAGE" .
if [[ -z "$NOCLEAN" ]]; then
docker buildx rm -f ffbuilder
rm -rf .cache/images
fi