Last active
October 1, 2022 09:47
-
-
Save Sitin/e69ea8a299f972da7638644419cba604 to your computer and use it in GitHub Desktop.
Get Envoy binary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
if [ "$#" -ne 3 ]; then | |
echo "Illegal number of parameters!" | |
echo "Usage:" | |
echo " ./get-envoy-binary.sh <version> <container engine: podman | docker> <out directory>" | |
exit 1 | |
fi | |
version="${1}" | |
container_engine="${2}" | |
out_dir="${3}" | |
envoy_tag=v"${version}"-latest | |
image_url="invalid" | |
case "${container_engine}" in | |
podman) | |
image_url="docker.io/envoyproxy/envoy:${envoy_tag}" | |
;; | |
docker) | |
image_url="envoyproxy/envoy:${envoy_tag}" | |
;; | |
*) | |
echo "Unknown container engine: ${container_engine}. Engine must be either 'docker' or 'podman'." | |
exit 1 | |
esac | |
if [ ! -d "${out_dir}" ]; | |
then | |
echo "'${out_dir}' is not a directory!" | |
exit -1 | |
fi | |
out_path="${out_dir}/envoy" | |
if [ -f "${out_path}" ]; then | |
echo "${out_path} already exixts!" | |
exit 1 | |
fi | |
echo "Envoy image: ${image_url}" | |
echo "Envoy will be copied to: ${out_path}" | |
# Get envoy binary location within a container | |
envoy_location=$("${container_engine}" run --rm --entrypoint which "${image_url}" envoy) | |
# Create container | |
container_id=$("${container_engine}" create "${image_url}") | |
# Copy binary | |
"${container_engine}" cp "${container_id}":"${envoy_location}" "${out_path}" | |
chmod +x "${out_path}" | |
# Remove container | |
"${container_engine}" rm -v "${container_id}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HOWTO
Get the script:
Example usage:
./get-envoy-binary.sh 1.24 podman .