From: Sam Saffron Date: Thu, 31 Oct 2013 06:11:51 +0000 (-0700) Subject: bootstrapping X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1acce9e4e73ad44a8843b484f7bccdeb8024d0ed;p=discourse_docker.git bootstrapping --- diff --git a/image/Dockerfile b/image/Dockerfile index 8f0b433..7dc77ff 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -45,7 +45,14 @@ RUN apt-get -y update &&\ cp /var/www/discourse/config/environments/production.rb.sample /var/www/discourse/config/environments/production.rb - +RUN apt-get install -y runit &&\ + mkdir -p /etc/service/sshd &&\ + mkdir -p /var/run/sshd &&\ + echo "#!/bin/sh" > /etc/service/sshd/run &&\ + echo "exec 2>&1" >> /etc/service/sshd/run &&\ + echo "exec /usr/sbin/sshd -D -e" >> /etc/service/sshd/run &&\ + mkdir -p /root/.ssh &&\ + chmod +x /etc/service/sshd/run # RUN cd /var/www/discourse && bundle exec rake db:test:prepare && bundle exec rspec diff --git a/launcher b/launcher index 7927227..7b3702c 100755 --- a/launcher +++ b/launcher @@ -4,18 +4,20 @@ command=$1 config=$2 config_file=shared/config/"$config"/conf.yml cidfile=cids/"$config".cid +cidbootstrap=cids/"$config"_boostrap.cid image=samsaffron/discourse [ $# -ne 2 ] && { echo "Usage: launcher COMMAND CONFIG" echo "Commands:" - echo " start: Start/initialize a container" - echo " stop: Stop a running container" - echo " restart: Restart a container" - echo " destroy: Stop and remove a container" - echo " shell: start a bash shell in a running container" - echo " logs: Docker logs for container" + echo " start: Start/initialize a container" + echo " stop: Stop a running container" + echo " restart: Restart a container" + echo " destroy: Stop and remove a container" + echo " shell: Start a bash shell in a running container" + echo " logs: Docker logs for container" + echo " bootstrap: Bootstrap a container for the config base on an image" exit 1 } @@ -25,6 +27,14 @@ if [ ! -e $config_file ] exit 1 fi +if [ "$command" == "bootstrap" ] + then + docker run -cidfile $cidbootstrap -i -t -v `pwd`/shared:/shared samsaffron/discourse /shared/pups/bin/pups /$config_file + docker commit `cat $cidbootstrap` samsaffron/discourse $config + docker rm `cat $cidbootstrap` + rm $cidbootstrap +fi + if [ "$command" == "shell" ] then @@ -70,7 +80,7 @@ if [ "$command" == "start" ] if [ ! -e $cidfile ] then echo "No cid found, creating a new container" - docker run -cidfile $cidfile -p 22 -p 3000 -d -v `pwd`/shared:/shared samsaffron/discourse /shared/pups/bin/pups /$config_file + docker run -cidfile $cidfile -p 22 -p 3000 -d -v `pwd`/shared:/shared samsaffron/discourse:$config /usr/bin/runsvdir -P /etc/service exit 0 else echo "cid found, ensuring container is started"