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