2018-07-31 11:30:21 -04:00
|
|
|
#!/usr/bin/env bash
|
2018-11-13 14:15:36 -05:00
|
|
|
#####################################################################################################
|
2018-08-07 11:26:43 -04:00
|
|
|
# Starts up the api, portal, and dependent services via
|
|
|
|
# docker-compose. The api will be available on localhost:9000 and the
|
|
|
|
# portal will be on localhost:9001
|
2018-10-29 20:22:33 -04:00
|
|
|
#
|
2018-11-13 14:15:36 -05:00
|
|
|
# Relevant overrides can be found at ./.env and ../docker/.env
|
|
|
|
#
|
2018-10-29 20:22:33 -04:00
|
|
|
# Options:
|
2018-11-13 14:15:36 -05:00
|
|
|
# -t, --timeout seconds: overwrite ping timeout, default of 60
|
|
|
|
# -a, --api-only: only starts up vinyldns-api and its dependencies, excludes vinyldns-portal
|
2019-01-04 11:36:08 -05:00
|
|
|
# -c, --clean: re-pull vinyldns/api and vinyldns/portal images from docker hub
|
|
|
|
# -v, --version tag: overwrite vinyldns/api and vinyldns/portal docker tags
|
2018-11-13 14:15:36 -05:00
|
|
|
#####################################################################################################
|
2018-07-31 11:30:21 -04:00
|
|
|
|
2018-11-13 14:15:36 -05:00
|
|
|
function wait_for_url {
|
|
|
|
echo "pinging ${URL} ..."
|
|
|
|
DATA=""
|
|
|
|
RETRY="$TIMEOUT"
|
|
|
|
while [ "$RETRY" -gt 0 ]
|
|
|
|
do
|
|
|
|
DATA=$(curl -I -s "${URL}" -o /dev/null -w "%{http_code}")
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "Succeeded in connecting to ${URL}!"
|
|
|
|
break
|
|
|
|
else
|
2019-05-15 10:27:23 -04:00
|
|
|
echo "Retrying" >&2
|
2018-11-13 14:15:36 -05:00
|
|
|
|
|
|
|
let RETRY-=1
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
if [ "$RETRY" -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "Exceeded retries waiting for ${URL} to be ready, failing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2018-10-29 20:22:33 -04:00
|
|
|
|
|
|
|
function usage {
|
|
|
|
printf "usage: docker-up-vinyldns.sh [OPTIONS]\n\n"
|
|
|
|
printf "starts up a local VinylDNS installation using docker compose\n\n"
|
|
|
|
printf "options:\n"
|
2018-11-13 14:15:36 -05:00
|
|
|
printf "\t-t, --timeout seconds: overwrite ping timeout of 60\n"
|
|
|
|
printf "\t-a, --api-only: do not start up vinyldns-portal\n"
|
2019-01-04 11:36:08 -05:00
|
|
|
printf "\t-c, --clean: re-pull vinyldns/api and vinyldns/portal images from docker hub\n"
|
|
|
|
printf "\t-v, --version tag: overwrite vinyldns/api and vinyldns/portal docker tags\n"
|
2018-10-29 20:22:33 -04:00
|
|
|
}
|
|
|
|
|
2019-01-04 11:36:08 -05:00
|
|
|
function clean_images {
|
|
|
|
if (( $CLEAN == 1 )); then
|
|
|
|
echo "cleaning docker images..."
|
2019-10-08 19:13:15 -04:00
|
|
|
docker rmi vinyldns/api:$VINYLDNS_VERSION
|
|
|
|
docker rmi vinyldns/portal:$VINYLDNS_VERSION
|
2019-01-04 11:36:08 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function wait_for_api {
|
|
|
|
echo "Waiting for api..."
|
|
|
|
URL="$VINYLDNS_API_URL"
|
|
|
|
wait_for_url
|
|
|
|
}
|
2018-10-29 20:22:33 -04:00
|
|
|
|
2019-01-04 11:36:08 -05:00
|
|
|
function wait_for_portal {
|
|
|
|
# check if portal was skipped
|
|
|
|
if [ "$SERVICE" != "api" ]; then
|
|
|
|
echo "Waiting for portal..."
|
|
|
|
URL="$VINYLDNS_PORTAL_URL"
|
|
|
|
wait_for_url
|
|
|
|
fi
|
|
|
|
}
|
2018-07-31 11:30:21 -04:00
|
|
|
|
2019-01-04 11:36:08 -05:00
|
|
|
# initial var setup
|
|
|
|
DIR=$( cd $(dirname $0) ; pwd -P )
|
|
|
|
TIMEOUT=60
|
Support building docker images locally and without SBT (#753)
Fixes #744
Overhauls our docker release process to run releases of docker outside of SBT. This was tested through the signing process deploying SNAPSHOT images to docker hub.
All images do a git clone to pull vinyldns, and perform the build of the container based on that git clone.
- A new `build` directory contains the things to be built, for this PR only the docker images are here. Anticipate possibly pulling in other artifacts in the future.
- `build/docker` contains all of the docker setup
- `build/docker/test` contains a func test docker image that can be used to test any VinylDNS API instance
- `build/docker/test-bind9` contains our bind9 setup
- `build/docker/api` is a MySQL only API distribution
- `build/docker/portal` is a MySQL only Portal distribution
In addition, a few files are added to make the build easier:
- `build/start.sh` starts a given vinyldns version
- `build/stop.sh` stops the current running vinyldns setup
- `build/release.sh` this is the **MAIN** guy that performs the build. Lots of arguments that are useful for testing. Can provide a repository (for publishing to a docker register that is not docker hub), for building clean vs. assuming docker images. Besides building everything, also runs func tests (smoke tests) against the docker image before completing.
Added a `README.md` for others to follow along with
To test..
1. Make sure you increase your docker machine settings to 4GB (the default of 2GB failed)
2. Go to the `build` directory
3. From there, run `./release.sh -c -t 111` to only build the docker images, this should build `0.9.4-b111`
4. Start it up, run `./start.sh -v 0.9.4-b111`
5. Login to the portal at http://localhost:9001
6. When finished, run `./stop.sh` from the build directory
*If you see an error code 137 error, you need to increase your memory*
2019-10-22 19:11:28 -04:00
|
|
|
DOCKER_COMPOSE_CONFIG="${DIR}/../docker/docker-compose-quick-start.yml"
|
2019-01-04 11:36:08 -05:00
|
|
|
# empty service starts up all docker services in compose file
|
|
|
|
SERVICE=""
|
|
|
|
# when CLEAN is set to 1, existing docker images are deleted so they are re-pulled
|
|
|
|
CLEAN=0
|
2020-09-30 20:23:12 -04:00
|
|
|
# default to latest for docker versions
|
|
|
|
export VINYLDNS_VERSION=latest
|
2019-01-04 11:36:08 -05:00
|
|
|
|
|
|
|
# source env before parsing args so vars can be overwritten
|
2018-09-17 11:18:37 -04:00
|
|
|
set -a # Required in order to source docker/.env
|
|
|
|
# Source customizable env files
|
|
|
|
source "$DIR"/.env
|
|
|
|
source "$DIR"/../docker/.env
|
|
|
|
|
2019-01-04 11:36:08 -05:00
|
|
|
# parse args
|
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case "$1" in
|
|
|
|
-t | --timeout ) TIMEOUT="$2"; shift;;
|
|
|
|
-a | --api-only ) SERVICE="api";;
|
|
|
|
-c | --clean ) CLEAN=1;;
|
2019-10-08 19:13:15 -04:00
|
|
|
-v | --version ) export VINYLDNS_VERSION=$2; shift;;
|
2019-01-04 11:36:08 -05:00
|
|
|
* ) usage; exit;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
clean_images
|
2018-07-31 11:30:21 -04:00
|
|
|
|
2019-01-04 11:36:08 -05:00
|
|
|
echo "timeout is set to ${TIMEOUT}"
|
2019-10-08 19:13:15 -04:00
|
|
|
echo "vinyldns version is set to '${VINYLDNS_VERSION}'"
|
2018-07-31 11:30:21 -04:00
|
|
|
|
2019-01-04 11:36:08 -05:00
|
|
|
echo "Starting vinyldns and all dependencies in the background..."
|
|
|
|
docker-compose -f "$DOCKER_COMPOSE_CONFIG" up -d ${SERVICE}
|
2018-07-31 11:30:21 -04:00
|
|
|
|
2019-01-04 11:36:08 -05:00
|
|
|
wait_for_api
|
|
|
|
wait_for_portal
|