To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / extra / soundsoftware / dockertest @ 1571:4c2b25b7e85f

1 1570:ae2f71010562 Chris
2
# For documentation and experimental purposes only. As a
3
# reconstruction of the machine image that runs this application,
4
# there are lots of things missing here; meanwhile as a good Docker
5
# configuration, it fails in mixing together rather a lot of concerns.
6
7 1569:26a4f99ec679 Chris
FROM ubuntu:16.04
8
MAINTAINER Chris Cannam <cannam@all-day-breakfast.com>
9 1570:ae2f71010562 Chris
10 1569:26a4f99ec679 Chris
RUN apt-get update && \
11
    apt-get install -y \
12 1570:ae2f71010562 Chris
    apache2 \
13
    apache2-dev \
14
    apt-utils \
15 1569:26a4f99ec679 Chris
    build-essential \
16 1570:ae2f71010562 Chris
    cron \
17
    curl \
18
    doxygen \
19
    exim4 \
20
    git \
21
    graphviz \
22
    imagemagick \
23
    libapache-dbi-perl \
24
    libapache2-mod-perl2 \
25
    libapr1-dev \
26
    libaprutil1-dev \
27
    libauthen-simple-ldap-perl \
28
    libcurl4-openssl-dev \
29
    libdbd-pg-perl \
30
    libpq-dev \
31
    libmagickwand-dev \
32
    libio-socket-ssl-perl \
33
    logrotate \
34
    mercurial \
35 1569:26a4f99ec679 Chris
    openjdk-9-jdk-headless \
36 1570:ae2f71010562 Chris
    postgresql \
37
    rsync \
38
    ruby \
39
    ruby-dev \
40
    sudo \
41
    supervisor
42
43
44
# Passenger gets installed through gem, not apt
45
46
RUN gem install passenger -v 4.0.60 --no-rdoc --no-ri
47
RUN passenger-install-apache2-module --languages=ruby
48
49
50
# Copy across webapp, set up ownership
51
52
COPY . /var/www/code
53
54 1569:26a4f99ec679 Chris
RUN groupadd code
55
RUN useradd -g code -G www-data code
56
RUN chown -R code.www-data /var/www/code
57 1570:ae2f71010562 Chris
RUN find /var/www/code -type d -exec chmod g+s \{\} \;
58
59
60
# We're based in the code webapp directory from here on
61
62 1569:26a4f99ec679 Chris
WORKDIR /var/www/code
63 1570:ae2f71010562 Chris
64
65 1571:4c2b25b7e85f Chris
# Set up database config (todo: insert variables)
66 1570:ae2f71010562 Chris
67
RUN cp extra/soundsoftware/dockertest/database.yml config/database.yml
68
69
70
# Install Rails dependencies (database.yml must be populated before this)
71
72 1569:26a4f99ec679 Chris
RUN gem install bundler
73
RUN bundle install
74 1570:ae2f71010562 Chris
75
76
# Import Postgres database from postgres-dumpall file
77
78 1569:26a4f99ec679 Chris
RUN chown postgres postgres-dumpall
79 1571:4c2b25b7e85f Chris
RUN /etc/init.d/postgresql start && sudo -u postgres psql -f postgres-dumpall postgres
80 1570:ae2f71010562 Chris
81
82
# Install Perl auth module for Hg access
83
84
RUN mkdir -p /usr/local/lib/site_perl/Apache/Authn/
85
RUN cp extra/soundsoftware/SoundSoftware.pm /usr/local/lib/site_perl/Apache/Authn/
86
87
88 1571:4c2b25b7e85f Chris
# Set up Apache config (todo: insert variables)
89 1570:ae2f71010562 Chris
90 1571:4c2b25b7e85f Chris
RUN rm -f /etc/apache2/sites-enabled/000-default.conf
91
92
RUN cp extra/soundsoftware/dockertest/passenger.conf /etc/apache2/mods-available/
93
RUN cp extra/soundsoftware/dockertest/passenger.load /etc/apache2/mods-available/
94
RUN cp extra/soundsoftware/dockertest/perl.conf      /etc/apache2/mods-available/
95
96
RUN ln -s ../mods-available/passenger.conf  /etc/apache2/mods-enabled/
97
RUN ln -s ../mods-available/passenger.load  /etc/apache2/mods-enabled/
98
RUN ln -s ../mods-available/perl.conf       /etc/apache2/mods-enabled/
99
RUN ln -s ../mods-available/expires.load    /etc/apache2/mods-enabled/
100
RUN ln -s ../mods-available/rewrite.load    /etc/apache2/mods-enabled/
101
102
RUN cp extra/soundsoftware/dockertest/code.conf /etc/apache2/sites-available/
103 1570:ae2f71010562 Chris
RUN ln -s ../sites-available/code.conf /etc/apache2/sites-enabled/10-code.conf
104 1571:4c2b25b7e85f Chris
105
106
# Start Apache
107
108 1570:ae2f71010562 Chris
RUN apache2ctl configtest
109 1571:4c2b25b7e85f Chris
EXPOSE 80
110
CMD apache2ctl -D FOREGROUND
111
112 1570:ae2f71010562 Chris
113
# A test Apache config. Lacks SSL, lacks a desirable extra layer of
114
# authentication for admin interface paths. Do not deploy this.
115
116
PerlLoadModule Apache::Authn::SoundSoftware
117
118
<VirtualHost *:80>
119
        ServerName code.soundsoftware.ac.uk
