29 lines
800 B
Bash
29 lines
800 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
# Function to get SHA256 digest
|
||
|
get_digest() {
|
||
|
docker pull $1 > /dev/null
|
||
|
digest=$(docker inspect --format='{{index .RepoDigests 0}}' $1 | cut -d'@' -f2)
|
||
|
echo $digest
|
||
|
}
|
||
|
|
||
|
# Array of images to process
|
||
|
declare -A images
|
||
|
images["public.ecr.aws/awsguru/aws-lambda-adapter:0.8.4"]="aws-lambda-adapter"
|
||
|
images["docker.io/denoland/deno:bin"]="deno_bin"
|
||
|
images["docker.io/library/debian:bookworm-slim"]="deno_runtime"
|
||
|
|
||
|
# Process each image
|
||
|
for image in "${!images[@]}"; do
|
||
|
alias=${images[$image]}
|
||
|
digest=$(get_digest $image)
|
||
|
echo "Image: $image"
|
||
|
echo "Alias: $alias"
|
||
|
echo "Digest: $digest"
|
||
|
echo
|
||
|
|
||
|
# Update Dockerfile
|
||
|
sed -i "s|FROM $image AS $alias|FROM $image@$digest AS $alias|g" Dockerfile
|
||
|
done
|
||
|
|
||
|
echo "Dockerfile updated with SHA256 digests."
|