annotate deploy/docker/Dockerfile.inline @ 1628:9c5f8e24dadc live tip

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