From d3ef8b472a9a1645daab4fb3f57a699054167f65 Mon Sep 17 00:00:00 2001 From: Felix Bartels <1257835+fbartels@users.noreply.github.com> Date: Sat, 26 Sep 2020 15:44:26 +0200 Subject: [PATCH] enhance example for installing plugins at build time (#458) * enhance example for installing plugins at build time Relates to https://github.com/zokradonh/kopano-docker/issues/457 * do not always rebuild the webapp base when building the webapp plugins image documentation --- Makefile | 4 +++- webapp/Dockerfile.plugins | 23 +++++++++++++++++++++++ webapp/start.sh | 4 +++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 10e4688..67a75cd 100644 --- a/Makefile +++ b/Makefile @@ -187,11 +187,13 @@ build-webapp: build-php build-webapp-demo: build-webapp ## Replaces the actual kopano_webapp container with one that has login hints for demo.kopano.com. docker build --rm \ + --build-arg docker_repo=$(docker_repo) \ -f webapp/Dockerfile.demo \ -t $(docker_repo)/kopano_webapp webapp/ -build-webapp-plugins: build-webapp ## Example for a custom image to install Kopano WebApp plugins +build-webapp-plugins: ## Example for a custom image to install Kopano WebApp plugins docker build --rm \ + --build-arg docker_repo=$(docker_repo) \ -f webapp/Dockerfile.plugins \ -t $(docker_repo)/kopano_webapp webapp/ diff --git a/webapp/Dockerfile.plugins b/webapp/Dockerfile.plugins index bf36660..4f1db87 100644 --- a/webapp/Dockerfile.plugins +++ b/webapp/Dockerfile.plugins @@ -1,3 +1,4 @@ +# This Dockerfile can be built by running `make build-webapp-plugins` in the root of this project ARG docker_repo=zokradonh FROM ${docker_repo}/kopano_webapp @@ -6,6 +7,28 @@ ENV \ KCCONF_WEBAPPPLUGIN_MDM_PLUGIN_MDM_SERVER=kopano_zpush:9080 \ KCCONF_WEBAPPPLUGIN_MDM_PLUGIN_MDM_SERVER_SSL=false +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + RUN apt-get update && apt-get install -y --no-install-recommends \ + "${ADDITIONAL_KOPANO_PACKAGES}" \ + "${ADDITIONAL_KOPANO_WEBAPP_PLUGINS}" \ + kopano-webapp-plugin-files \ + kopano-webapp-plugin-filesbackend-owncloud \ + kopano-webapp-plugin-intranet \ kopano-webapp-plugin-mdm \ + kopano-webapp-plugin-pimfolder \ + kopano-webapp-plugin-smime \ && rm -rf /var/cache/apt /var/lib/apt/lists + +# tweak to make the container read-only +RUN mkdir -p /tmp/webapp/ && \ + for i in /etc/kopano/webapp/* /etc/kopano/webapp/.[^.]*; do \ + if [ -L "$i" ]; then \ + continue; \ + fi; \ + if [[ "$i" = *.dist ]]; then \ + continue; \ + fi; \ + mv -v "$i" "$i.dist"; \ + ln -s /tmp/webapp/"$(basename "$i")" "$i"; \ + done diff --git a/webapp/start.sh b/webapp/start.sh index 4550929..6b4a7f7 100755 --- a/webapp/start.sh +++ b/webapp/start.sh @@ -31,6 +31,7 @@ if [ "${AUTOCONFIGURE}" == true ]; then echo "Notice: Container is run read-only, skipping package installation." echo "If you want to have additional packages installed in the container either:" echo "- build your own image with the packages already included" + echo " - see https://github.com/zokradonh/kopano-docker/blob/master/webapp/Dockerfile.plugins for an example of such a Dockerfile" echo "- switch the container to 'read_only: false'" fi @@ -52,7 +53,8 @@ if [ "${AUTOCONFIGURE}" == true ]; then # fallback for plugins installed during runtime for i in /etc/kopano/webapp/*.php; do filename=$(basename -- "$i") - if [ "$filename" = config.php ]; then + # skip file if its already a symlink + if [ -L "$i" ]; then continue fi mv -vn "$i" "/tmp/webapp/$filename"