-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile.production
More file actions
132 lines (106 loc) · 4.23 KB
/
Copy pathDockerfile.production
File metadata and controls
132 lines (106 loc) · 4.23 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
FROM phusion/passenger-full:3.1.6
MAINTAINER Populate "fernando@populate.tools"
ENV HOME /home/app/decidim-diba
# Locales configuration
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Force Madrid's timezone
ENV TZ=Europe/Madrid
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install software dependencies
RUN apt install -y ca-certificates
RUN apt-get --allow-releaseinfo-change update
RUN apt-get update
RUN apt-get install -y clang build-essential
RUN apt-get install -y imagemagick gettext-base tzdata
RUN apt-get install -y p7zip
RUN apt-get install -y xfonts-base
RUN apt-get install -y xfonts-75dpi
RUN apt-get install -y --no-install-recommends libjemalloc2
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
ENV MALLOC_CONF='dirty_decay_ms:1000,narenas:2,background_thread:true'
##############################
# Install NodeJs & Yarn
##############################
RUN yes | apt remove nodejs
ENV NVM_DIR /usr/local/nvm
RUN mkdir -p /usr/local/nvm
# Replace shell with bash so we can source files
#RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Set debconf to run non-interactively
#RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
ENV NODE_VERSION 18.17.1
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
RUN npm -v
RUN npm install -g yarn
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
# Expose Nginx HTTP service
EXPOSE 80
EXPOSE 443
# Start Nginx / Passenger
RUN rm -f /etc/service/nginx/down
# Remove the default site
RUN rm /etc/nginx/sites-enabled/default
# Create app home dir
RUN mkdir -p $HOME
WORKDIR $HOME
RUN bash -lc 'rvm install ruby-3.3.4'
RUN bash -lc 'rvm --default use ruby-3.3.4'
# Install bundle of gems
RUN gem update --system \
&& gem install bundler:4.0.7 \
&& gem uninstall bundler --version 2.5.11 --force --ignore-dependencies \
&& gem install strscan:3.1.2 \
&& gem uninstall strscan --version 3.0.9 --force --ignore-dependencies \
&& gem install stringio:3.2.0 \
&& gem uninstall stringio --version 3.1.1 --force --ignore-dependencies
RUN gem install rake:13.2.1
ADD Gemfile Gemfile
ADD Gemfile.lock Gemfile.lock
ADD decidim-census decidim-census
ADD decidim-diba_census_api decidim-diba_census_api
ADD decidim-age_action_authorization decidim-age_action_authorization
ADD decidim-ldap decidim-ldap
ADD decidim-process_settings decidim-process_settings
RUN bundle config set without 'development test'
RUN bundle config set deployment 'true'
RUN bundle install --jobs=4
# Add the nginx site and config
ADD docker/nginx.conf /etc/nginx/sites-enabled/decidim-diba.conf
ADD docker/rails-env.conf /etc/nginx/main.d/rails-env.conf
RUN sed -i 's/# server_tokens off;/server_tokens off;/' /etc/nginx/nginx.conf
RUN sed -i 's/gzip on;/gzip off;/' /etc/nginx/nginx.conf
# Add the Rails app
ADD . /home/app/decidim-diba
RUN npm cache clean --force
RUN npm i graphql-docs@https://github.com/decidim/graphql-docs/raw/master/graphql-docs-0.2.1.tgz
RUN npm install
RUN RAILS_ENV=production SECRET_KEY_BASE=NOT-IMPORTANT DOCKER=1 bin/rake assets:precompile
# Add a tmp folder for pids
RUN mkdir -p tmp/pids
# Define volumes
VOLUME $HOME/public/uploads
VOLUME $HOME/log
# Configure init scripts
RUN mkdir -p /etc/my_init.d
ADD docker/fix_permissions.sh /etc/my_init.d/fix_permissions.sh
ADD docker/replace_nginx_env_variables.sh /etc/my_init.d/replace_nginx_variables.sh
RUN chmod +x /etc/my_init.d/*.sh
# Run Sidekiq as a runit-supervised service so it is restarted automatically if
# it dies (replaces the previous unsupervised, daemonized my_init.d/sidekiq.sh).
ADD docker/sidekiq/run /etc/service/sidekiq/run
RUN chmod +x /etc/service/sidekiq/run
RUN chown -R app:app $HOME
# cheat activestorage as it is still trying to create variants at storage/ even configuring public/uploads/storage as the local root path
RUN ln -s public/uploads/storage storage
# Clean up APT and bundler when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*.