Bump Ruby to 2.7.2, Decidim to 0.23.1

- Split image to nginx and decidim
 - Make database migrations persistent, resolves #486
This commit is contained in:
Disassembler 2020-11-21 09:25:40 +01:00
parent 86c97de908
commit 03d56ac0c9
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
13 changed files with 91 additions and 47 deletions

View File

@ -36,7 +36,7 @@ spoc-image build -p alpine3.12-java8/image
spoc-image build -p alpine3.12-php7.3/image spoc-image build -p alpine3.12-php7.3/image
spoc-image build -p alpine3.12-python3.8/image spoc-image build -p alpine3.12-python3.8/image
spoc-image build -p alpine3.12-ruby2.4/image spoc-image build -p alpine3.12-ruby2.4/image
spoc-image build -p alpine3.12-ruby2.6/image spoc-image build -p alpine3.12-ruby2.7/image
spoc-image build -p alpine3.12-tomcat7/image spoc-image build -p alpine3.12-tomcat7/image
spoc-image build -p alpine3.12-tomcat8.5/image spoc-image build -p alpine3.12-tomcat8.5/image
@ -63,7 +63,8 @@ spoc-app publish crisiscleanup/app
spoc-image build -p cts/image spoc-image build -p cts/image
spoc-app publish cts/app spoc-app publish cts/app
spoc-image build -p decidim/image spoc-image build -p decidim/decidim-nginx.image
spoc-image build -p decidim/decidim.image
spoc-app publish decidim/app spoc-app publish decidim/app
spoc-image build -p dhis2/image spoc-image build -p dhis2/image

View File

