-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile.production
106 lines (84 loc) · 3.16 KB
/
Dockerfile.production
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
FROM phusion/passenger-ruby27:2.1.0
MAINTAINER CodiTramuntana "info@coditramuntana.com"
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-get update
RUN apt-get install -y imagemagick gettext-base tzdata
##############################
# 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 16.9.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
# Install bundle of gems
RUN gem install bundler:2.3.6
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
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
ADD docker/sidekiq.sh /etc/my_init.d/sidekiq.sh
RUN chmod +x /etc/my_init.d/*.sh
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/*.