annotate extra/soundsoftware/dockertest/Dockerfile @ 1576:d1de6986e429 dockerise

Scripts to run the Hg repos
author Chris Cannam
date Fri, 04 Aug 2017 11:24:54 +0100
parents 7b23adecd963
children 06ca2df3d7ca
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@1576 65 # Initialise /var/hg (in reality this would be mounted from somewhere)
Chris@1576 66
Chris@1576 67 RUN mkdir -p /var/hg
Chris@1576 68 RUN chown code.www-data /var/hg
Chris@1576 69 RUN chmod g+s /var/hg
Chris@1576 70 COPY extra/soundsoftware/dockertest/index.cgi /var/hg/
Chris@1576 71 COPY extra/soundsoftware/dockertest/hgweb.config /var/hg/
Chris@1576 72 RUN chmod +x /var/hg/index.cgi
Chris@1576 73
Chris@1576 74
Chris@1570 75 # We're based in the code webapp directory from here on
Chris@1570 76
Chris@1569 77 WORKDIR /var/www/code
Chris@1570 78
Chris@1570 79
Chris@1574 80 # Set up database config etc
Chris@1570 81
Chris@1574 82 RUN cp extra/soundsoftware/dockertest/database.yml.interpolated config/database.yml
Chris@1570 83
Chris@1570 84
Chris@1573 85 # Install Rails and dependencies (database.yml must be populated before this)
Chris@1570 86
Chris@1569 87 RUN gem install bundler
Chris@1569 88 RUN bundle install
Chris@1570 89
Chris@1570 90
Chris@1573 91 # Initialise Redmine token (bundler must be installed before this)
Chris@1573 92
Chris@1573 93 RUN bundle exec rake generate_secret_token
Chris@1573 94
Chris@1573 95
Chris@1570 96 # Import Postgres database from postgres-dumpall file
Chris@1570 97
Chris@1569 98 RUN chown postgres postgres-dumpall
Chris@1571 99 RUN /etc/init.d/postgresql start && sudo -u postgres psql -f postgres-dumpall postgres
Chris@1570 100
Chris@1570 101
Chris@1570 102 # Install Perl auth module for Hg access
Chris@1570 103
Chris@1570 104 RUN mkdir -p /usr/local/lib/site_perl/Apache/Authn/
Chris@1570 105 RUN cp extra/soundsoftware/SoundSoftware.pm /usr/local/lib/site_perl/Apache/Authn/
Chris@1570 106
Chris@1570 107
Chris@1571 108 # Set up Apache config (todo: insert variables)
Chris@1570 109
Chris@1571 110 RUN rm -f /etc/apache2/sites-enabled/000-default.conf
Chris@1571 111
Chris@1571 112 RUN cp extra/soundsoftware/dockertest/passenger.conf /etc/apache2/mods-available/
Chris@1571 113 RUN cp extra/soundsoftware/dockertest/passenger.load /etc/apache2/mods-available/
Chris@1571 114 RUN cp extra/soundsoftware/dockertest/perl.conf /etc/apache2/mods-available/
Chris@1571 115
Chris@1571 116 RUN ln -s ../mods-available/passenger.conf /etc/apache2/mods-enabled/
Chris@1571 117 RUN ln -s ../mods-available/passenger.load /etc/apache2/mods-enabled/
Chris@1571 118 RUN ln -s ../mods-available/perl.conf /etc/apache2/mods-enabled/
Chris@1571 119 RUN ln -s ../mods-available/expires.load /etc/apache2/mods-enabled/
Chris@1571 120 RUN ln -s ../mods-available/rewrite.load /etc/apache2/mods-enabled/
Chris@1571 121
Chris@1574 122 RUN cp extra/soundsoftware/dockertest/code.conf.interpolated /etc/apache2/sites-available/code.conf
Chris@1570 123 RUN ln -s ../sites-available/code.conf /etc/apache2/sites-enabled/10-code.conf
Chris@1571 124
Chris@1572 125 RUN apache2ctl configtest
Chris@1571 126
Chris@1571 127
Chris@1572 128 # Start Postgres and foregrounded Apache
Chris@1572 129
Chris@1572 130 RUN echo "#!/bin/bash" > container-run.sh
Chris@1572 131 RUN echo "/etc/init.d/postgresql start" >> container-run.sh
Chris@1572 132 RUN echo "apache2ctl -D FOREGROUND" >> container-run.sh
Chris@1572 133 RUN chmod +x container-run.sh
Chris@1572 134
Chris@1571 135 EXPOSE 80
Chris@1572 136 CMD ./container-run.sh
Chris@1571 137