2017-07-24 12:21:38 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set +e
|
|
|
|
|
|
|
|
echo "Usage: #./builder [registry version] [photon tag] [registry username] [registry password]"
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
error "Please set the 'version' variable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z $2 ]; then
|
|
|
|
error "Please set the 'photonversion' variable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z $3 ]; then
|
|
|
|
error "Please set the 'username' variable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z $4 ]; then
|
|
|
|
error "Please set the 'password' variable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
VERSION="$1"
|
|
|
|
PHOTONVERSION="$2"
|
|
|
|
USERNAME="$3"
|
|
|
|
PASSWORD="$4"
|
|
|
|
PHOTONIMAGE=vmware/registry:$PHOTONVERSION
|
|
|
|
|
|
|
|
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/distribution.XXXXXX`
|
|
|
|
git clone -b $VERSION https://github.com/docker/distribution.git $TEMP
|
|
|
|
|
|
|
|
echo 'build the registry binary bases on the golang:1.7.3...'
|
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/bin/registry binary
|
|
|
|
|
|
|
|
docker rm -f $ID
|
|
|
|
docker rmi -f registry-golang
|
|
|
|
|
|
|
|
echo "Build registry binary success, then to build photon image..."
|
|
|
|
cd $cur
|
|
|
|
echo $PHOTONIMAGE
|
2017-08-30 10:13:54 +02:00
|
|
|
cp $TEMP/cmd/registry/config-example.yml config.yml
|
2017-07-24 12:21:38 +02:00
|
|
|
docker build -f Dockerfile -t $PHOTONIMAGE .
|
|
|
|
|
|
|
|
rm -rf $TEMP
|
|
|
|
rm -rf binary
|
2017-08-30 10:13:54 +02:00
|
|
|
rm -rf config.yml
|
2017-07-24 12:21:38 +02:00
|
|
|
|
2017-07-26 11:22:03 +02:00
|
|
|
echo 'Push image to docker hub.'
|
2017-08-30 10:13:54 +02:00
|
|
|
../../pushimage.sh $PHOTONIMAGE $USERNAME $PASSWORD
|