Last active
December 26, 2015 17:49
-
-
Save nakosung/7190083 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# public port | |
export WEBFRONTEND_PORT=6060 | |
export GATEWAY_PORT=6061 | |
export GIT_PORT=6062 | |
export LOCAL_IP=$(ip addr show | grep eth0 | grep inet | awk '{print $2}' | sed -e 's/\/.*$//') | |
# install jq | |
if [ "$(uname)" == "Darwin" ] | |
then | |
wget http://stedolan.github.io/jq/download/osx64/jq | |
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ] | |
then | |
wget http://stedolan.github.io/jq/download/linux64/jq | |
elif [ -n "$COMSPEC" -a -x "$COMSPEC" ] | |
then | |
echo $0: this script does not support Windows \:\( | |
fi | |
chmod +x jq | |
cat <<EOF > ./run.sh | |
DOCKERENVS= | |
function get_ip() | |
{ | |
echo \$1 | |
echo \$2 | |
local container=\$(docker ps | grep \$2 | awk {'print \$1}') | |
local ip=\$(docker inspect \$container | ./jq .[0].NetworkSettings.IPAddress | sed s/\"//g) | |
DOCKERENVS=\$(echo "-e \$1=\$ip \$DOCKERENVS") | |
} | |
function run() | |
{ | |
DOCKERENVS= | |
get_ip MONGO_ADDRESS mongodb | |
get_ip ZK_ADDRESS zookeeper | |
get_ip REDIS_ADDRESS redis | |
docker run \$DOCKERENVS \$* | |
} | |
run \$* | |
EOF | |
chmod +x run.sh | |
cat <<EOF > build.sh | |
git clone ssh://[email protected]/redduck/\$1.git | |
pushd \$1 | |
git submodule update --init | |
docker build -t \$1 . | |
popd | |
EOF | |
chmod +x build.sh | |
# ZooKeeper 3.4.5 | |
docker run -d -name zk -p 2181:2181 paulczar/zookeeper-3.4.5 /opt/zookeeper-3.4.5/bin/zkServer.sh start-foreground | |
# Mongodb | |
docker run -d -name mongo -p 27017 damien/mongodb mongod | |
# redis | |
docker run -d -name redis srid/redis:2.6 | |
contained=( eventbus router db devices bank party monopoly-server push ) | |
for i in "${contained[@]}" | |
do | |
./build.sh $i | |
done | |
./build.sh cdn | |
./build.sh server | |
./build.sh gateway | |
for i in "${contained[@]}" | |
do | |
./run.sh -d $i | |
done | |
./run.sh -d gateway | |
./run.sh -d server | |
./run.sh -d -p 7000:7000 cdn | |
./nginx.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment