-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbootstrap
executable file
·49 lines (44 loc) · 1.38 KB
/
bootstrap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
#
# NAME
# bootstrap -- initialize/update docker environment
#
# SYNOPSIS
# bootstrap
# bootstrap shellinit
#
# DESCRIPTION
# Execute this script without parameters to build the local docker
# environment. Once bootstrapped, dependent services are running
# via docker-compose and the environment variables are written to
# *build/test-environment* for future use.
#
# Running this script with the _shellinit_ command line parameter
# causes it to simply interrogate the running docker environment,
# update *build/test-environment*, and print the environment to
# the standard output stream in a shell executable manner. This
# makes the following pattern for setting environment variables
# in the current shell work.
#
# prompt% $(./bootstrap shellinit)
#
# vim: set ts=2 sts=2 sw=2 et:
if test -e /var/run/docker.sock
then
DOCKER_IP=127.0.0.1
else
echo "Failed to initialize docker environment"
exit 2
fi
get_exposed_port() {
docker-compose port $1 $2 | cut -d: -f2
}
set -e
mkdir -p build
docker-compose down --volumes --remove-orphans
docker-compose up -d
cat > build/test-environment <<EOF
export CONSUL_ENDPOINT=http://${DOCKER_IP}:$(get_exposed_port consul 8500)
export S3_ENDPOINT=http://${DOCKER_IP}:$(get_exposed_port localstack 4567)
EOF
printf "\nBootstrap complete\n\nDon't forget to execute \". build/test-environment\"\n"