Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53a5fa4f authored by Nivesh Krishna's avatar Nivesh Krishna
Browse files

Merge branch 'selfhost-21' into 'nc-21'

Selfhost 21

See merge request !112
parents aff07651 5f8e3650
Loading
Loading
Loading
Loading
Loading
+46 −9
Original line number Diff line number Diff line
@@ -10,23 +10,60 @@ 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
    SUBPATH: ''
  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"
        SUBPATH: "/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" .
    - docker push "$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$SUBPATH:$CI_COMMIT_REF_SLUG" .
    - docker push "$CI_REGISTRY_IMAGE$SUBPATH:$CI_COMMIT_REF_SLUG"

build-tag:
  only:
    - tags
  stage: build
  variables:
    TARGET: ecloud
    SUBPATH: ''
  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"
        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$SUBPATH:$CI_COMMIT_REF_SLUG" .
    - docker push "$CI_REGISTRY_IMAGE$SUBPATH:$CI_COMMIT_REF_SLUG"

docker-tag:
  stage: .post
  rules:
    - when: manual
  script:
    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" .
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
    - 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
+54 −40
Original line number Diff line number Diff line
@@ -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\/<?php p(\$_\[\x27language\x27\]); ?>\/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