Skip to content

Instantly share code, notes, and snippets.

@kntyskw
Last active January 3, 2016 13:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save kntyskw/c9ec984b18249272f7e4 to your computer and use it in GitHub Desktop.
Save kntyskw/c9ec984b18249272f7e4 to your computer and use it in GitHub Desktop.
Starts private docker repository backed by S3 on ElasticBeanstalk environment. It is supposed to launch before the application container is launched so that the application container image can be pulled from the local private repository.
#!/bin/bash
. /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
# Start docker repository with name "registry"
docker run \
--name registry \
-e SETTINGS_FLAVOR=prod \
-e DOCKER_REGISTRY_CONFIG=/docker-registry/config/config_sample.yml \
-e AWS_BUCKET=$DOCKER_REPOSITORY_BUCKET \
-e STORAGE_PATH=/ \
-e AWS_KEY=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET=$AWS_SECRET_KEY \
-e SEARCH_BACKEND=sqlalchemy \
-p 49000:5000 -d \
registry docker-registry
nRetry=0
while [[ $((nRetry++)) < 3 ]]; do
echo "Checking if the registry is up..."
sleep 5
RET=`curl http://127.0.0.1:49000/v1/_ping 2>1 /dev/null`
if [[ $RET == "true" ]]; then
echo "Registry container is up"
exit 0
fi
done
echo "Failed to launch registry container"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment