don't use docker-machine for k8petstore on linux

pull/6/head
jvance 2015-11-10 11:22:53 -08:00
parent 69427c0a8e
commit 5ccf073969
4 changed files with 22 additions and 41 deletions

View File

@ -14,17 +14,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
!/bin/bash
#!/bin/bash
source ../../hack/lib/util.sh # need kube::util::host_platform()
HOST_OS=$(kube::util::host_platform)
HOST_OS=${HOST_OS%/*} # just host_os name
function setup_vm() {
### Provider = vbox. You can use another one if you want... But untested.
PROVIDER=virtualbox
### Create a VM specific to this app...
if docker-machine ls |grep -q k8petstore ; then
echo "VM already exists, moving on..."
if docker-machine ls | grep -q k8petstore ; then
echo "VM already exists, moving on..."
else
docker-machine create --driver $PROVIDER k8petstore
docker-machine create --driver $PROVIDER k8petstore
fi
}
@ -34,27 +39,24 @@ function setup_docker() {
eval "$(docker-machine env k8petstore)"
docker rm -f `docker ps -a -q`
### Now capture the IP.
MACHINE_IP="`docker-machine ip k8petstore`"
}
function build_containers() {
version="`date +"%m-%d-%Y-%s"`"
pushd ../redis
pushd redis
docker build -t jayunit100/k8-petstore-redis:$version ./
popd
pushd ../redis-master
pushd redis-master
docker build -t jayunit100/k8-petstore-redis-master:$version ./
popd
pushd ../redis-slave
pushd redis-slave
docker build -t jayunit100/k8-petstore-redis-slave:$version ./
popd
pushd ../web-server
pushd web-server
docker build -t jayunit100/k8-petstore-web-server:$version ./
popd
}
@ -68,14 +70,16 @@ function runk8petstore() {
### TODO, add slaves.
echo "Running k8petstore now..."
docker run -d -p 6379:6379 jayunit100/k8-petstore-redis-master:$version
docker run -d -e REDISMASTER_SERVICE_HOST=$MACHINE_IP -e REDISMASTER_SERVICE_PORT=6379 -p 3000:3000 jayunit100/k8-petstore-web-server:$version
docker run --name redis -d -p 6379:6379 jayunit100/k8-petstore-redis-master:$version
docker run --link redis:redis -d -e REDISMASTER_SERVICE_HOST=redis -e REDISMASTER_SERVICE_PORT=6379 -p 3000:3000 jayunit100/k8-petstore-web-server:$version
}
setup_vm
setup_docker
if [[ "$HOST_OS" != linux ]] ; then
setup_vm
setup_docker
fi
build_containers

View File

@ -8,7 +8,7 @@
#
# Just a stub.
FROM jayunit100/redis:2.8.19
FROM redis
ADD etc_redis_redis.conf /etc/redis/redis.conf

View File

@ -8,7 +8,7 @@
#
# Just a stub.
FROM jayunit100/redis:2.8.19
FROM redis
ADD run.sh /run.sh

View File

@ -5,30 +5,7 @@
#
# Pull base image.
FROM ubuntu
# Install Redis.
RUN \
cd /tmp && \
# Modify to stay at this version rather then always update.
#################################################################
###################### REDIS INSTALL ############################
wget http://download.redis.io/releases/redis-2.8.19.tar.gz && \
tar xvzf redis-2.8.19.tar.gz && \
cd redis-2.8.19 && \
################################################################
################################################################
make && \
make install && \
cp -f src/redis-sentinel /usr/local/bin && \
mkdir -p /etc/redis && \
cp -f *.conf /etc/redis && \
rm -rf /tmp/redis-stable* && \
sed -i 's/^\(bind .*\)$/# \1/' /etc/redis/redis.conf && \
sed -i 's/^\(daemonize .*\)$/# \1/' /etc/redis/redis.conf && \
sed -i 's/^\(dir .*\)$/# \1\ndir \/data/' /etc/redis/redis.conf && \
sed -i 's/^\(logfile .*\)$/# \1/' /etc/redis/redis.conf
FROM redis
# Define mountable directories.
VOLUME ["/data"]