From 65154cf41e054f70b24b63e09c8f2d9ff84043cc Mon Sep 17 00:00:00 2001 From: Akhil Date: Thu, 21 Jul 2022 16:00:08 +0530 Subject: [PATCH 1/4] Add selfhost nc21 --- Dockerfile | 94 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/Dockerfile b/Dockerfile index 894166de..8bc95437 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,9 +84,9 @@ RUN curl -fsSL -o integration_google.tar.gz \ rm integration_google.tar.gz; RUN curl -fsSL -o ecloud-accounts.tar.gz \ - "https://gitlab.e.foundation/e/infra/selfhost/nextcloud-apps/ecloud-drop-account/-/archive/${EA_TAG}/ecloud-drop-account-${EA_TAG}.tar.gz" && \ + "https://gitlab.e.foundation/e/infra/ecloud/nextcloud-apps/ecloud-accounts/-/archive/${EA_TAG}/ecloud-accounts-${EA_TAG}.tar.gz" && \ tar -xf ecloud-accounts.tar.gz -C ${BASE_DIR}/custom_apps/ && \ - mv "${BASE_DIR}/custom_apps/ecloud-drop-account-${EA_TAG}" "${BASE_DIR}/custom_apps/ecloud-accounts" && \ + mv "${BASE_DIR}/custom_apps/ecloud-accounts-${EA_TAG}" "${BASE_DIR}/custom_apps/ecloud-accounts" && \ rm ecloud-accounts.tar.gz; # Remove unzip when unzipping is done @@ -95,43 +95,6 @@ RUN apt-get -y remove unzip # force eCloud theme not to be disabled even when there is an upgrade process launched RUN sed -i "s/\$systemConfig->setValue('theme', '');/\$systemConfig->setValue('theme', 'eCloud');/g" ${BASE_DIR}/lib/base.php -# Patches -COPY patches/ ${TMP_PATCH_DIR}/ -RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/002-login-without-domain.patch -RUN patch -u ${BASE_DIR}/core/templates/layout.user.php -i ${TMP_PATCH_DIR}/003-contact-search-removal.patch -RUN patch -u ${BASE_DIR}/core/Controller/ContactsMenuController.php -i ${TMP_PATCH_DIR}/004-contact-search-controller-removal.patch -RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-core.patch -RUN cd ${BASE_DIR}/custom_apps && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-custom-app.patch -RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/006-recovery-email-changes.patch -RUN patch -u ${BASE_DIR}/apps/settings/lib/Settings/Personal/ServerDevNotice.php -i ${TMP_PATCH_DIR}/007-remove-dev-notice.patch -RUN patch -u ${BASE_DIR}/lib/private/Template/IconsCacher.php -i ${TMP_PATCH_DIR}/008-icons-cacher-theme-svgs.patch -RUN patch -u ${BASE_DIR}/core/Controller/SvgController.php -i ${TMP_PATCH_DIR}/008-svg-controller-theme-svgs.patch -RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/009-help-links.patch -RUN patch -u ${BASE_DIR}/lib/private/Updater.php -i ${TMP_PATCH_DIR}/010-disable-app-store-upgrade.patch -RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/011-privacy-settings.patch -RUN cd ${BASE_DIR} && patch -u ${BASE_DIR}/apps/dashboard/lib/Controller/DashboardController.php -i ${TMP_PATCH_DIR}/012-remove-user-status-widget.patch -RUN patch -u ${BASE_DIR}/lib/private/Authentication/Token/PublicKeyTokenProvider.php -i ${TMP_PATCH_DIR}/013-revert-token-password-update.patch -RUN patch -u ${BASE_DIR}/lib/private/legacy/OC_Helper.php -i ${TMP_PATCH_DIR}/014-add-mail-usage.patch -RUN rm -rf ${TMP_PATCH_DIR} - -# autocomplete leak tweak apps frontend with sed, disable group suggestion - -RUN cd ${BASE_DIR}/custom_apps/contacts && sed -i 's/"GROUP","INDIVIDUAL"/"INDIVIDUAL"/g' js/contacts-main.js -RUN cd ${BASE_DIR}/custom_apps/contacts && sed -i 's/emit("new-contact")/emit("newContact")/g' js/contacts-main.js -RUN cd ${BASE_DIR}/custom_apps/calendar && sed -i 's/"GROUP","INDIVIDUAL"/"INDIVIDUAL"/g' js/calendar-main.js -RUN cd ${BASE_DIR}/custom_apps/calendar && sed -i 's/{name:\[a,"displayname"\]},//' js/calendar-main.js - -# Set default widgets to calendar, tasks and notes -RUN sed -i 's/recommendations,spreed,mail,calendar/calendar,tasks,notes/' ${BASE_DIR}/apps/dashboard/lib/Controller/DashboardController.php - -# Remove colored background from email template logo -RUN sed -i 's/$this->header, \[$this->themingDefaults->getColorPrimary()/$this->header, \["none"/' ${BASE_DIR}/lib/private/Mail/EMailTemplate.php - -# fix min version of google data migration app -RUN sed -i "s/min-version=\"22\"/min-version=\"21\"/" ${BASE_DIR}/custom_apps/integration_google/appinfo/info.xml -RUN sed -i 's/ in Nextcloud/ /' ${BASE_DIR}/custom_apps/integration_google/js/integration_google-personalSettings.js -RUN sed -i 's/Nextcloud administrator/administrator/' ${BASE_DIR}/custom_apps/integration_google/js/integration_google-personalSettings.js - # Custom theme RUN curl -fsSL -o eCloud-theme.tar.gz \ "https://gitlab.e.foundation/e/infra/nextcloud-theme/-/archive/${THEME_VERSION}/nextcloud-theme-${THEME_VERSION}.tar.gz" && \ @@ -143,8 +106,17 @@ RUN curl -fsSL -o eCloud-theme.tar.gz \ # Replace "Get your own free account" NC link with /e/ Account link in public pages RUN sed -i 's/https:\/\/nextcloud.com\/signup\//https:\/\/e\.foundation\/\/e-email-invite\//' ${BASE_DIR}/core/templates/layout.public.php +# Remove colored background from email template logo +RUN sed -i 's/$this->header, \[$this->themingDefaults->getColorPrimary()/$this->header, \["none"/' ${BASE_DIR}/lib/private/Mail/EMailTemplate.php +# fix min version of google data migration app +RUN sed -i "s/min-version=\"22\"/min-version=\"21\"/" ${BASE_DIR}/custom_apps/integration_google/appinfo/info.xml +RUN sed -i 's/ in Nextcloud/ /' ${BASE_DIR}/custom_apps/integration_google/js/integration_google-personalSettings.js +RUN sed -i 's/Nextcloud administrator/administrator/' ${BASE_DIR}/custom_apps/integration_google/js/integration_google-personalSettings.js +RUN cd ${BASE_DIR}/custom_apps/contacts && sed -i 's/emit("new-contact")/emit("newContact")/g' js/contacts-main.js + + # Use php 8 image -FROM php:8.0.12-fpm-bullseye +FROM php:8.0.12-fpm-bullseye AS base RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images # Copy all the required files from the nextcloud stage @@ -252,3 +224,45 @@ ENV NEXTCLOUD_VERSION 21.0.9 ENTRYPOINT ["/custom_entrypoint.sh"] CMD ["php-fpm"] + +FROM base as selfhost +ARG BASE_DIR="/usr/src/nextcloud" +ARG TMP_PATCH_DIR="/tmp/build_patches" + +COPY patches/ ${TMP_PATCH_DIR}/ +# Patches +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/002-login-without-domain.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/006-recovery-email-changes.patch +RUN patch -u ${BASE_DIR}/apps/settings/lib/Settings/Personal/ServerDevNotice.php -i ${TMP_PATCH_DIR}/007-remove-dev-notice.patch +RUN patch -u ${BASE_DIR}/lib/private/Template/IconsCacher.php -i ${TMP_PATCH_DIR}/008-icons-cacher-theme-svgs.patch +RUN patch -u ${BASE_DIR}/core/Controller/SvgController.php -i ${TMP_PATCH_DIR}/008-svg-controller-theme-svgs.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/009-help-links.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/011-privacy-settings.patch +RUN patch -u ${BASE_DIR}/lib/private/Authentication/Token/PublicKeyTokenProvider.php -i ${TMP_PATCH_DIR}/013-revert-token-password-update.patch +RUN patch -u ${BASE_DIR}/lib/private/legacy/OC_Helper.php -i ${TMP_PATCH_DIR}/014-add-mail-usage.patch + +RUN rm -rf ${TMP_PATCH_DIR} + +# autocomplete leak tweak apps frontend with sed, disable group suggestion + +FROM selfhost as ecloud +ARG BASE_DIR="/usr/src/nextcloud" +ARG TMP_PATCH_DIR="/tmp/build_patches" + +COPY patches/ ${TMP_PATCH_DIR}/ +# Specific MurenaCloud Patches +RUN patch -u ${BASE_DIR}/core/templates/layout.user.php -i ${TMP_PATCH_DIR}/003-contact-search-removal.patch +RUN patch -u ${BASE_DIR}/core/Controller/ContactsMenuController.php -i ${TMP_PATCH_DIR}/004-contact-search-controller-removal.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-core.patch +RUN cd ${BASE_DIR}/custom_apps && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-custom-app.patch +RUN patch -u ${BASE_DIR}/lib/private/Updater.php -i ${TMP_PATCH_DIR}/010-disable-app-store-upgrade.patch +RUN cd ${BASE_DIR} && patch -u ${BASE_DIR}/apps/dashboard/lib/Controller/DashboardController.php -i ${TMP_PATCH_DIR}/012-remove-user-status-widget.patch + +RUN rm -rf ${TMP_PATCH_DIR} + +RUN cd ${BASE_DIR}/custom_apps/contacts && sed -i 's/"GROUP","INDIVIDUAL"/"INDIVIDUAL"/g' js/contacts-main.js +RUN cd ${BASE_DIR}/custom_apps/calendar && sed -i 's/"GROUP","INDIVIDUAL"/"INDIVIDUAL"/g' js/calendar-main.js +RUN cd ${BASE_DIR}/custom_apps/calendar && sed -i 's/{name:\[a,"displayname"\]},//' js/calendar-main.js + +# Set default widgets to calendar, tasks and notes +RUN sed -i 's/recommendations,spreed,mail,calendar/calendar,tasks,notes/' ${BASE_DIR}/apps/dashboard/lib/Controller/DashboardController.php -- GitLab From 7484397a2daa7928b97626a346bce8cedaeb0107 Mon Sep 17 00:00:00 2001 From: Akhil Date: Thu, 21 Jul 2022 16:21:53 +0530 Subject: [PATCH 2/4] Add selfhost CI/CD change --- .gitlab-ci.yml | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e9fa46e..684a4c39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,23 +10,56 @@ default: services: - docker:19.03.12-dind before_script: - - docker info - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY tags: - generic_privileged build-branch: - except: - - tags stage: build + variables: + TARGET: ecloud + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: never + - if: $CI_COMMIT_TAG != null + when: never + - if: $CI_COMMIT_REF_SLUG =~ /^selfhost/ + variables: + TARGET: "selfhost" + - if: $CI_COMMIT_REF_SLUG != null + when: on_success + allow_failure: true script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - echo "TARGET $TARGET, BRANCH $CI_COMMIT_BRANCH, COMMIT_REF_SLUG $CI_COMMIT_REF_SLUG, COMMIT_TAG $CI_COMMIT_TAG" + - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" build-tag: - only: - - tags stage: build + variables: + TARGET: ecloud + allow_failure: true + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: never + - if: $CI_COMMIT_TAG == null + when: never + - if: $CI_COMMIT_REF_SLUG =~ /^selfhost/ + variables: + TARGET: "selfhost" + - if: $CI_COMMIT_TAG != null + when: on_success script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" + - echo "TARGET $TARGET, BRANCH $CI_COMMIT_BRANCH, COMMIT_REF_SLUG $CI_COMMIT_REF_SLUG, COMMIT_TAG $CI_COMMIT_TAG" + - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + +docker-tag: + stage: .post + rules: + - when: manual + script: + - echo "SOURCE $SOURCE, TARGET $TARGET" + - docker pull $CI_REGISTRY_IMAGE:$SOURCE + - docker tag $CI_REGISTRY_IMAGE:$SOURCE $CI_REGISTRY_IMAGE:$TARGET + - docker push $CI_REGISTRY_IMAGE:$TARGET -- GitLab From 38ea61ffe60298e2da47062a9db32e7062bdccbc Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 21 Jul 2022 11:08:28 +0000 Subject: [PATCH 3/4] Update .gitlab-ci.yml --- .gitlab-ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 684a4c39..1f18b24b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,6 +18,7 @@ build-branch: stage: build variables: TARGET: ecloud + PATH: '' rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' when: never @@ -26,18 +27,20 @@ build-branch: - if: $CI_COMMIT_REF_SLUG =~ /^selfhost/ variables: TARGET: "selfhost" + PATH: "/selfhost" - if: $CI_COMMIT_REF_SLUG != null when: on_success allow_failure: true script: - echo "TARGET $TARGET, BRANCH $CI_COMMIT_BRANCH, COMMIT_REF_SLUG $CI_COMMIT_REF_SLUG, COMMIT_TAG $CI_COMMIT_TAG" - - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE$PATH:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE$PATH:$CI_COMMIT_REF_SLUG" build-tag: stage: build variables: TARGET: ecloud + PATH: '' allow_failure: true rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' @@ -47,12 +50,13 @@ build-tag: - if: $CI_COMMIT_REF_SLUG =~ /^selfhost/ variables: TARGET: "selfhost" + PATH: "/selfhost" - if: $CI_COMMIT_TAG != null when: on_success script: - echo "TARGET $TARGET, BRANCH $CI_COMMIT_BRANCH, COMMIT_REF_SLUG $CI_COMMIT_REF_SLUG, COMMIT_TAG $CI_COMMIT_TAG" - - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE$PATH:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE$PATH:$CI_COMMIT_REF_SLUG" docker-tag: stage: .post -- GitLab From 84bf96199b4b08601072362f4795764c43e46ad6 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 21 Jul 2022 11:10:44 +0000 Subject: [PATCH 4/4] Update .gitlab-ci.yml --- .gitlab-ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f18b24b..75dd630b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ build-branch: stage: build variables: TARGET: ecloud - PATH: '' + SUBPATH: '' rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' when: never @@ -27,20 +27,20 @@ build-branch: - if: $CI_COMMIT_REF_SLUG =~ /^selfhost/ variables: TARGET: "selfhost" - PATH: "/selfhost" + SUBPATH: "/selfhost" - if: $CI_COMMIT_REF_SLUG != null when: on_success allow_failure: true script: - echo "TARGET $TARGET, BRANCH $CI_COMMIT_BRANCH, COMMIT_REF_SLUG $CI_COMMIT_REF_SLUG, COMMIT_TAG $CI_COMMIT_TAG" - - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE$PATH:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE$PATH:$CI_COMMIT_REF_SLUG" + - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE$SUBPATH:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE$SUBPATH:$CI_COMMIT_REF_SLUG" build-tag: stage: build variables: TARGET: ecloud - PATH: '' + SUBPATH: '' allow_failure: true rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' @@ -50,13 +50,13 @@ build-tag: - if: $CI_COMMIT_REF_SLUG =~ /^selfhost/ variables: TARGET: "selfhost" - PATH: "/selfhost" + SUBPATH: "/selfhost" - if: $CI_COMMIT_TAG != null when: on_success script: - echo "TARGET $TARGET, BRANCH $CI_COMMIT_BRANCH, COMMIT_REF_SLUG $CI_COMMIT_REF_SLUG, COMMIT_TAG $CI_COMMIT_TAG" - - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE$PATH:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE$PATH:$CI_COMMIT_REF_SLUG" + - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE$SUBPATH:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE$SUBPATH:$CI_COMMIT_REF_SLUG" docker-tag: stage: .post -- GitLab