@ -1,5 +1,5 @@
{ {
"version": "0.22.0-201021", "version": "0.23.1-201118",
"meta": { "meta": {
"title": "Decidim", "title": "Decidim",
"desc-cs": "Platforma pro účast občanů", "desc-cs": "Platforma pro účast občanů",
@ -8,12 +8,13 @@
}, },
"containers": { "containers": {
"decidim": { "decidim": {
"image": "decidim_0.22.0-201021", "image": "decidim_0.23.1-201118",
"depends": [ "depends": [
"decidim-postgres" "decidim-postgres"
], ],
"mounts": { "mounts": {
"decidim/decidim_conf": "srv/decidim-app/config", "decidim/decidim_conf": "srv/decidim-app/config",
"decidim/decidim_data/migrate": "srv/decidim-app/db/migrate",
"decidim/decidim_data/storage": "srv/decidim-app/storage", "decidim/decidim_data/storage": "srv/decidim-app/storage",
"decidim/decidim_data/uploads": "srv/decidim-app/public/uploads" "decidim/decidim_data/uploads": "srv/decidim-app/public/uploads"
} }

View File

@ -1,21 +1,16 @@
IMAGE decidim_0.22.0-201021 IMAGE decidim-nginx_1.18.0-201118
FROM alpine3.12-ruby2.6_2.6.6-201021 FROM alpine3.12-ruby2.7_2.7.2-201118
# https://github.com/Platoniq/decidim-install/blob/master/decidim-bionic.md
# https://github.com/Platoniq/decidim-install/blob/master/basic-config.md
ENV RAILS_ENV production
RUN EOF RUN EOF
# Install runtime dependencies # Install runtime dependencies
apk --no-cache add curl imagemagick libpq nodejs pcre procps tzdata apk --no-cache add curl pcre
# Install build dependencies # Install build dependencies
apk --no-cache add --virtual .deps build-base curl-dev icu-dev libxml2-dev libxslt-dev linux-headers pcre-dev postgresql-dev zlib-dev apk --no-cache add --virtual .deps build-base curl-dev libressl-dev linux-headers pcre-dev
# Install passenger # Install passenger
gem install passenger --no-document gem install passenger --no-document
ln -s /usr/local/lib/ruby/gems/2.6.0/gems/passenger-* /usr/local/lib/passenger ln -s /usr/local/lib/ruby/gems/2.7.0/gems/passenger-* /usr/local/lib/passenger
# Create OS user # Create OS user
addgroup -S -g 8080 decidim addgroup -S -g 8080 decidim
@ -44,40 +39,22 @@ RUN EOF
--with-http_gzip_static_module \ --with-http_gzip_static_module \
--with-http_stub_status_module \ --with-http_stub_status_module \
--with-http_addition_module \ --with-http_addition_module \
--without-http_fastcgi_module \
--without-http_memcached_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--with-cc-opt=-Wno-error \ --with-cc-opt=-Wno-error \
--add-module=/usr/local/lib/passenger/src/nginx_module --add-module=/usr/local/lib/passenger/src/nginx_module
make -j $(getconf _NPROCESSORS_ONLN) make -j $(getconf _NPROCESSORS_ONLN)
make install make install
rm -f /etc/nginx/*.default rm -f /etc/nginx/*.default
# Install Decidim
bundle config build.nokogiri --use-system-libraries
gem install bundler:1.17.3
gem install decidim
cd /srv
decidim decidim-app
EOF
COPY image.d
RUN EOF
# Install gems required by decidim
cd /srv/decidim-app
bundle update
# Setup delayed job for mail sending
bin/rails generate delayed_job:active_record
# Precompile static assets
bin/rails assets:precompile
# Change ownership
chown -R decidim:decidim /srv/decidim-app
# Cleanup # Cleanup
apk --no-cache del .deps apk --no-cache del .deps
rm -rf /tmp/* rm -rf /tmp/*
rm -rf /.bundle /root/.gem rm -rf /.gem
EOF EOF
COPY decidim-nginx.image.d
CMD /bin/s6-svscan /etc/services.d CMD /bin/s6-svscan /etc/services.d

View File

@ -0,0 +1,47 @@
IMAGE decidim_0.23.1-201118
FROM decidim-nginx_1.18.0-201118
# https://github.com/Platoniq/decidim-install/blob/master/decidim-bionic.md
# https://github.com/Platoniq/decidim-install/blob/master/basic-config.md
ENV RAILS_ENV production
RUN EOF
# Install runtime dependencies
apk --no-cache add imagemagick libpq nodejs procps tzdata
# Install build dependencies
apk --no-cache add --virtual .deps build-base git libxml2-dev libxslt-dev postgresql-dev zlib-dev
# Install Decidim
bundle config build.nokogiri --use-system-libraries
gem install decidim
cd /srv
decidim decidim-app
EOF
COPY decidim.image.d
RUN EOF
# Install gems required by decidim
cd /srv/decidim-app
bundle install
# Setup delayed job for mail sending
bin/rails generate delayed_job:active_record
# Precompile static assets
bin/rails assets:precompile
# Remove database migrations (will be recreated in install.sh / update.sh)
rm /srv/decidim-app/db/migrate/*
# Change ownership
chown -R decidim:decidim /srv/decidim-app
# Cleanup
apk --no-cache del .deps
rm -rf /.bundle /.gem
EOF
CMD /bin/s6-svscan /etc/services.d

View File

@ -4,9 +4,10 @@ source "https://rubygems.org"
ruby RUBY_VERSION ruby RUBY_VERSION
gem "decidim", "0.22.0" gem "decidim", "0.23.1"
# gem "decidim-consultations", "0.22.0" # gem "decidim-consultations", "0.23.1"
# gem "decidim-initiatives", "0.22.0" # gem "decidim-initiatives", "0.23.1"
# gem "decidim-templates", "0.23.1"
gem "bootsnap", "~> 1.3" gem "bootsnap", "~> 1.3"
@ -15,10 +16,12 @@ gem "uglifier", "~> 4.1"
gem "faker", "~> 1.9" gem "faker", "~> 1.9"
gem "wicked_pdf", "~> 1.4"
group :development, :test do group :development, :test do
gem "byebug", "~> 11.0", platform: :mri gem "byebug", "~> 11.0", platform: :mri
gem "decidim-dev", "0.22.0" gem "decidim-dev", "0.23.1"
end end
group :development do group :development do

View File

@ -5,7 +5,7 @@ set -ev
POSTGRES_DATA="${VOLUMES_DIR}/decidim/postgres_data" POSTGRES_DATA="${VOLUMES_DIR}/decidim/postgres_data"
DECIDIM_CONF="${VOLUMES_DIR}/decidim/decidim_conf" DECIDIM_CONF="${VOLUMES_DIR}/decidim/decidim_conf"
DECIDIM_DATA="${VOLUMES_DIR}/decidim/decidim_data" DECIDIM_DATA="${VOLUMES_DIR}/decidim/decidim_data"
DECIDIM_LAYER="${LAYERS_DIR}/decidim_0.22.0-201021" DECIDIM_LAYER="${LAYERS_DIR}/decidim_0.23.1-201118"
# Create Postgres instance # Create Postgres instance
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA} install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
@ -24,14 +24,17 @@ envsubst <createdb.sql | spoc-container exec decidim-postgres -- psql
cp -rp ${DECIDIM_LAYER}/srv/decidim-app/config ${DECIDIM_CONF} cp -rp ${DECIDIM_LAYER}/srv/decidim-app/config ${DECIDIM_CONF}
# Configure Decidim # Configure Decidim
install -o 108080 -g 108080 -m 700 -d ${DECIDIM_DATA}/migrate
install -o 108080 -g 108080 -m 700 -d ${DECIDIM_DATA}/storage install -o 108080 -g 108080 -m 700 -d ${DECIDIM_DATA}/storage
install -o 108080 -g 108080 -m 700 -d ${DECIDIM_DATA}/uploads install -o 108080 -g 108080 -m 700 -d ${DECIDIM_DATA}/uploads
export DECIDIM_SECRET=$(spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; rake secret') export DECIDIM_SECRET=$(spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rake secret')
install -o 108080 -g 108080 -m 640 decidim_conf/environments/production.rb ${DECIDIM_CONF}/environments/production.rb install -o 108080 -g 108080 -m 640 decidim_conf/environments/production.rb ${DECIDIM_CONF}/environments/production.rb
install -o 108080 -g 108080 -m 640 decidim_conf/initializers/decidim.rb ${DECIDIM_CONF}/initializers/decidim.rb install -o 108080 -g 108080 -m 640 decidim_conf/initializers/decidim.rb ${DECIDIM_CONF}/initializers/decidim.rb
envsubst <decidim_conf/application.yml | install -o 108080 -g 108080 -m 640 /dev/stdin ${DECIDIM_CONF}/application.yml envsubst <decidim_conf/application.yml | install -o 108080 -g 108080 -m 640 /dev/stdin ${DECIDIM_CONF}/application.yml
# Populate database # Populate database
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim:upgrade'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails generate delayed_job:active_record'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails db:migrate' spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails db:migrate'
# Create admin account # Create admin account

12
lxc-apps/decidim/update.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -ev
# Start service containers
spoc-container start decidim-postgres
# Run database migration
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim:upgrade'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails db:migrate'
# Stop service containers
spoc-container stop decidim-postgres

View File

@ -1,4 +1,4 @@
IMAGE alpine3.12-ruby2.6_2.6.6-201021 IMAGE alpine3.12-ruby2.7_2.7.2-201118
FROM alpine3.12_3.12.1-201021 FROM alpine3.12_3.12.1-201021
RUN EOF RUN EOF
@ -10,7 +10,7 @@ RUN EOF
# Download and unpack Ruby # Download and unpack Ruby
mkdir -p /usr/src/ruby mkdir -p /usr/src/ruby
wget http://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.xz -O - | tar xJf - -C /usr/src/ruby --strip-components=1 wget http://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.xz -O - | tar xJf - -C /usr/src/ruby --strip-components=1
# Compile and install Ruby # Compile and install Ruby
cd /usr/src/ruby cd /usr/src/ruby