From 17092d8e73c0349b48b00df0505b2b721442f1c2 Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Wed, 31 Jul 2024 09:37:01 +0000 Subject: [PATCH] init gitpod --- .gitpod.yml | 37 ++++++++++++++++ gitpod/docker-compose.yml | 61 +++++++++++++++++++++++++++ gitpod/nextcloud/Dockerfile | 15 +++++++ gitpod/nextcloud/after-install.sh | 37 ++++++++++++++++ gitpod/nextcloud/custom-entrypoint.sh | 8 ++++ gitpod/reset.sh | 5 +++ 6 files changed, 163 insertions(+) create mode 100644 .gitpod.yml create mode 100644 gitpod/docker-compose.yml create mode 100644 gitpod/nextcloud/Dockerfile create mode 100644 gitpod/nextcloud/after-install.sh create mode 100644 gitpod/nextcloud/custom-entrypoint.sh create mode 100644 gitpod/reset.sh diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..cc18113 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,37 @@ + +tasks: + - name: Nextcloud Server + init: | + cd gitpod + git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/nextcloud/server.git server + docker-compose up --no-start + command: | + git config core.fileMode false + # Both gitpod and Nextcloud need read/write acess + # Obviously not recommended for a production system + sudo chown -R www-data:www-data ${GITPOD_REPO_ROOT} + sudo chmod -R 777 ${GITPOD_REPO_ROOT} + cd gitpod + docker-compose up + + - name: Dependency install & Frontend watch + init: make dev-setup + command: make watch-js + + - name: Terminal + command: clear + +ports: + - port: 8080 + onOpen: notify + visibility: private + - port: 8081 + visibility: private + onOpen: ignore + +vscode: + extensions: + - Vue.volar + - dbaeumer.vscode-eslint + - ms-azuretools.vscode-docker + - zobo.php-intellisense \ No newline at end of file diff --git a/gitpod/docker-compose.yml b/gitpod/docker-compose.yml new file mode 100644 index 0000000..36a8e0b --- /dev/null +++ b/gitpod/docker-compose.yml @@ -0,0 +1,61 @@ +# This is for gitpod, DO NOT USE THIS TO HOST YOUR PRODUCTION NEXTCLOUD + +version: '2' + +volumes: + nextcloud: + db: + config: + +services: + db: + image: mariadb + restart: always + command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb_read_only_compressed=OFF + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=wdGq73jQB0p373gLdf6yLRj5 + - MYSQL_PASSWORD=wdGq73jQB0p373gLdf6yLRj5 + - MYSQL_DATABASE=nextcloud + - MYSQL_USER=nextcloud + + phpmyadmin: + image: phpmyadmin + container_name: phpmyadmin + links: + - db + volumes: + - /phpmyadminapache2logs/:/var/log/apache2/ + environment: + PMA_HOST: db + PMA_PORT: 3306 + restart: always + ports: + - 8081:80 + + app: + image: 'local/nextcloud' + build: + context: ./nextcloud + dockerfile: Dockerfile + restart: always + ports: + - 8080:80 + links: + - db + volumes: + - nextcloud:/var/www/html + - config:/var/www/html/config + - /workspace/groupfolder_tags/:/var/www/html/custom_apps/groupfolder_tags/ + - /apache2logs/:/var/log/apache2/ + environment: + - MYSQL_PASSWORD=wdGq73jQB0p373gLdf6yLRj5 + - MYSQL_DATABASE=nextcloud + - MYSQL_USER=nextcloud + - MYSQL_HOST=db + - NEXTCLOUD_ADMIN_USER=dev + - NEXTCLOUD_ADMIN_PASSWORD=t2qQ1C6ktYUv7 + - NEXTCLOUD_TRUSTED_DOMAINS=*.gitpod.io + - OVERWRITEPROTOCOL=https + - NEXTCLOUD_UPDATE=1 diff --git a/gitpod/nextcloud/Dockerfile b/gitpod/nextcloud/Dockerfile new file mode 100644 index 0000000..00e12d4 --- /dev/null +++ b/gitpod/nextcloud/Dockerfile @@ -0,0 +1,15 @@ +FROM nextcloud + +RUN apt-get update && apt-get install -y --no-install-recommends jq + +COPY custom-entrypoint.sh /custom-entrypoint.sh +COPY after-install.sh /after-install.sh + +RUN chmod +x /custom-entrypoint.sh +RUN chmod +x /after-install.sh + +RUN echo "opcache.revalidate_freq=0" > /usr/local/etc/php/conf.d/z-gitpod.ini + +ENTRYPOINT ["/custom-entrypoint.sh"] + +CMD ["/after-install.sh"] \ No newline at end of file diff --git a/gitpod/nextcloud/after-install.sh b/gitpod/nextcloud/after-install.sh new file mode 100644 index 0000000..4274be3 --- /dev/null +++ b/gitpod/nextcloud/after-install.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +is_installed() { + echo "$(run_as 'php /var/www/html/occ status --output=json' | jq '.installed')" +} + +wait_until_finished() { + until [[ $(is_installed) == "true" ]]; do + echo "waiting for nextcloud to initialize, so groupfolder_tags can be activated" + run_as "php /var/www/html/occ status --output=json" + sleep 5 + done +} + +echo "$(is_installed)" + +wait_until_finished + +run_as "php /var/www/html/occ config:system:set debug --value='true' --type=boolean" + +run_as "php /var/www/html/occ app:enable groupfolder_tags" + +run_as "php /var/www/html/occ migrations:migrate groupfolder_tags" + +run_as "php /var/www/html/occ app:disable firstrunwizard" + +run_as "php /var/www/html/occ config:system:set defaultapp --value='groupfolder_tags'" + +apache2-foreground \ No newline at end of file diff --git a/gitpod/nextcloud/custom-entrypoint.sh b/gitpod/nextcloud/custom-entrypoint.sh new file mode 100644 index 0000000..a26ec9f --- /dev/null +++ b/gitpod/nextcloud/custom-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Both gitpod and Nextcloud need read/write acess +# Obviously not recommended for a production system +chown -R www-data:www-data /var/www/html/custom_apps/ +chmod -R 777 /var/www/html/custom_apps/ + +/entrypoint.sh "$@" \ No newline at end of file diff --git a/gitpod/reset.sh b/gitpod/reset.sh new file mode 100644 index 0000000..3dc2f8a --- /dev/null +++ b/gitpod/reset.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +docker-compose down +docker volume rm gitpod_config gitpod_db gitpod_nextcloud +docker-compose up --force-recreate --build \ No newline at end of file