bootstrap 1.43 KB
Newer Older
BAIRE Anthony's avatar
BAIRE Anthony committed
1 2 3 4 5 6
#!/bin/bash

set -e

. prepare.sh

CAMPION Sebastien's avatar
CAMPION Sebastien committed
7 8 9 10 11 12

mkdir -p certs
if [ ! -f cert/server.key ] & [ ! -f certs/server.crt ]; then
    openssl req -subj '/CN=localhost/O=Registry Demo/C=US' -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout certs/server.key -out certs/server.crt
fi

BAIRE Anthony's avatar
BAIRE Anthony committed
13
# build base image (if not present)
14
(set -x ; make base-debian)
15 16 17

# build the binaries (for the 'toolbox' and 'ssh' images)
(set -x ; make .stamp.build)
BAIRE Anthony's avatar
BAIRE Anthony committed
18 19 20 21 22 23


if [ -n "$*" ] ; then
	TODO="$*"
else
	docker-compose down
CAMPION Sebastien's avatar
CAMPION Sebastien committed
24
  TODO="dev-mysql dev-smtpsink dev-ssh dev-rails dev-django dev-nginx"
BAIRE Anthony's avatar
BAIRE Anthony committed
25 26 27 28 29 30 31 32 33 34 35
fi

(set -xe
	for name in $TODO
	do
		# ensure $name does not start with '-'
		[[ ! "$name" =~ ^- ]]

		# FIXME: race condition in docker-compose (if the command
		# finishes too quickly, then it is run twice)
		docker-compose run --rm "$name" sh -c "sleep 1 ; /dk/container_init"
36
		docker-compose up -d "$name"
BAIRE Anthony's avatar
BAIRE Anthony committed
37 38 39 40 41
	done
	docker-compose up -d
	docker-compose ps
)

BAIRE Anthony's avatar
BAIRE Anthony committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
# build the factories
for name in `echo 'select concat(name, ":", version) as img from docker_os order by img;' | docker exec -i dev-mysql mysql -uroot allgo | grep -v '^img$'`
do
	tag="localhost:8002/allgo/dev/factory/$name"
	if docker inspect --type image -- "$tag" >/dev/null 2>/dev/null
	then
		echo "$name: already pulled"
		(set -x
		docker push -- "$tag"
		docker rmi  -- "$name" || true
		)
	else
		echo "$name:"
		(set -x
		docker pull -- "$name"
		docker tag  -- "$name" "$tag"
		docker push -- "$tag"
		docker rmi  -- "$name"
		)
	fi
done