Advertisement
Guest User

Hipache and Meteor

a guest
Aug 29th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.02 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Run all application containers
  4.  
  5. echo Starting Hipache reverse proxy container...
  6.  
  7. #run the main hipache container
  8. HIPACHE_CONTAINER=$(sudo docker run -d -p 80:80 -p 6379 test/hipache)
  9.  
  10. #what port is hipache running on? in case we ever decide to change from -p 80:80
  11. HIPACHE_PORT=$(sudo docker port $HIPACHE_CONTAINER 80)
  12. HIPACHE_BRIDGE=$(sudo docker inspect $HIPACHE_CONTAINER | grep Bridge | cut -d":" -f2 | cut -d'"' -f2)
  13.  
  14. #this is temporary and fails if you're running containers are on disparate docker hosts
  15. BRIDGE_IP=$(/sbin/ifconfig $HIPACHE_BRIDGE | sed -n '2 p' | awk '{print $2}' | cut -d":" -f2)
  16.  
  17. #get the port that REDIS is running on
  18. REDIS_PORT=$(sudo docker port $HIPACHE_CONTAINER 6379)
  19. REDIS_HOST=$BRIDGE_IP
  20.  
  21. echo Starting MongoDB container...
  22.  
  23. #run the mongodb container
  24. MONGODB_CONTAINER=$(sudo docker run -d -v=/data/db/testdb:/tmp/data -e DATA_DIR=/tmp/data -e OPTS="--smallfiles" -p 27017 test/mongodb)
  25. MONGODB_PORT=$(sudo docker port $MONGODB_CONTAINER 27017)
  26. MONGODB_HOST=$BRIDGE_IP
  27.  
  28. echo Starting Meteor application containers...
  29.  
  30. #run two instances of meteor application
  31. METEOR_CONTAINER_1=$(sudo docker run -d -p 3000 -e PORT=3000 -e MONGO_URL=mongodb://$MONGODB_HOST:$MONGODB_PORT test/meteor)
  32. METEOR_PORT_1=$(sudo docker port $METEOR_CONTAINER_1 3000)
  33. METEOR_HOST_1=$BRIDGE_IP
  34.  
  35. METEOR_CONTAINER_2=$(sudo docker run -d -p 3001 -e PORT=3001 -e MONGO_URL=mongodb://$MONGODB_HOST:$MONGODB_PORT test/meteor)
  36. METEOR_PORT_2=$(sudo docker port $METEOR_CONTAINER_2 3001)
  37. METEOR_HOST_2=$BRIDGE_IP
  38.  
  39.  
  40. echo Registering application instances in Hipache, please wait...
  41.  
  42. #redis takes a bit of time to load up...
  43. sleep 5
  44.  
  45. #make sure the main hipache knows about our new http://test.local domain`
  46. redis-cli -h $REDIS_HOST -p $REDIS_PORT rpush frontend:test.local testlocal
  47. redis-cli -h $REDIS_HOST -p $REDIS_PORT rpush frontend:test.local http://$METEOR_HOST_1:$METEOR_PORT_1
  48. redis-cli -h $REDIS_HOST -p $REDIS_PORT rpush frontend:test.local http://$METEOR_HOST_2:$METEOR_PORT_2
  49.  
  50. echo Done.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement