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 @ 1570:ae2f71010562

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
# Set up Apache config and webapp database config (todo: insert variables)
66
67
RUN cp extra/soundsoftware/dockertest/code.conf /etc/apache2/sites-available/
68
RUN cp extra/soundsoftware/dockertest/database.yml config/database.yml
69
70
71
# Install Rails dependencies (database.yml must be populated before this)
72
73 1569:26a4f99ec679 Chris
RUN gem install bundler
74
RUN bundle install
75 1570:ae2f71010562 Chris
76
77
# Import Postgres database from postgres-dumpall file
78
79 1569:26a4f99ec679 Chris
RUN chown postgres postgres-dumpall
80 1570:ae2f71010562 Chris
RUN /etc/init.d/postgresql start && \
81
  sudo -u postgres psql -f postgres-dumpall postgres
82
83
84
# Install Perl auth module for Hg access
85
86
RUN mkdir -p /usr/local/lib/site_perl/Apache/Authn/
87
RUN cp extra/soundsoftware/SoundSoftware.pm /usr/local/lib/site_perl/Apache/Authn/
88
89
90
# Enable site for Apache
91
92
RUN ln -s ../sites-available/code.conf /etc/apache2/sites-enabled/10-code.conf
93
RUN apache2ctl configtest
94
95
# A test Apache config. Lacks SSL, lacks a desirable extra layer of
96
# authentication for admin interface paths. Do not deploy this.
97
98
PerlLoadModule Apache::Authn::SoundSoftware
99
100
<VirtualHost *:80>
101
        ServerName code.soundsoftware.ac.uk
102
        ServerAdmin chris.cannam@soundsoftware.ac.uk
103
104
        DocumentRoot /var/www/code/public
105
        PassengerRestartDir restart_files
106
        PassengerHighPerformance on
107
        PassengerMaxRequests 50000
108
        PassengerStatThrottleRate 5
109
	PassengerStartTimeout 60
110
	PassengerFriendlyErrorPages off
111
        RailsSpawnMethod smart
112
        ExpiresDefault "access plus 1 minute"
113
114
        <DirectoryMatch "^/.*/\.svn/">
115
                Order allow,deny
116
                Deny from all
117
                Satisfy All
118
        </DirectoryMatch>
119
120
        <DirectoryMatch "^/.*/\.hg/">
121
                Order allow,deny
122
                Deny from all
123
                Satisfy All
124
        </DirectoryMatch>
125
126
        <DirectoryMatch "^/.*/\.git/">
127
                Order allow,deny
128
                Deny from all
129
                Satisfy All
130
        </DirectoryMatch>
131
132
        <Directory /var/www/code/public>
133
                Options -MultiViews
134
	</Directory>
135
136
        <Directory /var/www/code/public/themes/soundsoftware/stylesheets/fonts>
137
		# Avoid other sites embedding our fonts
138
		RewriteEngine on
139
		RewriteCond %{HTTP_REFERER} !^$
140
		RewriteCond %{HTTP_REFERER} !^http(s)?://code.soundsoftware.ac.uk/.*$ [NC]
141
		RewriteRule \.(ttf|woff|eot|otf|svg|zip|gz|html|txt)$ - [F]
142
	</Directory>
143
144
	ScriptAlias /hg "/var/hg/index.cgi"
145
146
	<Location /hg>
147
               	AuthName "Mercurial"
148
                AuthType Basic
149
                Require valid-user
150
		PerlAccessHandler Apache::Authn::SoundSoftware::access_handler
151
      		PerlAuthenHandler Apache::Authn::SoundSoftware::authen_handler
152
		PerlSetVar HTTPS "on"
153
		SoundSoftwareDSN "dbi:Pg:database=code;host=localhost"
154
    		SoundSoftwareDbUser "code"
155
     		SoundSoftwareDbPass "INSERT_POSTGRES_PASSWORD_HERE"
156
		SoundSoftwareRepoPrefix "/var/hg/"
157
		SoundSoftwareSslRequired "on"
158
		Options +ExecCGI
159
		AddHandler cgi-script .cgi
160
		ExpiresDefault now
161
        </Location>
162
163
	Alias /git "/var/files/git-mirror"
164
165
	<Directory "/var/files/git-mirror">
166
		Options -Indexes +FollowSymLinks
167
                Order allow,deny
168
                Allow from all
169
	</Directory>
170
	<Directory ~ "/var/files/git-mirror/.*\.workdir">
171
		Order allow,deny
172
		Deny from all
173
	</Directory>
174
	<Directory ~ "/var/files/git-mirror/__.*">
175
                Order allow,deny
176
                Deny from all
177
	</Directory>
178
179
	ErrorLog /var/log/apache2/code-error.log
180
	CustomLog /var/log/apache2/code-access.log vhost_combined
181
182
        LogLevel warn
183
        ServerSignature Off
184
185
</VirtualHost>
186
187
production:
188
  adapter: postgresql
189
  database: code
190
  host: localhost
191
  username: code
192
  password: "INSERT_POSTGRES_PASSWORD_HERE"
193
194 1569:26a4f99ec679 Chris
#!/bin/bash
195
196
set -eu
197
198
dockerdir=./extra/soundsoftware/dockertest
199
if [ ! -d "$dockerdir" ]; then
200
    echo "Run this script from the root of a working copy of soundsoftware-site"
201
    exit 2
202
fi
203
204
dockertag="cannam/soundsoftware-site"
205
206
sudo docker build -t "$dockertag" -f "$dockerdir/Dockerfile" .