annotate extra/soundsoftware/dockertest/Dockerfile @ 1573:8edb54e29f00 dockerise

Minor tweaks
author Chris Cannam
date Thu, 03 Aug 2017 20:20:18 +0100
parents 2b1b8ebb7d98
children 7b23adecd963
rev   line source
Chris@1570 1
Chris@1570 2 # For documentation and experimental purposes only. As a
Chris@1570 3 # reconstruction of the machine image that runs this application,
Chris@1573 4 # there are lots of things missing here; but as a good Docker
Chris@1573 5 # configuration, it fails by mixing together rather a lot of concerns.
Chris@1570 6
Chris@1569 7 FROM ubuntu:16.04
Chris@1569 8 MAINTAINER Chris Cannam <cannam@all-day-breakfast.com>
Chris@1570 9
Chris@1569 10 RUN apt-get update && \
Chris@1569 11 apt-get install -y \
Chris@1570 12 apache2 \
Chris@1570 13 apache2-dev \
Chris@1570 14 apt-utils \
Chris@1569 15 build-essential \
Chris@1570 16 cron \
Chris@1570 17 curl \
Chris@1570 18 doxygen \
Chris@1570 19 exim4 \
Chris@1570 20 git \
Chris@1570 21 graphviz \
Chris@1570 22 imagemagick \
Chris@1570 23 libapache-dbi-perl \
Chris@1570 24 libapache2-mod-perl2 \
Chris@1570 25 libapr1-dev \
Chris@1570 26 libaprutil1-dev \
Chris@1570 27 libauthen-simple-ldap-perl \
Chris@1570 28 libcurl4-openssl-dev \
Chris@1570 29 libdbd-pg-perl \
Chris@1570 30 libpq-dev \
Chris@1570 31 libmagickwand-dev \
Chris@1570 32 libio-socket-ssl-perl \
Chris@1570 33 logrotate \
Chris@1570 34 mercurial \
Chris@1570 35 postgresql \
Chris@1570 36 rsync \
Chris@1570 37 ruby \
Chris@1570 38 ruby-dev \
Chris@1572 39 sudo
Chris@1572 40
Chris@1573 41 # Also used on the live site, for javadoc extraction, but this is
Chris@1573 42 # would be by far the biggest package here: let's omit it while we're
Chris@1573 43 # not making use of it
Chris@1573 44 # openjdk-9-jdk-headless
Chris@1573 45
Chris@1572 46 RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Chris@1570 47
Chris@1570 48
Chris@1570 49 # Passenger gets installed through gem, not apt
Chris@1570 50
Chris@1570 51 RUN gem install passenger -v 4.0.60 --no-rdoc --no-ri
Chris@1570 52 RUN passenger-install-apache2-module --languages=ruby
Chris@1570 53
Chris@1570 54
Chris@1570 55 # Copy across webapp, set up ownership
Chris@1570 56
Chris@1570 57 COPY . /var/www/code
Chris@1570 58
Chris@1569 59 RUN groupadd code
Chris@1569 60 RUN useradd -g code -G www-data code
Chris@1569 61 RUN chown -R code.www-data /var/www/code
Chris@1570 62 RUN find /var/www/code -type d -exec chmod g+s \{\} \;
Chris@1570 63
Chris@1570 64
Chris@1570 65 # We're based in the code webapp directory from here on
Chris@1570 66
Chris@1569 67 WORKDIR /var/www/code
Chris@1570 68
Chris@1570 69
Chris@1572 70 # Set up database config etc (todo: insert variables)
Chris@1570 71
Chris@1570 72 RUN cp extra/soundsoftware/dockertest/database.yml config/database.yml
Chris@1570 73
Chris@1570 74
Chris@1573 75 # Install Rails and dependencies (database.yml must be populated before this)
Chris@1570 76
Chris@1569 77 RUN gem install bundler
Chris@1569 78 RUN bundle install
Chris@1570 79
Chris@1570 80
Chris@1573 81 # Initialise Redmine token (bundler must be installed before this)
Chris@1573 82
Chris@1573 83 RUN bundle exec rake generate_secret_token
Chris@1573 84
Chris@1573 85
Chris@1570 86 # Import Postgres database from postgres-dumpall file
Chris@1570 87
Chris@1569 88 RUN chown postgres postgres-dumpall
Chris@1571 89 RUN /etc/init.d/postgresql start && sudo -u postgres psql -f postgres-dumpall postgres
Chris@1570 90
Chris@1570 91
Chris@1570 92 # Install Perl auth module for Hg access
Chris@1570 93
Chris@1570 94 RUN mkdir -p /usr/local/lib/site_perl/Apache/Authn/
Chris@1570 95 RUN cp extra/soundsoftware/SoundSoftware.pm /usr/local/lib/site_perl/Apache/Authn/
Chris@1570 96
Chris@1570 97
Chris@1571 98 # Set up Apache config (todo: insert variables)
Chris@1570 99
Chris@1571 100 RUN rm -f /etc/apache2/sites-enabled/000-default.conf
Chris@1571 101
Chris@1571 102 RUN cp extra/soundsoftware/dockertest/passenger.conf /etc/apache2/mods-available/
Chris@1571 103 RUN cp extra/soundsoftware/dockertest/passenger.load /etc/apache2/mods-available/
Chris@1571 104 RUN cp extra/soundsoftware/dockertest/perl.conf /etc/apache2/mods-available/
Chris@1571 105
Chris@1571 106 RUN ln -s ../mods-available/passenger.conf /etc/apache2/mods-enabled/
Chris@1571 107 RUN ln -s ../mods-available/passenger.load /etc/apache2/mods-enabled/
Chris@1571 108 RUN ln -s ../mods-available/perl.conf /etc/apache2/mods-enabled/
Chris@1571 109 RUN ln -s ../mods-available/expires.load /etc/apache2/mods-enabled/
Chris@1571 110 RUN ln -s ../mods-available/rewrite.load /etc/apache2/mods-enabled/
Chris@1571 111
Chris@1571 112 RUN cp extra/soundsoftware/dockertest/code.conf /etc/apache2/sites-available/
Chris@1570 113 RUN ln -s ../sites-available/code.conf /etc/apache2/sites-enabled/10-code.conf
Chris@1571 114
Chris@1572 115 RUN apache2ctl configtest
Chris@1571 116
Chris@1571 117
Chris@1572 118 # Start Postgres and foregrounded Apache
Chris@1572 119
Chris@1572 120 RUN echo "#!/bin/bash" > container-run.sh
Chris@1572 121 RUN echo "/etc/init.d/postgresql start" >> container-run.sh
Chris@1572 122 RUN echo "apache2ctl -D FOREGROUND" >> container-run.sh
Chris@1572 123 RUN chmod +x container-run.sh
Chris@1572 124
Chris@1571 125 EXPOSE 80
Chris@1572 126 CMD ./container-run.sh
Chris@1571 127