Chris@1570: Chris@1570: # For documentation and experimental purposes only. As a Chris@1570: # reconstruction of the machine image that runs this application, Chris@1573: # there are lots of things missing here; but as a good Docker Chris@1573: # configuration, it fails by mixing together rather a lot of concerns. Chris@1570: Chris@1569: FROM ubuntu:16.04 Chris@1569: MAINTAINER Chris Cannam Chris@1570: Chris@1569: RUN apt-get update && \ Chris@1569: apt-get install -y \ Chris@1570: apache2 \ Chris@1570: apache2-dev \ Chris@1570: apt-utils \ Chris@1569: build-essential \ Chris@1570: cron \ Chris@1570: curl \ Chris@1570: doxygen \ Chris@1570: exim4 \ Chris@1570: git \ Chris@1570: graphviz \ Chris@1570: imagemagick \ Chris@1570: libapache-dbi-perl \ Chris@1570: libapache2-mod-perl2 \ Chris@1570: libapr1-dev \ Chris@1570: libaprutil1-dev \ Chris@1570: libauthen-simple-ldap-perl \ Chris@1570: libcurl4-openssl-dev \ Chris@1570: libdbd-pg-perl \ Chris@1570: libpq-dev \ Chris@1570: libmagickwand-dev \ Chris@1570: libio-socket-ssl-perl \ Chris@1570: logrotate \ Chris@1570: mercurial \ Chris@1570: postgresql \ Chris@1570: rsync \ Chris@1570: ruby \ Chris@1570: ruby-dev \ Chris@1572: sudo Chris@1572: Chris@1573: # Also used on the live site, for javadoc extraction, but this is Chris@1573: # would be by far the biggest package here: let's omit it while we're Chris@1573: # not making use of it Chris@1573: # openjdk-9-jdk-headless Chris@1573: Chris@1572: RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* Chris@1570: Chris@1570: Chris@1570: # Passenger gets installed through gem, not apt Chris@1570: Chris@1570: RUN gem install passenger -v 4.0.60 --no-rdoc --no-ri Chris@1570: RUN passenger-install-apache2-module --languages=ruby Chris@1570: Chris@1570: Chris@1570: # Copy across webapp, set up ownership Chris@1570: Chris@1570: COPY . /var/www/code Chris@1570: Chris@1569: RUN groupadd code Chris@1569: RUN useradd -g code -G www-data code Chris@1569: RUN chown -R code.www-data /var/www/code Chris@1570: RUN find /var/www/code -type d -exec chmod g+s \{\} \; Chris@1570: Chris@1570: Chris@1576: # Initialise /var/hg (in reality this would be mounted from somewhere) Chris@1576: Chris@1576: RUN mkdir -p /var/hg Chris@1576: RUN chown code.www-data /var/hg Chris@1576: RUN chmod g+s /var/hg Chris@1576: COPY extra/soundsoftware/dockertest/index.cgi /var/hg/ Chris@1576: COPY extra/soundsoftware/dockertest/hgweb.config /var/hg/ Chris@1576: RUN chmod +x /var/hg/index.cgi Chris@1576: Chris@1576: Chris@1570: # We're based in the code webapp directory from here on Chris@1570: Chris@1569: WORKDIR /var/www/code Chris@1570: Chris@1570: Chris@1574: # Set up database config etc Chris@1570: Chris@1574: RUN cp extra/soundsoftware/dockertest/database.yml.interpolated config/database.yml Chris@1570: Chris@1570: Chris@1573: # Install Rails and dependencies (database.yml must be populated before this) Chris@1570: Chris@1569: RUN gem install bundler Chris@1569: RUN bundle install Chris@1570: Chris@1570: Chris@1573: # Initialise Redmine token (bundler must be installed before this) Chris@1573: Chris@1573: RUN bundle exec rake generate_secret_token Chris@1573: Chris@1573: Chris@1570: # Import Postgres database from postgres-dumpall file Chris@1570: Chris@1569: RUN chown postgres postgres-dumpall Chris@1571: RUN /etc/init.d/postgresql start && sudo -u postgres psql -f postgres-dumpall postgres Chris@1570: Chris@1570: Chris@1570: # Install Perl auth module for Hg access Chris@1570: Chris@1570: RUN mkdir -p /usr/local/lib/site_perl/Apache/Authn/ Chris@1570: RUN cp extra/soundsoftware/SoundSoftware.pm /usr/local/lib/site_perl/Apache/Authn/ Chris@1570: Chris@1570: Chris@1571: # Set up Apache config (todo: insert variables) Chris@1570: Chris@1571: RUN rm -f /etc/apache2/sites-enabled/000-default.conf Chris@1571: Chris@1571: RUN cp extra/soundsoftware/dockertest/passenger.conf /etc/apache2/mods-available/ Chris@1571: RUN cp extra/soundsoftware/dockertest/passenger.load /etc/apache2/mods-available/ Chris@1571: RUN cp extra/soundsoftware/dockertest/perl.conf /etc/apache2/mods-available/ Chris@1571: Chris@1571: RUN ln -s ../mods-available/passenger.conf /etc/apache2/mods-enabled/ Chris@1571: RUN ln -s ../mods-available/passenger.load /etc/apache2/mods-enabled/ Chris@1571: RUN ln -s ../mods-available/perl.conf /etc/apache2/mods-enabled/ Chris@1571: RUN ln -s ../mods-available/expires.load /etc/apache2/mods-enabled/ Chris@1571: RUN ln -s ../mods-available/rewrite.load /etc/apache2/mods-enabled/ Chris@1578: RUN ln -s ../mods-available/cgi.load /etc/apache2/mods-enabled/ Chris@1571: Chris@1574: RUN cp extra/soundsoftware/dockertest/code.conf.interpolated /etc/apache2/sites-available/code.conf Chris@1570: RUN ln -s ../sites-available/code.conf /etc/apache2/sites-enabled/10-code.conf Chris@1571: Chris@1572: RUN apache2ctl configtest Chris@1571: Chris@1571: Chris@1572: # Start Postgres and foregrounded Apache Chris@1572: Chris@1572: RUN echo "#!/bin/bash" > container-run.sh Chris@1572: RUN echo "/etc/init.d/postgresql start" >> container-run.sh Chris@1572: RUN echo "apache2ctl -D FOREGROUND" >> container-run.sh Chris@1572: RUN chmod +x container-run.sh Chris@1572: Chris@1571: EXPOSE 80 Chris@1572: CMD ./container-run.sh Chris@1571: