From 738ab37716f0c89d67f253f629b56d9a2eba6fdc Mon Sep 17 00:00:00 2001 From: brush Date: Sun, 3 Dec 2023 02:25:26 -0800 Subject: [PATCH] add samba customization to dockerfile, if nextcloud_container_image_customizations_samba_enabled: true (#12) * Update main.yml set container customizations to enabled if nextcloud_container_image_smb_enabled is set (OR imagemagick) * nextcloud_container_image_customizations_smb_enabled activates customizations * add smbclient installation to docker image, if enabled see https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/smb/apache/Dockerfile for source * Set variable default and revise multiline syntax Integrate suggestions from @spantaleev * Refactor code to make only a single, one-line package install Per suggestion @spanteleev; so that extra files can be deleted without leaving a footprint in the stack of images --- defaults/main.yml | 14 +++++++++++++- templates/customizations/Dockerfile.j2 | 13 +++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index c94ccb4..228f9c0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -36,6 +36,11 @@ nextcloud_customized_container_src_path: "{{ nextcloud_base_path }}/customized-c nextcloud_container_image_customizations_php_imageick_installation_enabled: false nextcloud_container_image_customizations_php_imageick_installation_package: "libmagickcore-6.q16-6-extra" +# Samba (SMB) support for Windows fileshares can be setup using the toggle below, which +# installs the smbclient package per the example here https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/smb/apache/Dockerfile +# Also see ../../templates/customizations/Dockerfile.j2 +nextcloud_container_image_customizations_samba_enabled: false + # Preview generator setup # # Enable the variable nextcloud_preview_enabled and you are good to go. @@ -90,7 +95,14 @@ nextcloud_preview_app_jpeg_quality: "60" # - `nextcloud_container_image_customizations_dockerfile_body_custom` # - `nextcloud_container_image_customized` # - `nextcloud_container_image_final` -nextcloud_container_image_customizations_enabled: "{{ nextcloud_container_image_customizations_php_imageick_installation_enabled }}" +nextcloud_container_image_customizations_enabled: | + {{ + ( + nextcloud_container_image_customizations_php_imageick_installation_enabled + or + nextcloud_container_image_customizations_samba_enabled + ) + }} # nextcloud_container_image_customizations_dockerfile_body_custom contains your custom Dockerfile steps # for building your customized Nextcloud image based on the original (upstream) image (`nextcloud_container_image`). diff --git a/templates/customizations/Dockerfile.j2 b/templates/customizations/Dockerfile.j2 index b60a5f4..a57ff36 100644 --- a/templates/customizations/Dockerfile.j2 +++ b/templates/customizations/Dockerfile.j2 @@ -1,8 +1,17 @@ FROM {{ nextcloud_container_image }} +{% set packages_to_install = [] %} + {% if nextcloud_container_image_customizations_php_imageick_installation_enabled %} -RUN apt -y update -RUN apt -y install {{ nextcloud_container_image_customizations_php_imageick_installation_package }} +{% set packages_to_install = packages_to_install + [nextcloud_container_image_customizations_php_imageick_installation_package] %} +{% endif %} + +{% if nextcloud_container_image_customizations_samba_enabled %} +{% set packages_to_install = packages_to_install + ['procps', 'smbclient'] %} +{% endif %} + +{% if packages_to_install | length > 0 %} +RUN apt -y update && apt -y install {{ packages_to_install | join(' ') }} && rm -rf /var/lib/apt/lists/* {% endif %} {{ nextcloud_container_image_customizations_dockerfile_body_custom }}