-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
114 lines (93 loc) · 4.41 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
FROM ghcr.io/openhistoricalmap/cgimap:0.0.1-0.dev.git.2087.h94d548c
# Install Passenger
RUN gem install passenger && passenger-install-apache2-module --auto
# Install svgo required
RUN npm install -g svgo
# Install openstreetmap-website
RUN rm -rf $workdir/html
ENV OPENHISTORICALMAP_WEBSITE_GITSHA=dae4f4273c2ac1f991ac337842b33f6fea07d41c
RUN git clone https://github.com/OpenHistoricalMap/ohm-website.git $workdir \
&& cd $workdir \
&& git checkout $OPENHISTORICALMAP_WEBSITE_GITSHA
WORKDIR $workdir
# change the echo here with a reason for changing the commithash
RUN echo 'Hotfix to remove "missing interpolation argument"s from ~30 locale files'
RUN git fetch && rm -rf .git
# Install Ruby packages
RUN gem install bundler && bundle install
# Configure database.yml
RUN cp $workdir/config/example.database.yml $workdir/config/database.yml
RUN touch $workdir/config/settings.local.yml
RUN cp $workdir/config/example.storage.yml $workdir/config/storage.yml
# Protect sensitive information
RUN chmod 600 $workdir/config/database.yml
RUN yarn install
RUN bundle exec rake yarn:install
# Generate RAILS_MASTER_KEY and SECRET_KEY_BASE during build
RUN rm -f config/credentials.yml.enc
RUN export RAILS_MASTER_KEY=$(openssl rand -hex 16) && \
export SECRET_KEY_BASE=$(rails secret) && \
echo $RAILS_MASTER_KEY > config/master.key && \
if [ ! -f config/credentials.yml.enc ]; then \
EDITOR="echo" RAILS_MASTER_KEY=$RAILS_MASTER_KEY rails credentials:edit; \
fi && \
RAILS_MASTER_KEY=$RAILS_MASTER_KEY rails runner " \
require 'active_support/encrypted_configuration'; \
require 'yaml'; \
creds = ActiveSupport::EncryptedConfiguration.new( \
config_path: 'config/credentials.yml.enc', \
key_path: 'config/master.key', \
env_key: 'RAILS_MASTER_KEY', \
raise_if_missing_key: true \
); \
credentials = { secret_key_base: '${SECRET_KEY_BASE}' }; \
creds.write(credentials.to_yaml); \
puts 'Credentials configured correctly.'"
RUN bundle exec rake i18n:js:export --trace
RUN bundle exec rake assets:precompile
# The rack interface requires a `tmp` directory to use openstreetmap-cgimap
RUN ln -s /tmp /var/www/tmp
# Add Apache configuration file
ADD config/production.conf /etc/apache2/sites-available/production.conf
RUN a2enmod headers setenvif proxy proxy_http proxy_fcgi fcgid rewrite lbmethod_byrequests
RUN a2dissite 000-default
RUN a2ensite production
# Enable the Passenger Apache module and restart Apache
RUN echo "ServerName $(cat /etc/hostname)" >> /etc/apache2/apache2.conf
# Config passenger module
RUN echo "LoadModule passenger_module $(passenger-config --root)/buildout/apache2/mod_passenger.so" > /etc/apache2/mods-available/passenger.load
RUN echo "<IfModule mod_passenger.c>\n\
PassengerRoot $(passenger-config --root)\n\
PassengerRuby /usr/local/bin/ruby\n\
</IfModule>" > /etc/apache2/mods-available/passenger.conf
RUN a2enmod passenger
# Check installation
RUN /usr/local/bundle/bin/passenger-config validate-install
RUN /usr/local/bundle/bin/passenger-memory-stats
# Config the virtual host apache2
RUN apache2ctl configtest
# Set Permissions for www-data
RUN chown -R www-data: $workdir
# Clone Map-styles
ENV OPENHISTORICALMAP_MAP_STYLES_GITSHA=6de6e329569ab6561d1fa6ab2cebb42df7fd17c7
RUN git clone --branch staging --depth 1 https://github.com/OpenHistoricalMap/map-styles.git $workdir/public/map-styles
RUN cd $workdir/public/map-styles && git fetch --depth 1 origin $OPENHISTORICALMAP_MAP_STYLES_GITSHA && git checkout $OPENHISTORICALMAP_MAP_STYLES_GITSHA
RUN rm -rf $workdir/public/map-styles/.git
COPY update_map_styles.py $workdir/
# Clone leaflet-ohm-timeslider-v2
ENV LEAFLET_OHM_TIMESLIDER_V2=dd0acbdc9432fae6a4d09a17a4848c391e5064f0
RUN git clone https://github.com/OpenHistoricalMap/leaflet-ohm-timeslider-v2.git $workdir/public/leaflet-ohm-timeslider-v2 \
&& cd $workdir/public/leaflet-ohm-timeslider-v2 \
&& git checkout dd0acbdc9432fae6a4d09a17a4848c391e5064f0 \
&& rm -rf .git \
&& chmod 777 -R assets/ \
&& cp decimaldate.* $workdir/app/assets/javascripts/ \
&& cp leaflet-ohm-timeslider.* $workdir/app/assets/javascripts/ \
&& cp leaflet-ohm-timeslider.* $workdir/app/assets/stylesheets/ \
&& cp assets/* $workdir/app/assets/images/
# Add settings
ADD config/settings.yml $workdir/config/
COPY start.sh $workdir/
COPY cgimap.sh $workdir/
COPY liveness.sh $workdir/
CMD $workdir/start.sh