Simplify hourglass asset compilation and make image smaller with better apt uninstall.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-03-23 19:59:29 +01:00
parent c42e698689
commit 53069307f9

View File

@@ -9,37 +9,26 @@ ENV REDMINE_SEND_REMINDERS_DAYS=0 \
RUN set -eux; \
apt-get update; \
apt-get install -y cron nodejs gcc make; \
apt-get install -y --no-install-recommends cron nodejs; \
savedAptMark="$(apt-mark showmanual)"; \
apt-get install -y --no-install-recommends gcc make; \
# Compile FFI module
chmod 770 /usr/local/bundle/gems /usr/local/bundle/extensions/x86_64-linux /usr/local/bundle/extensions/x86_64-linux/3.1.0; \
bundle check || bundle install; \
# Clean-up
apt-get purge -y --auto-remove gcc make; \
apt-get clean; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.cache; \
# Remove default cron mess
rm -f /etc/cron.daily/*; \
rm -f /etc/cron.d/*; \
# Install plugin dependencies
# fill up "database.yml" with bogus entries so the redmine Gemfile will pre-install all database adapter dependencies
echo '# the following entries only exist to force `bundle install` to pre-install all database adapter dependencies -- they can be safely removed/ignored' > ./config/database.yml; \
#for adapter in mysql2 postgresql sqlserver sqlite3; do \
# echo "$adapter:" >> ./config/database.yml; \
# echo " adapter: $adapter" >> ./config/database.yml; \
#done; \
echo "production:" >> ./config/database.yml; \
echo " adapter: mysql2" >> ./config/database.yml; \
bundle check || bundle install; \
# For hourglass plugin
cp plugins/000_redmine_x_ux_upgrade/init.rb plugins/000_redmine_x_ux_upgrade/init.rb.orig; \
git apply ux_upgrade-disable_db.patch; \
# fill up "database.yml" with bogus entries so the plugin can compile it assets
echo "production:" >> ./config/database.yml; \
echo " adapter: mysql2" >> ./config/database.yml; \
mv plugins/000_redmine_x_ux_upgrade/init.rb plugins/000_redmine_x_ux_upgrade/init.rb.orig; \
# WARNING: the next command makes the image larger by almost 100 MB
echo Hourglass::Assets.compile|rails console; \
#bundle exec rake redmine:plugins:assets RAILS_ENV=mysql2 NAME=redmine_hourglass; \
#bundle exec rake redmine:plugins:assets RAILS_ENV=postgresql NAME=redmine_hourglass; \
#bundle exec rake redmine:plugins:assets RAILS_ENV=sqlserver NAME=redmine_hourglass; \
#bundle exec rake redmine:plugins:assets RAILS_ENV=sqlite3 NAME=redmine_hourglass; \
rm ./config/database.yml; \
mv plugins/000_redmine_x_ux_upgrade/init.rb.orig plugins/000_redmine_x_ux_upgrade/init.rb; \
# end hourglass plugin
chmod +x /pre-entrypoint.sh; \
# setting ENTRYPOINT destroys CMD so replace the entrypoint script and call it later
# (see bottom note in https://docs.docker.com/engine/reference/builder/#entrypoint)
@@ -47,4 +36,17 @@ RUN set -eux; \
mv /pre-entrypoint.sh /docker-entrypoint.sh; \
# Apply patches
git apply project_identifier.patch; \
rm *.patch
rm *.patch; \
# Clean-up
find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| grep -v '^/usr/local/' \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
apt-get clean; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.cache;