Skip to content

Commit

Permalink
fix zot
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Oct 11, 2023
1 parent 6cfe694 commit 1091e82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 8 additions & 8 deletions oci/private/image.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}")
Expand All @@ -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.
Expand Down Expand Up @@ -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}"
10 changes: 6 additions & 4 deletions oci/private/registry/zot_launcher.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}" <<EOF
{
"storage":{ "rootDirectory": "$storage_dir/all", "dedupe": false, "subPaths": {"/image": {"rootDirectory": "$storage_dir"}}},
"storage": { "rootDirectory": "$storage_dir/..", "dedupe": false, "commit": true },
"http":{ "port": "0", "address": "127.0.0.1" },
"log":{ "level": "debug" }
"log":{ "level": "info" }
}
EOF
"${ZOT}" serve "${config_path}" >> $output 2>&1 &
Expand All @@ -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"
}

0 comments on commit 1091e82

Please sign in to comment.