configurable volumes and port set-up

This commit is contained in:
Michał 'rysiek' Woźniak 2015-01-04 02:43:49 +01:00
parent 5de8856171
commit 8f79928837

View file

@ -1,5 +1,13 @@
#!/bin/bash
#
# vars
#
# config vars
setup_volumes=true
setup_ports=false
# some basic vars
project_name="quasseldocker"
postgres_image="$project_name/postgres"
@ -11,7 +19,20 @@ quassel_container="$project_name-quassel"
postgresdata="`pwd`/postgres/data"
quasselconf="`pwd`/quassel/quasselcore.conf"
#
# prep work
#
# should we set-up the volumes?
if [ "$setup_volumes" = true ]; then
postgres_volume="-v $postgresdata:/var/lib/postgresql/"
quassel_volume="-v $quasselconf:/var/lib/quassel/quasselcore.conf"
fi
# should we set-up the port forwarding to the host system?
if [ "$setup_ports" = true ]; then
quassel_port="-p 4242:4242"
fi
# build postgres image
buildpostgres="docker build -t $postgres_image postgres"
@ -20,10 +41,10 @@ buildpostgres="docker build -t $postgres_image postgres"
buildquassel="docker build -t $quassel_image quassel"
# postgres docker
runpostgres="docker run -h $postgres_container --name $postgres_container -v $postgresdata:/var/lib/postgresql/ -d $postgres_image"
runpostgres="docker run -h $postgres_container --name $postgres_container $postgres_volume -d $postgres_image"
# quassel docker
runquassel="docker run -h $quassel_container --link=$postgres_container:$postgres_container -v $quasselconf:/var/lib/quassel/quasselcore.conf --name $quassel_container -d $quassel_image"
runquassel="docker run -h $quassel_container --link=$postgres_container:$postgres_container $quassel_volume $quassel_port --name $quassel_container -d $quassel_image"
# kill all
killall="docker kill $quassel_container $postgres_container"
@ -33,12 +54,12 @@ rmall="docker rm -v $quassel_container $postgres_container"
# info
info="remember to prep both environments if needed (e.g. after clean build):
- docker run --entrypoint /bin/sh -u root -t -i -v $postgresdata:/var/lib/postgresql/ --rm $postgres_image -c /root/prep.sh
- docker run --entrypoint /bin/sh -u root -t -i -v $quasselconf:/var/lib/quassel/quasselcore.conf --name $quassel_container --rm $quassel_image -c 'chown quasselcore:quassel /var/lib/quassel/quasselcore.conf'
- docker run --entrypoint /bin/sh -u root -t -i $postgres_volume --rm $postgres_image -c /root/prep.sh
- docker run --entrypoint /bin/sh -u root -t -i $quassel_volume --name $quassel_container --rm $quassel_image -c 'chown quasselcore:quassel /var/lib/quassel/quasselcore.conf'
root access to both containers:
- docker run --entrypoint /bin/sh -u root -h $postgres_container -t -i --name $postgres_container --rm $postgres_image -c /bin/bash
- docker run --entrypoint /bin/sh -u root -h $quassel_container --link=$postgres_container:$postgres_container -t -i -v $quasselconf:/var/lib/quassel/quasselcore.conf --name $quassel_container --rm $quassel_image -c /bin/bash"
- docker run --entrypoint /bin/sh -u root -h $quassel_container --link=$postgres_container:$postgres_container -t -i $quassel_volume --name $quassel_container --rm $quassel_image -c /bin/bash"
# help