IMAGE decidim_0.23.1-210130
FROM decidim-nginx_1.18.0-210106

# 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 runtime gems and plugins
    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
