Skip to content

Instantly share code, notes, and snippets.

@Sitin
Last active October 1, 2022 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sitin/e69ea8a299f972da7638644419cba604 to your computer and use it in GitHub Desktop.
Save Sitin/e69ea8a299f972da7638644419cba604 to your computer and use it in GitHub Desktop.
Get Envoy binary
#!/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}"
@Sitin
Copy link
Author

Sitin commented Oct 1, 2022

HOWTO

Get the script:

git clone git@gist.github.com:e69ea8a299f972da7638644419cba604.git get-envoy-binary
cd get-envoy-binary
chmod +c get-envoy-binary.sh

Example usage:

./get-envoy-binary.sh 1.24 podman .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment