From f868baa5695acbc446a993492e05186ff6477836 Mon Sep 17 00:00:00 2001 From: Dashamir Hoxha Date: Thu, 25 Sep 2014 09:35:01 +0200 Subject: [PATCH] Building a docker image. --- Dockerfile | 21 +++++++++++++++++++++ README.org | 17 +++++++++++++++++ install/install-and-config.sh | 6 ++---- install/scripts/packages-and-software.sh | 14 ++++++-------- 4 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..76e2bed --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +### This file can be used to build a docker image like this: +### docker build --tag='btr_server' . +### It can also be used for automated builds in Docker Hub +### (see https://docs.docker.com/userguide/dockerrepos/#automated-builds) + +FROM ubuntu:14.04 + +### Install packages first, in order to take advantage +### of caching features of `docker build`. +COPY install/scripts/packages-and-software.sh /tmp/ +RUN DEBIAN_FRONTEND=noninteractive /tmp/packages-and-software.sh + +### Copy the source code and run the installer. +COPY . /usr/local/src/btr_server/ +ENV code_dir /usr/local/src/btr_server +WORKDIR /usr/local/src/btr_server/ +RUN ["install/install-container.sh", "install/settings.sh"] + +### Set the default command to run in the container. +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf", "--nodaemon"] + diff --git a/README.org b/README.org index 70a006d..26e909c 100644 --- a/README.org +++ b/README.org @@ -32,6 +32,7 @@ This is a Drupal installation profile for B-Translator Server. /etc/init.d/chroot-btr stop #+END_EXAMPLE + * Installation in a docker container This is almost the same as the installation above, except that @@ -46,6 +47,22 @@ This is a Drupal installation profile for B-Translator Server. docker.io stop btr #+END_EXAMPLE + Compared to the installation with chroot, docker has the advantage + that it is platform independent (the host system does not have to be + Ubuntu or Debian). + + +* Building with docker + + Another way is to use the command =docker build= to build an image + and then =docker run= to create a container from this image: + #+BEGIN_EXAMPLE + vim btr_server/install/settings.sh + docker.io build --tag=btr_server btr_server/ + docker.io run -d --name=btr --hostname=btr.example.org \ + -p 80:80 -p 443:443 btr_server + #+END_EXAMPLE + * What is B-Translator diff --git a/install/install-and-config.sh b/install/install-and-config.sh index 000f3f9..8aed8a3 100755 --- a/install/install-and-config.sh +++ b/install/install-and-config.sh @@ -5,10 +5,6 @@ sed -i /etc/hosts \ -e "/^127.0.0.1/c 127.0.0.1 btr.example.org localhost" hostname btr.example.org -### export drupal_dir -export drupal_dir=/var/www/btr -export drush="drush --root=$drupal_dir" - ### go to the directory of scripts cd $code_dir/install/scripts/ @@ -16,6 +12,8 @@ cd $code_dir/install/scripts/ ./packages-and-software.sh ### make and install the drupal profile 'btr_server' +export drupal_dir=/var/www/btr +export drush="drush --root=$drupal_dir" ./drupal-make-and-install.sh ### move translation tables on their own database diff --git a/install/scripts/packages-and-software.sh b/install/scripts/packages-and-software.sh index e4559ba..db20053 100755 --- a/install/scripts/packages-and-software.sh +++ b/install/scripts/packages-and-software.sh @@ -4,19 +4,17 @@ apt-get update apt-get -y upgrade -install='apt-get -y -o DPkg::Options::=--force-confdef -o DPkg::Options::=--force-confold install' - ### install localization -$install language-pack-en +apt-get -y install language-pack-en update-locale ### install other needed packages -$install aptitude tasksel vim nano psmisc cron supervisor -$install mysql-server ssmtp memcached php5-memcached \ +apt-get -y install aptitude tasksel vim nano psmisc cron supervisor +apt-get -y install mysql-server ssmtp memcached php5-memcached \ php5-mysql php5-gd php-db php5-dev php-pear php5-curl php-apc \ make ssl-cert gawk unzip wget curl diffutils phpmyadmin git ruby \ mercurial subversion translate-toolkit dtrx -$install screen logwatch +apt-get -y install screen logwatch initctl reload-configuration ### install hub: http://hub.github.com/ @@ -25,7 +23,7 @@ chmod +x /bin/hub ### install twitter cli client ### see also: http://xmodulo.com/2013/12/access-twitter-command-line-linux.html -$install ruby-dev +apt-get -y install ruby-dev gem install t ### phpmyadmin will install apache2 and start it @@ -34,7 +32,7 @@ gem install t update-rc.d apache2 disable ### install nginx and php5-fpm -$install nginx nginx-common nginx-full php5-fpm +apt-get -y install nginx nginx-common nginx-full php5-fpm ### There is some problem with php-pear in 14.04 ### See: http://askubuntu.com/questions/451953/php-pear-is-not-working-after-upgrading-to-ubuntu-14-04