Skip to content

Instantly share code, notes, and snippets.

@kntyskw
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kntyskw/5ab96ac8e6f3712c67ad to your computer and use it in GitHub Desktop.
Save kntyskw/5ab96ac8e6f3712c67ad to your computer and use it in GitHub Desktop.
Downloads docker registry container image archive from the bucket specified by environment variable DOCKER_REGISTRY_BUCKET and import it to docker.
#!/bin/sh
# Check if the registry image is already installed
IS_INSTALLED=`docker images | grep -E 'registry\s*latest' | wc -l`
if [ $IS_INSTALLED == 0 ]; then
. /opt/elasticbeanstalk/hooks/common.sh
# Load ElasticBeanstalk environment variables
touch /tmp/env.sh
chmod 600 /tmp/env.sh
jq .docker.env[] $EB_CONFIG_FILE | tr -d \" > /tmp/env.sh
source /tmp/env.sh
rm /tmp/env.sh
echo "Downloading registry image"
aws s3 cp s3://$DOCKER_REPOSITORY_BUCKET/registry-image.tgz /tmp/registry-image.tgz
echo "Installing registry image"
cat /tmp/registry-image.tgz | docker import - registry:latest
else
echo "registry image has been installed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment