Running Docker using Vagrant
This commit is contained in:
103
Vagrantfile
vendored
Normal file
103
Vagrantfile
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure(2) do |config|
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://atlas.hashicorp.com/search.
|
||||
config.vm.box = "ubuntu/trusty64"
|
||||
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.memory = 2048
|
||||
v.cpus = 2
|
||||
end
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||
|
||||
# Create a public network, which generally matched to bridged network.
|
||||
# Bridged networks make the machine appear as another physical device on
|
||||
# your network.
|
||||
# config.vm.network "public_network"
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
# config.vm.synced_folder "../data", "/vagrant_data"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
# vb.memory = "1024"
|
||||
# end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
||||
# such as FTP and Heroku are also available. See the documentation at
|
||||
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
||||
# config.push.define "atlas" do |push|
|
||||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
||||
# end
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
#!/bin/sh
|
||||
|
||||
# https://github.com/pussinboots/vagrant-devel/blob/master/provision/packages/java8.sh
|
||||
|
||||
if which java >/dev/null; then
|
||||
echo "skip java 8 installation"
|
||||
else
|
||||
echo "java 8 installation"
|
||||
apt-get install --yes python-software-properties
|
||||
add-apt-repository ppa:webupd8team/java
|
||||
apt-get update -qq
|
||||
echo debconf shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
|
||||
echo debconf shared/accepted-oracle-license-v1-1 seen true | /usr/bin/debconf-set-selections
|
||||
apt-get install --yes oracle-java8-installer
|
||||
yes "" | apt-get -f install
|
||||
fi
|
||||
SHELL
|
||||
|
||||
config.vm.provision "docker" do |d|
|
||||
end
|
||||
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
if which docker-compose >/dev/null; then
|
||||
echo "skip docker-compose installation"
|
||||
else
|
||||
sudo bash -c "curl -L https://github.com/docker/compose/releases/download/1.6.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose ; chmod +x /usr/local/bin/docker-compose"
|
||||
fi
|
||||
SHELL
|
||||
|
||||
end
|
||||
@@ -16,8 +16,12 @@ fi
|
||||
${DOCKER_COMPOSE?} up -d mongodb
|
||||
|
||||
if [ -z "$DOCKER_HOST_IP" ] ; then
|
||||
export DOCKER_HOST_IP=$(docker-machine ip default)
|
||||
echo set DOCKER_HOST_IP $DOCKER_HOST_IP
|
||||
if which docker-machine >/dev/null; then
|
||||
export DOCKER_HOST_IP=$(docker-machine ip default)
|
||||
else
|
||||
export DOCKER_HOST_IP=localhost
|
||||
fi
|
||||
echo set DOCKER_HOST_IP $DOCKER_HOST_IP
|
||||
fi
|
||||
|
||||
if [ -z "$SPRING_DATA_MONGODB_URI" ] ; then
|
||||
@@ -27,7 +31,7 @@ fi
|
||||
|
||||
export SERVICE_HOST=$DOCKER_HOST_IP
|
||||
|
||||
./gradlew $* build
|
||||
./gradlew $* build -x :e2e-test:test
|
||||
|
||||
if [ -z "$EVENTUATE_API_KEY_ID" -o -z "$EVENTUATE_API_KEY_SECRET" ] ; then
|
||||
echo You must set EVENTUATE_API_KEY_ID and EVENTUATE_API_KEY_SECRET
|
||||
@@ -37,11 +41,11 @@ fi
|
||||
|
||||
${DOCKER_COMPOSE?} up -d
|
||||
|
||||
$DIR/wait-for-services.sh $DOCKER_HOST_IP
|
||||
$DIR/wait-for-services.sh $DOCKER_HOST_IP 8080 8081 8082
|
||||
|
||||
set -e
|
||||
|
||||
./gradlew $* :e2e-test:cleanTest :e2e-test:test
|
||||
./gradlew -a $* :e2e-test:cleanTest :e2e-test:test -P ignoreE2EFailures=false
|
||||
|
||||
${DOCKER_COMPOSE?} stop
|
||||
${DOCKER_COMPOSE?} rm -v --force
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
#! /bin/bash
|
||||
|
||||
while [[ true ]]; do
|
||||
nc -z -w 4 ${1?} 8080 && nc -z -w 4 ${1?} 8081 && nc -z -w 4 ${1?} 8082
|
||||
if [[ "$?" -eq "0" ]]; then
|
||||
done=false
|
||||
|
||||
host=$1
|
||||
shift
|
||||
ports=$*
|
||||
|
||||
while [[ "$done" = false ]]; do
|
||||
for port in $ports; do
|
||||
curl -q http://${host}:${port}/health >& /dev/null
|
||||
if [[ "$?" -eq "0" ]]; then
|
||||
done=true
|
||||
else
|
||||
done=false
|
||||
fi
|
||||
done
|
||||
if [[ "$done" = true ]]; then
|
||||
echo connected
|
||||
break
|
||||
fi
|
||||
break;
|
||||
fi
|
||||
#curl -q http://${1?}:8080/health >& /dev/null && curl -q http://${1?}:8081/health >& /dev/null && curl -q http://${1?}:8082/health >& /dev/null
|
||||
echo -n .
|
||||
sleep 1
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user