120
        ServerAdmin chris.cannam@soundsoftware.ac.uk
121
122
        DocumentRoot /var/www/code/public
123
        PassengerRestartDir restart_files
124
        PassengerHighPerformance on
125
        PassengerMaxRequests 50000
126
        PassengerStatThrottleRate 5
127
	PassengerStartTimeout 60
128 1571:4c2b25b7e85f Chris
	PassengerFriendlyErrorPages on
129 1570:ae2f71010562 Chris
        RailsSpawnMethod smart
130
        ExpiresDefault "access plus 1 minute"
131
132
        <DirectoryMatch "^/.*/\.svn/">
133
                Order allow,deny
134
                Deny from all
135
                Satisfy All
136
        </DirectoryMatch>
137
138
        <DirectoryMatch "^/.*/\.hg/">
139
                Order allow,deny
140
                Deny from all
141
                Satisfy All
142
        </DirectoryMatch>
143
144
        <DirectoryMatch "^/.*/\.git/">
145
                Order allow,deny
146
                Deny from all
147
                Satisfy All
148
        </DirectoryMatch>
149
150
        <Directory /var/www/code/public>
151
                Options -MultiViews
152
	</Directory>
153
154
        <Directory /var/www/code/public/themes/soundsoftware/stylesheets/fonts>
155
		# Avoid other sites embedding our fonts
156
		RewriteEngine on
157
		RewriteCond %{HTTP_REFERER} !^$
158
		RewriteCond %{HTTP_REFERER} !^http(s)?://code.soundsoftware.ac.uk/.*$ [NC]
159
		RewriteRule \.(ttf|woff|eot|otf|svg|zip|gz|html|txt)$ - [F]
160
	</Directory>
161
162
	ScriptAlias /hg "/var/hg/index.cgi"
163
164
	<Location /hg>
165
               	AuthName "Mercurial"
166
                AuthType Basic
167
                Require valid-user
168
		PerlAccessHandler Apache::Authn::SoundSoftware::access_handler
169
      		PerlAuthenHandler Apache::Authn::SoundSoftware::authen_handler
170
		PerlSetVar HTTPS "on"
171
		SoundSoftwareDSN "dbi:Pg:database=code;host=localhost"
172
    		SoundSoftwareDbUser "code"
173
     		SoundSoftwareDbPass "INSERT_POSTGRES_PASSWORD_HERE"
174
		SoundSoftwareRepoPrefix "/var/hg/"
175
		SoundSoftwareSslRequired "on"
176
		Options +ExecCGI
177
		AddHandler cgi-script .cgi
178
		ExpiresDefault now
179
        </Location>
180
181
	Alias /git "/var/files/git-mirror"
182
183
	<Directory "/var/files/git-mirror">
184
		Options -Indexes +FollowSymLinks
185
                Order allow,deny
186
                Allow from all
187
	</Directory>
188
	<Directory ~ "/var/files/git-mirror/.*\.workdir">
189
		Order allow,deny
190
		Deny from all
191
	</Directory>
192
	<Directory ~ "/var/files/git-mirror/__.*">
193
                Order allow,deny
194
                Deny from all
195
	</Directory>
196
197
	ErrorLog /var/log/apache2/code-error.log
198
	CustomLog /var/log/apache2/code-access.log vhost_combined
199
200
        LogLevel warn
201
        ServerSignature Off
202
203
</VirtualHost>
204
205
production:
206
  adapter: postgresql
207
  database: code
208
  host: localhost
209
  username: code
210
  password: "INSERT_POSTGRES_PASSWORD_HERE"
211
212 1571:4c2b25b7e85f Chris
PassengerMaxPoolSize 60
213
214
LoadModule passenger_module /var/lib/gems/2.3.0/gems/passenger-4.0.60/buildout/apache2/mod_passenger.so
215
PassengerRoot /var/lib/gems/2.3.0/gems/passenger-4.0.60
216
PassengerDefaultRuby /usr/bin/ruby2.3
217
# Apache::DBI is supposed to be a transparent replacement for Perl DBI with
218
# better performance when multiple connections are made with common DSN, user
219
# and password
220
PerlModule Apache::DBI
221 1569:26a4f99ec679 Chris
#!/bin/bash
222
223
set -eu
224
225
dockerdir=./extra/soundsoftware/dockertest
226
if [ ! -d "$dockerdir" ]; then
227
    echo "Run this script from the root of a working copy of soundsoftware-site"
228
    exit 2
229
fi
230
231
dockertag="cannam/soundsoftware-site"
232
233
sudo docker build -t "$dockertag" -f "$dockerdir/Dockerfile" .
234 1571:4c2b25b7e85f Chris
sudo docker run -p 8080:80 -d "$dockertag"