2020-09-02 16:07:59 +00:00
|
|
|
#!/bin/bash
|
2020-09-02 23:03:23 +00:00
|
|
|
set -xe
|
2020-09-02 16:07:59 +00:00
|
|
|
cd "$(dirname "$0")"
|
2020-09-02 23:03:23 +00:00
|
|
|
source util/vars.sh
|
2020-09-02 16:07:59 +00:00
|
|
|
|
2022-07-12 23:24:40 +00:00
|
|
|
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" \
|
2022-08-02 18:37:17 +00:00
|
|
|
--driver-opt network=host \
|
2022-07-12 23:24:40 +00:00
|
|
|
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=-1 \
|
|
|
|
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=-1
|
|
|
|
|
2023-06-18 14:44:57 +00:00
|
|
|
docker container inspect ffbuildreg &>/dev/null || \
|
|
|
|
docker run --rm -d -p 127.0.0.1:64647:5000 --name ffbuildreg registry:2
|
|
|
|
LOCAL_REG_PORT="$(docker container inspect --format='{{range $p, $conf := .NetworkSettings.Ports}}{{(index $conf 0).HostPort}}{{end}}' ffbuildreg)"
|
|
|
|
LOCAL_ROOT="127.0.0.1:${LOCAL_REG_PORT}/local"
|
|
|
|
|
|
|
|
export REGISTRY_OVERRIDE_DL="127.0.0.1:${LOCAL_REG_PORT}" GITHUB_REPOSITORY_DL="local"
|
2022-08-02 18:37:17 +00:00
|
|
|
|
2023-06-18 14:44:57 +00:00
|
|
|
if [[ -z "$QUICKBUILD" ]]; then
|
2021-07-07 12:37:58 +00:00
|
|
|
if grep "FROM.*base.*" "images/base-${TARGET}/Dockerfile" >/dev/null 2>&1; then
|
2022-07-12 23:24:40 +00:00
|
|
|
docker buildx --builder ffbuilder build \
|
|
|
|
--cache-from=type=local,src=.cache/"${BASE_IMAGE/:/_}" \
|
|
|
|
--cache-to=type=local,mode=max,dest=.cache/"${BASE_IMAGE/:/_}" \
|
2022-08-02 18:37:17 +00:00
|
|
|
--push --tag "${LOCAL_ROOT}/base:latest" images/base
|
2021-07-07 12:37:58 +00:00
|
|
|
fi
|
2021-05-12 17:50:12 +00:00
|
|
|
|
2022-07-12 23:24:40 +00:00
|
|
|
docker buildx --builder ffbuilder build \
|
|
|
|
--cache-from=type=local,src=.cache/"${TARGET_IMAGE/:/_}" \
|
|
|
|
--cache-to=type=local,mode=max,dest=.cache/"${TARGET_IMAGE/:/_}" \
|
2022-08-02 18:37:17 +00:00
|
|
|
--push --tag "${LOCAL_ROOT}/base-${TARGET}:latest" \
|
|
|
|
--build-arg GH_REPO="$LOCAL_ROOT" "images/base-${TARGET}"
|
|
|
|
|
2023-06-18 14:44:57 +00:00
|
|
|
export REGISTRY_OVERRIDE="$REGISTRY_OVERRIDE_DL" GITHUB_REPOSITORY="$GITHUB_REPOSITORY_DL"
|
2021-07-07 12:37:58 +00:00
|
|
|
fi
|
2020-09-20 13:46:29 +00:00
|
|
|
|
2020-09-27 21:11:10 +00:00
|
|
|
./generate.sh "$TARGET" "$VARIANT" "${ADDINS[@]}"
|
2020-09-02 16:07:59 +00:00
|
|
|
|
2023-06-18 14:44:57 +00:00
|
|
|
docker buildx --builder ffbuilder build -f Dockerfile.dl \
|
|
|
|
--cache-from=type=local,src=.cache/"${DL_IMAGE/:/_}" \
|
|
|
|
--cache-to=type=local,mode=max,dest=.cache/"${DL_IMAGE/:/_}" \
|
|
|
|
--push --tag "${LOCAL_ROOT}/dl_cache:latest" .
|
|
|
|
|
2022-07-12 23:24:40 +00:00
|
|
|
docker buildx --builder ffbuilder build \
|
|
|
|
--cache-from=type=local,src=.cache/"${IMAGE/:/_}" \
|
|
|
|
--cache-to=type=local,mode=max,dest=.cache/"${IMAGE/:/_}" \
|
|
|
|
--load --tag "$IMAGE" .
|
|
|
|
|
2023-06-18 14:44:57 +00:00
|
|
|
docker container stop ffbuildreg
|
2022-07-12 23:24:40 +00:00
|
|
|
docker buildx rm -f ffbuilder
|