diff --git a/oci/private/image.sh.tpl b/oci/private/image.sh.tpl index f06edeaa..50454c8d 100644 --- a/oci/private/image.sh.tpl +++ b/oci/private/image.sh.tpl @@ -60,8 +60,6 @@ function base_from_layout() { "${CRANE}" push "${oci_layout_path}" "${registry}/image:latest" --image-refs "${refs}" > "${output}" 2>&1 - echo "${output}" >&2 - if grep -q "MANIFEST_INVALID" "${output}"; then cat >&2 << EOF @@ -79,7 +77,7 @@ EOF cat "${refs}" } -# removes unreferenced blobs from oci-layout +# removes unreferenced blobs from oci-layout and normalizes index.json function gc() { local ref="$1" local digest=$("${CRANE}" digest "${ref}") @@ -94,6 +92,9 @@ function gc() { fi done done + mv "${STORAGE_DIR}/index.json" "${STORAGE_DIR}/temp.json" + "${JQ}" --arg digest "$digest" '.manifests |= [map(select(.digest == $digest and .annotations == null))[0]]' "${STORAGE_DIR}/temp.json" > "${STORAGE_DIR}/index.json" + rm "${STORAGE_DIR}/temp.json" } # this will redirect stderr(2) to stderr file. @@ -178,11 +179,10 @@ if [ -n "${WORKDIR}" ]; then fi if [ -n "$OUTPUT" ]; then - # "${CRANE}" pull "${REF}" "./${OUTPUT}" --format=oci - # gc "${REF}" + + "${CRANE}" pull "${REF}" "./${OUTPUT}" --format=oci + gc "${REF}" stop_registry "${STORAGE_DIR}" - cat $STDERR fi -} -# 2>> "${STDERR}" +} 2>> "${STDERR}" diff --git a/oci/private/registry/zot_launcher.sh.tpl b/oci/private/registry/zot_launcher.sh.tpl index ce40f774..b58d6a9d 100644 --- a/oci/private/registry/zot_launcher.sh.tpl +++ b/oci/private/registry/zot_launcher.sh.tpl @@ -8,12 +8,11 @@ function start_registry() { local config_path="$storage_dir/config.json" mkdir -p "${storage_dir}" - echo "$storage_dir" >&2 cat > "${config_path}" <> $output 2>&1 & @@ -34,7 +33,10 @@ EOF return 0 } + + function stop_registry() { local storage_dir="$1" - rm "$storage_dir/config.json" + rm -r "${storage_dir}/.uploads" + rm -r "${storage_dir}/config.json" } \ No newline at end of file