Skip to content

Commit 29aa78f

Browse files
committed
Uncomment the dockerfile
1 parent 36b28cc commit 29aa78f

File tree

1 file changed

+120
-125
lines changed

1 file changed

+120
-125
lines changed

images/web/Dockerfile

Lines changed: 120 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -32,138 +32,133 @@ RUN rm -rf $workdir/* && curl -fsSL $OSM_WEBSITE_URL -o /tmp/openstreetmap-websi
3232
mv /tmp/openstreetmap-website-$OPENSTREETMAP_WEBSITE_GITSHA/* $workdir && \
3333
rm -rf /tmp/*
3434

35-
# RUN gem install bundler && \
36-
# bundle install && \
37-
# yarn install && \
38-
# bundle exec rake yarn:install
39-
40-
# # Dummy config for precompile
41-
# RUN cp config/example.database.yml config/database.yml && \
42-
# cp config/example.storage.yml config/storage.yml && \
43-
# touch config/settings.local.yml && \
44-
# chmod 600 config/database.yml
45-
46-
# # Create dummy credentials
47-
# RUN rm -f config/credentials.yml.enc && \
48-
# export RAILS_MASTER_KEY=$(openssl rand -hex 16) && \
49-
# export SECRET_KEY_BASE=$(bundle exec rails secret) && \
50-
# echo $RAILS_MASTER_KEY > config/master.key && \
51-
# EDITOR="echo" RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rails credentials:edit && \
52-
# RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rails runner "\
53-
# require 'active_support/encrypted_configuration'; \
54-
# require 'yaml'; \
55-
# creds = ActiveSupport::EncryptedConfiguration.new(\
56-
# config_path: 'config/credentials.yml.enc', \
57-
# key_path: 'config/master.key', \
58-
# env_key: 'RAILS_MASTER_KEY', \
59-
# raise_if_missing_key: true \
60-
# ); \
61-
# credentials = { secret_key_base: '$SECRET_KEY_BASE' }; \
62-
# creds.write(credentials.to_yaml); \
63-
# puts 'Credentials configured correctly.'"
64-
65-
# # Precompiling assets for production without requiring secret RAILS_MASTER_KEY
66-
# RUN SECRET_KEY_BASE_DUMMY=1 \
67-
# bundle exec i18n export && \
68-
# bundle exec rails assets:precompile
69-
70-
71-
# FROM ruby:3.3-slim
72-
73-
# ENV DEBIAN_FRONTEND=noninteractive \
74-
# workdir=/var/www \
75-
# BUNDLE_PATH=/usr/local/bundle \
76-
# GEM_HOME=/usr/local/bundle \
77-
# GEM_PATH=/usr/local/bundle \
78-
# PATH="/usr/local/bundle/bin:$PATH" \
79-
# RAILS_ENV=production \
80-
# PATH="$PATH:$GEM_HOME/bin"
81-
82-
# # Install base dependencies for Passenger gem compilation and runtime
83-
# RUN BUILD_DEPS=" \
84-
# build-essential \
85-
# apache2-dev \
86-
# libcurl4-openssl-dev \
87-
# zlib1g-dev \
88-
# libssl-dev \
89-
# npm \
90-
# " \
91-
# && apt-get update && apt-get install -y --no-install-recommends \
92-
# $BUILD_DEPS \
93-
# libgd-dev \
94-
# apache2 \
95-
# libapache2-mod-fcgid \
96-
# libpq5 \
97-
# libxml2 \
98-
# libyaml-0-2 \
99-
# libarchive13 \
100-
# file \
101-
# pngcrush \
102-
# optipng \
103-
# advancecomp \
104-
# pngquant \
105-
# jhead \
106-
# jpegoptim \
107-
# gifsicle \
108-
# postgresql-client \
109-
# curl \
110-
# libvips \
111-
# nodejs \
112-
# \
113-
# && npm install -g svgo \
114-
# \
115-
# # Install Passenger as a gem and compile the Apache module
116-
# \
117-
# && gem install passenger --no-document \
118-
# && yes | passenger-install-apache2-module --auto --languages ruby \
119-
# && passenger-config validate-install --auto \
120-
# \
121-
# # Delete the build dependencies to reduce image size
122-
# \
123-
# && apt-get purge -y --auto-remove $BUILD_DEPS \
124-
# \
125-
# # libgd-dev is requiered by the app on run time to process gps files
126-
# \
127-
# && apt-get update && apt-get install -y --no-install-recommends libgd3 libgd-dev \
128-
# \
129-
# # Final cleanup
130-
# \
131-
# && apt-get clean && rm -rf /var/lib/apt/lists/*
132-
133-
134-
# # Apache configuration
135-
# COPY config/production.conf /etc/apache2/sites-available/production.conf
136-
137-
# RUN passenger-install-apache2-module --snippet > /etc/apache2/mods-available/passenger.load && \
138-
# passenger-config build-native-support
139-
140-
# RUN a2enmod headers setenvif proxy proxy_http proxy_fcgi fcgid rewrite lbmethod_byrequests passenger && \
141-
# a2dissite 000-default && \
142-
# a2ensite production && \
143-
# echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
144-
# apache2ctl configtest
145-
146-
# RUN echo '#!/bin/bash\nexec /usr/local/bin/ruby --yjit --yjit-exec-mem-size=64 "$@"' > /usr/local/bin/ruby_yjit && \
147-
# chmod +x /usr/local/bin/ruby_yjit
148-
149-
# WORKDIR $workdir
35+
RUN gem install bundler && \
36+
bundle install && \
37+
yarn install && \
38+
bundle exec rake yarn:install
39+
40+
# Dummy config for precompile
41+
RUN cp config/example.database.yml config/database.yml && \
42+
cp config/example.storage.yml config/storage.yml && \
43+
touch config/settings.local.yml && \
44+
chmod 600 config/database.yml
45+
46+
# Create dummy credentials
47+
RUN rm -f config/credentials.yml.enc && \
48+
export RAILS_MASTER_KEY=$(openssl rand -hex 16) && \
49+
export SECRET_KEY_BASE=$(bundle exec rails secret) && \
50+
echo $RAILS_MASTER_KEY > config/master.key && \
51+
EDITOR="echo" RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rails credentials:edit && \
52+
RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rails runner "\
53+
require 'active_support/encrypted_configuration'; \
54+
require 'yaml'; \
55+
creds = ActiveSupport::EncryptedConfiguration.new(\
56+
config_path: 'config/credentials.yml.enc', \
57+
key_path: 'config/master.key', \
58+
env_key: 'RAILS_MASTER_KEY', \
59+
raise_if_missing_key: true \
60+
); \
61+
credentials = { secret_key_base: '$SECRET_KEY_BASE' }; \
62+
creds.write(credentials.to_yaml); \
63+
puts 'Credentials configured correctly.'"
64+
65+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
66+
RUN SECRET_KEY_BASE_DUMMY=1 \
67+
bundle exec i18n export && \
68+
bundle exec rails assets:precompile
69+
70+
71+
FROM ruby:3.3-slim
72+
73+
ENV DEBIAN_FRONTEND=noninteractive \
74+
workdir=/var/www \
75+
BUNDLE_PATH=/usr/local/bundle \
76+
GEM_HOME=/usr/local/bundle \
77+
GEM_PATH=/usr/local/bundle \
78+
PATH="/usr/local/bundle/bin:$PATH" \
79+
RAILS_ENV=production \
80+
PATH="$PATH:$GEM_HOME/bin"
81+
82+
# Install base dependencies for Passenger gem compilation and runtime
83+
RUN BUILD_DEPS=" \
84+
build-essential \
85+
apache2-dev \
86+
libcurl4-openssl-dev \
87+
zlib1g-dev \
88+
libssl-dev \
89+
npm \
90+
" \
91+
&& apt-get update && apt-get install -y --no-install-recommends \
92+
$BUILD_DEPS \
93+
libgd-dev \
94+
apache2 \
95+
libapache2-mod-fcgid \
96+
libpq5 \
97+
libxml2 \
98+
libyaml-0-2 \
99+
libarchive13 \
100+
file \
101+
pngcrush \
102+
optipng \
103+
advancecomp \
104+
pngquant \
105+
jhead \
106+
jpegoptim \
107+
gifsicle \
108+
postgresql-client \
109+
curl \
110+
libvips \
111+
nodejs \
112+
\
113+
&& npm install -g svgo \
114+
\
115+
# Install Passenger as a gem and compile the Apache module
116+
\
117+
&& gem install passenger --no-document \
118+
&& yes | passenger-install-apache2-module --auto --languages ruby \
119+
&& passenger-config validate-install --auto \
120+
\
121+
# Delete the build dependencies to reduce image size
122+
\
123+
&& apt-get purge -y --auto-remove $BUILD_DEPS \
124+
\
125+
# libgd-dev is requiered by the app on run time to process gps files
126+
\
127+
&& apt-get update && apt-get install -y --no-install-recommends libgd3 libgd-dev \
128+
\
129+
# Final cleanup
130+
\
131+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
150132

151-
# COPY --chown=www-data:www-data --from=builder /var/www /$workdir
152-
# COPY --from=builder /usr/local/bundle /usr/local/bundle
153133

154-
# COPY config/settings.yml $workdir/config/
155-
# COPY start.sh liveness.sh $workdir/
134+
# Apache configuration
135+
COPY config/production.conf /etc/apache2/sites-available/production.conf
156136

157-
# RUN ln -s /tmp /var/www/tmp
137+
RUN passenger-install-apache2-module --snippet > /etc/apache2/mods-available/passenger.load && \
138+
passenger-config build-native-support
158139

159-
# RUN mkdir -p /var/www/log && \
160-
# touch /var/www/log/production.log && \
161-
# chown -R www-data:www-data /var/www/log /var/www/public && \
162-
# chown -R www-data:www-data /var/www
140+
RUN a2enmod headers setenvif proxy proxy_http proxy_fcgi fcgid rewrite lbmethod_byrequests passenger && \
141+
a2dissite 000-default && \
142+
a2ensite production && \
143+
echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
144+
apache2ctl configtest
163145

164-
# CMD ["./start.sh"]
146+
RUN echo '#!/bin/bash\nexec /usr/local/bin/ruby --yjit --yjit-exec-mem-size=64 "$@"' > /usr/local/bin/ruby_yjit && \
147+
chmod +x /usr/local/bin/ruby_yjit
148+
149+
WORKDIR $workdir
165150

151+
COPY --chown=www-data:www-data --from=builder /var/www /$workdir
152+
COPY --from=builder /usr/local/bundle /usr/local/bundle
166153

154+
COPY config/settings.yml $workdir/config/
155+
COPY start.sh liveness.sh $workdir/
167156

157+
RUN ln -s /tmp /var/www/tmp
168158

159+
RUN mkdir -p /var/www/log && \
160+
touch /var/www/log/production.log && \
161+
chown -R www-data:www-data /var/www/log /var/www/public && \
162+
chown -R www-data:www-data /var/www
169163

164+
CMD ["./start.sh"]

0 commit comments

Comments
 (0)