From 30cd29e7ef02a3d68905cfa170cd12e9508d1da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Tue, 1 Sep 2020 19:14:30 +0200 Subject: [PATCH] Reduce openedx image size with static asset deduplication This is inspired from FUN's openedx-docker project: static files are de-duplicated with rdfind to reduce the uncompressed image size by 320Mb. --- CHANGELOG.md | 4 ++++ tutor/templates/build/openedx/Dockerfile | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad9e1bd..4a641e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Note: Breaking changes between versions are indicated by "💥". +## Unreleased + +- [Improvement] Reduce "openedx" Docker image size with static asset de-duplication + ## v10.2.1 (2020-08-27) - [Bugfix] Upgrade all services to open-release/juniper.3 diff --git a/tutor/templates/build/openedx/Dockerfile b/tutor/templates/build/openedx/Dockerfile index 3881be8..ead920f 100644 --- a/tutor/templates/build/openedx/Dockerfile +++ b/tutor/templates/build/openedx/Dockerfile @@ -111,7 +111,7 @@ RUN npm install --verbose --registry=$NPM_REGISTRY FROM minimal as production # Install system requirements -RUN apt install -y gettext gfortran graphviz graphviz-dev libffi-dev libfreetype6-dev libgeos-dev libjpeg8-dev liblapack-dev libmysqlclient-dev libpng12-dev libsqlite3-dev libxmlsec1-dev lynx ntp pkg-config \ +RUN apt install -y gettext gfortran graphviz graphviz-dev libffi-dev libfreetype6-dev libgeos-dev libjpeg8-dev liblapack-dev libmysqlclient-dev libpng12-dev libsqlite3-dev libxmlsec1-dev lynx ntp pkg-config rdfind \ && rm -rf /var/lib/apt/lists/* COPY --from=dockerize /usr/local/bin/dockerize /usr/local/bin/dockerize @@ -177,7 +177,9 @@ RUN openedx-assets xmodule \ && openedx-assets common COPY ./themes/ /openedx/themes/ RUN openedx-assets themes \ - && openedx-assets collect --settings=tutor.assets + && openedx-assets collect --settings=tutor.assets \ + # De-duplicate static assets with symlinks + && rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/ # Create a data directory, which might be used (or not) RUN mkdir /openedx/data