harbor/make/photon/registry/builder

47 lines
1.1 KiB
Plaintext
Raw Normal View History

2017-07-24 12:21:38 +02:00
#!/bin/bash
set +e
if [ -z $1 ]; then
error "Please set the 'version' variable"
exit 1
fi
VERSION="$1"
set -e
# the temp folder to store binary file...
mkdir -p binary
rm -rf binary/registry || true
cd `dirname $0`
cur=$PWD
# the temp folder to store distribution source code...
TEMP=`mktemp -d ${TMPDIR-/tmp}/distribution.XXXXXX`
2017-07-24 12:21:38 +02:00
git clone -b $VERSION https://github.com/docker/distribution.git $TEMP
# add patch 2879
echo 'add patch https://github.com/docker/distribution/pull/2879 ...'
cd $TEMP
wget https://github.com/docker/distribution/pull/2879.patch
git apply 2879.patch
cd $cur
echo 'build the registry binary ...'
2017-07-25 03:32:50 +02:00
cp Dockerfile.binary $TEMP
2017-07-25 02:49:59 +02:00
docker build -f $TEMP/Dockerfile.binary -t registry-golang $TEMP
2017-07-24 12:21:38 +02:00
echo 'copy the registry binary to local...'
ID=$(docker create registry-golang)
docker cp $ID:/go/src/github.com/docker/distribution/bin/registry binary/registry
2017-07-24 12:21:38 +02:00
docker rm -f $ID
docker rmi -f registry-golang
echo "Build registry binary success, then to build photon image..."
cd $cur
cp $TEMP/cmd/registry/config-example.yml config.yml
2017-07-24 12:21:38 +02:00
rm -rf $TEMP