From: Michael Brown Date: Thu, 14 Nov 2013 08:16:21 +0000 (+0000) Subject: Fix errors in Dockerfile and launcher X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b86ac1af11ffcae1fc719433f42c6bc0f5db2271;p=discourse_docker.git Fix errors in Dockerfile and launcher --- diff --git a/image/Dockerfile b/image/Dockerfile index 93d1ace..9fbcc91 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -20,34 +20,37 @@ RUN apt-get -y update &&\ pngcrush imagemagick \ postgresql-9.2 postgresql-client-9.2 \ postgresql-contrib-9.2 libpq-dev libreadline-dev \ - nginx wget language-pack-en sudo &&\ + nginx wget language-pack-en sudo cron &&\ dpkg-divert --local --rename --add /sbin/initctl &&\ ln -s /bin/true /sbin/initctl &&\ apt-get install -y redis-server haproxy openssh-server &&\ - echo 'install: --no-ri --no-rdoc' >> ~/.gemrc - (mkdir /src && cd /src &&\ - git clone https://github.com/sstephenson/ruby-build.git) &&\ - (cd /src/ruby-build && ./install.sh) &&\ + echo 'install: --no-ri --no-rdoc' >> ~/.gemrc &&\ + mkdir /src && cd /src &&\ + git clone https://github.com/sstephenson/ruby-build.git && cd / &&\ + cd /src/ruby-build &&\ + ./install.sh && cd / &&\ rm -rf /src/ruby-build &&\ ruby-build 2.0.0-p247 /usr/local &&\ gem update --system &&\ - gem install bundler &&\ + gem install bundler --pre &&\ useradd discourse &&\ - (mkdir /var/www && cd /var/www &&\ + mkdir /var/www && cd /var/www &&\ git clone https://github.com/discourse/discourse.git &&\ - chown -R discourse:discourse /var/www/discourse) &&\ - (cd /var/www/discourse &&\ - sudo -u discourse RAILS4=1 bundle install --deployment \ - --without test --without development) &&\ - (cd /var/www/discourse/vendor/bundle &&\ - find . -name tmp -type d | xargs rm -rf) &&\ + chown -R discourse:discourse /var/www/discourse && cd / &&\ + cd /var/www/discourse &&\ + sudo -u discourse RAILS4=1 bundle install -j8 --deployment \ + --without test --without development && cd / &&\ + cd /var/www/discourse/vendor/bundle &&\ + find . -name tmp -type d | xargs rm -rf && cd / &&\ apt-get install -y runit &&\ locale-gen en_US &&\ - apt-get -y autoremove build-essential gcc gcc-4.7 .+-dev &&\ apt-get clean +# For a smaller but less flexible image: +# RUN apt-get -y autoremove build-essential gcc gcc-4.7 .+-dev + RUN apt-get install psmisc &&\ - (cd / && git clone https://github.com/SamSaffron/pups.git) &&\ + cd / && git clone https://github.com/SamSaffron/pups.git &&\ apt-get clean RUN echo image size: $(du -hsx /) diff --git a/launcher b/launcher index 5a70a0e..8708d3d 100755 --- a/launcher +++ b/launcher @@ -40,7 +40,7 @@ install_docker() { } set_volumes() { - volumes=`cat $config_file | docker run -rm -i -a stdout -a stdin samsaffron/discourse ruby -e \ + volumes=`cat $config_file | docker run -rm -i -a stdout -a stdin $image ruby -e \ "require 'yaml'; puts YAML.load(STDIN.readlines.join)['volumes'].map{|v| '-v ' << v['volume']['host'] << ':' << v['volume']['guest'] << ' '}.join"` } @@ -62,7 +62,7 @@ fi case "$command" in bootstrap) - template=`cat $config_file | docker run -rm -i -a stdin -a stdout samsaffron/discourse ruby -e \ + template=`cat $config_file | docker run -rm -i -a stdin -a stdout $image ruby -e \ "require 'yaml'; puts YAML.load(STDIN.readlines.join)['template']"` input=$(cat $config_file) @@ -72,9 +72,9 @@ case "$command" in set_volumes - exec echo "$input" | docker run -cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes samsaffron/discourse /pups/bin/pups --stdin + exec echo "$input" | docker run -cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes $image /pups/bin/pups --stdin sleep 5 - docker commit `cat $cidbootstrap` samsaffron/discourse $config + docker commit `cat $cidbootstrap` $image $config docker rm `cat $cidbootstrap` && rm $cidbootstrap exit 0 ;; @@ -120,12 +120,12 @@ case "$command" in if [ ! -e $cidfile ] then echo "No cid found, creating a new container" - ports=`cat $config_file | docker run -rm -i -a stdout -a stdin samsaffron/discourse ruby -e \ + ports=`cat $config_file | docker run -rm -i -a stdout -a stdin $image ruby -e \ "require 'yaml'; puts YAML.load(STDIN.readlines.join)['expose'].map{|p| '-p ' << p.to_s << ' '}.join"` set_volumes - docker run -name $config -cidfile $cidfile $ports -d $volumes samsaffron/discourse:$config /usr/bin/runsvdir -P /etc/service + docker run -name $config -cidfile $cidfile $ports -d $volumes $image:$config /usr/bin/runsvdir -P /etc/service exit 0 else echo "cid found, ensuring container is started"