annotate extra/soundsoftware/dockertest/Dockerfile @ 1572:2b1b8ebb7d98 dockerise

This now sort-of works, apart from not knowing the db password
author Chris Cannam
date Thu, 03 Aug 2017 17:24:49 +0100
parents 4c2b25b7e85f
children 8edb54e29f00
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@1570 4 # there are lots of things missing here; meanwhile as a good Docker
Chris@1570 5 # configuration, it fails in 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@1569 35 openjdk-9-jdk-headless \
Chris@1570 36 postgresql \
Chris@1570 37 rsync \
Chris@1570 38 ruby \
Chris@1570 39 ruby-dev \
Chris@1572 40 sudo
Chris@1572 41
Chris@1572 42 RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Chris@1570 43
Chris@1570 44
Chris@1570 45 # Passenger gets installed through gem, not apt
Chris@1570 46
Chris@1570 47 RUN gem install passenger -v 4.0.60 --no-rdoc --no-ri
Chris@1570 48 RUN passenger-install-apache2-module --languages=ruby
Chris@1570 49
Chris@1570 50
Chris@1570 51 # Copy across webapp, set up ownership
Chris@1570 52
Chris@1570 53 COPY . /var/www/code
Chris@1570 54
Chris@1569 55 RUN groupadd code
Chris@1569 56 RUN useradd -g code -G www-data code
Chris@1569 57 RUN chown -R code.www-data /var/www/code
Chris@1570 58 RUN find /var/www/code -type d -exec chmod g+s \{\} \;
Chris@1570 59
Chris@1570 60
Chris@1570 61 # We're based in the code webapp directory from here on
Chris@1570 62
Chris@1569 63 WORKDIR /var/www/code
Chris@1570 64
Chris@1570 65
Chris@1572 66 # Set up database config etc (todo: insert variables)
Chris@1570 67
Chris@1570 68 RUN cp extra/soundsoftware/dockertest/database.yml config/database.yml
Chris@1572 69 RUN bundle exec rake generate_secret_token
Chris@1570 70
Chris@1570 71
Chris@1570 72 # Install Rails dependencies (database.yml must be populated before this)
Chris@1570 73
Chris@1569 74 RUN gem install bundler
Chris@1569 75 RUN bundle install
Chris@1570 76
Chris@1570 77
Chris@1570 78 # Import Postgres database from postgres-dumpall file
Chris@1570 79
Chris@1569 80 RUN chown postgres postgres-dumpall
Chris@1571 81 RUN /etc/init.d/postgresql start && sudo -u postgres psql -f postgres-dumpall postgres
Chris@1570 82
Chris@1570 83
Chris@1570 84 # Install Perl auth module for Hg access
Chris@1570 85
Chris@1570 86 RUN mkdir -p /usr/local/lib/site_perl/Apache/Authn/
Chris@1570 87 RUN cp extra/soundsoftware/SoundSoftware.pm /usr/local/lib/site_perl/Apache/Authn/
Chris@1570 88
Chris@1570 89
Chris@1571 90 # Set up Apache config (todo: insert variables)
Chris@1570 91
Chris@1571 92 RUN rm -f /etc/apache2/sites-enabled/000-default.conf
Chris@1571 93
Chris@1571 94 RUN cp extra/soundsoftware/dockertest/passenger.conf /etc/apache2/mods-available/
Chris@1571 95 RUN cp extra/soundsoftware/dockertest/passenger.load /etc/apache2/mods-available/
Chris@1571 96 RUN cp extra/soundsoftware/dockertest/perl.conf /etc/apache2/mods-available/
Chris@1571 97
Chris@1571 98 RUN ln -s ../mods-available/passenger.conf /etc/apache2/mods-enabled/
Chris@1571 99 RUN ln -s ../mods-available/passenger.load /etc/apache2/mods-enabled/
Chris@1571 100 RUN ln -s ../mods-available/perl.conf /etc/apache2/mods-enabled/
Chris@1571 101 RUN ln -s ../mods-available/expires.load /etc/apache2/mods-enabled/
Chris@1571 102 RUN ln -s ../mods-available/rewrite.load /etc/apache2/mods-enabled/
Chris@1571 103
Chris@1571 104 RUN cp extra/soundsoftware/dockertest/code.conf /etc/apache2/sites-available/
Chris@1570 105 RUN ln -s ../sites-available/code.conf /etc/apache2/sites-enabled/10-code.conf
Chris@1571 106
Chris@1572 107 RUN apache2ctl configtest
Chris@1571 108
Chris@1571 109
Chris@1572 110 # Start Postgres and foregrounded Apache
Chris@1572 111
Chris@1572 112 RUN echo "#!/bin/bash" > container-run.sh
Chris@1572 113 RUN echo "/etc/init.d/postgresql start" >> container-run.sh
Chris@1572 114 RUN echo "apache2ctl -D FOREGROUND" >> container-run.sh
Chris@1572 115 RUN chmod +x container-run.sh
Chris@1572 116
Chris@1571 117 EXPOSE 80
Chris@1572 118 CMD ./container-run.sh
Chris@1571 119