diff --git a/README.md b/README.md index 930ff26e8a0a82fc80e78d96d998feaab687e864..b247aeafe6142bb5daceb7def76f1e83eb7e9ef5 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,17 @@ The meta repository which helps you check out the other repositories and run a d - [Yarn](#yarn) - [pyenv](#pyenv) - [Ory](#ory) - - [Emulator](#emulator) - [Google Pub/Sub Emulator](#google-pubsub-emulator) - [OwnCloud Infinite Storage (OCIS)](#owncloud-infinite-storage-ocis) - [Jitsi Meet](#jitsi-meet) + - [Chat](#chat) - [Docker-Compose](#docker-compose) - [Deno](#deno) - [Initialization](#initialization) - [IDE setup](#ide-setup) + - [Last steps](#last-steps) - [Running dev environments via mprocs](#running-dev-environments-via-mprocs) - - [Local backend on Android](#local-backend-on-android) + - [Local backend on Android Emulator](#local-backend-on-android-emulator) - [TODO for Open Source contributions](#todo-for-open-source-contributions) - [Helper scripts](#helper-scripts) - [forall-git](#forall-git) diff --git a/init.sh b/init.sh index 572caca42296bbae5ed9fdde11332d0916c14aeb..3a6a51f8d70f75ba3960e22a10e02cbe60aa88f3 100755 --- a/init.sh +++ b/init.sh @@ -35,6 +35,7 @@ checkoutAndPrepare() { eval "$(direnv export bash)" # install git hooks via husky husky install + [ -x ./init.sh ] && ./init.sh popd } @@ -76,7 +77,6 @@ set -o pipefail ensureAvailable ory ensureAvailable docker ensureAvailable deno -ensureAvailable vr ensureAvailable brew ensureAvailable pyenv ensureAvailable ffmpeg # needed by okuna @@ -93,55 +93,16 @@ brewInstall gitleaks # check out and initialize the repositories checkoutAndPrepare git@gitlab.holi.team:app/holi-frontends.git holi-frontends -pushd holi-frontends -yarn install -popd - checkoutAndPrepare git@gitlab.holi.team:app/holi-okuna.git holi-okuna -pushd holi-okuna -# install the Python virtualenv -pyenv install -s "$(cat .python-version)" -pyenv local "$(cat .python-version)" -# we need to install some postgis libs for holi-okuna -brewInstall gdal -brewInstall proj -brewInstall geos [[ -f .envrc.local ]] || cp .envrc.local.template .envrc.local -if [[ -f /opt/homebrew/lib/libgdal.dylib && -f /opt/homebrew/lib/libgeos_c.dylib && -f /opt/homebrew/lib/libproj.dylib ]]; then - # MacOS - if ! grep -q "GDAL_LIBRARY_PATH" .envrc.local; then # LIBRARY_PATH variables are not yet set cat <<- EOF >> .envrc.local -export GDAL_LIBRARY_PATH=/opt/homebrew/lib/libgdal.dylib -export GEOS_LIBRARY_PATH=/opt/homebrew/lib/libgeos_c.dylib -export PROJ_LIBRARY_PATH=/opt/homebrew/lib/libproj.dylib -EOF - fi -elif [[ -f /home/linuxbrew/.linuxbrew/lib/libgdal.so && -f /home/linuxbrew/.linuxbrew/lib/libgeos_c.so && -f /home/linuxbrew/.linuxbrew/lib/libproj.so ]]; then - # Linux - if ! grep -q "GDAL_LIBRARY_PATH" .envrc.local; then # LIBRARY_PATH variables are not yet set cat <<- EOF >> .envrc.local -export GDAL_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib/libgdal.so -export GEOS_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib/libgeos_c.so -export PROJ_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib/libproj.so -# if not exported like this, system libs will be used as deps of brew libs -export LD_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib/:\$LD_LIBRARY_PATH -EOF - fi -else - fail "Could not determine how to include the libraries necessary for PostGIS. Please investigate in init.sh." -fi # now, reinitialize via direnv (first run in checkoutAndPrepare did not succeed due to missing python interpreter) direnv reload eval "$(direnv export bash)" -popd - checkoutAndPrepare git@gitlab.holi.team:app/holi-unified-api.git holi-unified-api -pushd holi-unified-api -yarn install -popd - checkoutAndPrepare git@gitlab.holi.team:app/holi-app-donations.git holi-app-donations checkoutAndPrepare git@gitlab.holi.team:app/holi-app-goodnews.git holi-app-goodnews checkoutAndPrepare git@gitlab.holi.team:app/holi-geo-api.git holi-geo-api @@ -149,11 +110,7 @@ checkoutAndPrepare git@gitlab.holi.team:app/holi-app-volunteering.git holi-app-v checkoutAndPrepare git@gitlab.holi.team:app/holi-chat-server.git holi-chat-server checkoutAndPrepare git@gitlab.holi.team:app/holi-ocis.git holi-ocis checkoutAndPrepare git@gitlab.holi.team:app/holi-meet.git holi-meet - checkoutAndPrepare git@gitlab.holi.team:app/holi-ocis-integration.git holi-ocis-integration -pushd holi-ocis-integration -yarn install -popd # these are technically not used in a local development environment, but they # make use of common definitions from holi-meta. If you want to check them out, @@ -165,10 +122,7 @@ fi # Install dependencies to run Google Pub/Sub locally pushd pubsub -# install the Python virtualenv -pyenv install -s "$(cat .python-version)" -pyenv local "$(cat .python-version)" -direnv allow . +[ -x ./init.sh ] && ./init.sh eval "$(direnv export bash)" popd diff --git a/mprocs-local-backend.yaml b/mprocs-local-backend.yaml index 5c472cbcd5a8a5996b02474770e04b3b913979bf..2f413be707e699e867f17d021ee0b8d367b98d1e 100644 --- a/mprocs-local-backend.yaml +++ b/mprocs-local-backend.yaml @@ -3,21 +3,17 @@ procs: cwd: <CONFIG_DIR>/holi-frontends env: DEV_ENV: local - shell: > - . ./.envrc.local; - yarn mobile:dev; + shell: ./mprocs-start-mobile.sh web: cwd: <CONFIG_DIR>/holi-frontends env: DEV_ENV: local - shell: > - . ./.envrc.local; - yarn web:dev; + shell: ./mprocs-start-web.sh storybook: cwd: <CONFIG_DIR>/holi-frontends shell: > if [ "$LOCAL_BACKEND_STORYBOOK" = "true" ]; then - yarn storybook:dev --no-open + ./mprocs-start-storybook.sh; else echo "Not starting local Storybook because LOCAL_BACKEND_STORYBOOK is not set to 'true'"; fi @@ -30,13 +26,7 @@ procs: fi pubsub-emulator: cwd: <CONFIG_DIR>/pubsub - shell: > - set -m; - gcloud beta emulators pubsub start --project=holi-dev --host-port=localhost:8085 & ../wait-for-port.sh 8085; - $(gcloud beta emulators pubsub env-init); - . .venv/bin/activate; pip3 install -r requirements.txt; - python3 init.py; - fg; + shell: ./mprocs-start.sh stop: send-keys: - <C-c> @@ -45,10 +35,7 @@ procs: cwd: <CONFIG_DIR>/holi-ocis-integration shell: > if [ "$LOCAL_BACKEND_OCIS" = "true" ]; then - . ./.envrc.local; - ./start-ocis-integration-local.sh; - yarn build; - yarn start:dev; + ./mprocs-start.sh; else echo "Not starting local ocis subscriber because LOCAL_BACKEND_OCIS is not set to 'true'"; fi; @@ -58,41 +45,20 @@ procs: - <C-c> oathkeeper: cwd: <CONFIG_DIR>/holi-unified-api/oathkeeper - shell: > - docker run \ - --rm \ - --name ory-oathkeeper-unified-api \ - -p 0.0.0.0:4455:4455 \ - -p 0.0.0.0:4456:4456 \ - --env-file=.env.local \ - --mount type=bind,source=$PWD,target=/opt/oathkeeper/ \ - --add-host=host.docker.internal:host-gateway \ - oryd/oathkeeper:v0.40.3 --config /opt/oathkeeper/config.yaml serve; + shell: ../mprocs-start-oathkeeper.sh stop: send-keys: - <C-c> - <C-c> unified-api: cwd: <CONFIG_DIR>/holi-unified-api - shell: > - . ../.envrc.local.backends; - . ./.envrc.local; - [ "$LOCAL_BACKEND_CHAT" = "true" ] && ../wait-for-port.sh 8008; - [ "$LOCAL_BACKEND_OKUNA" = "true" ] && ../wait-for-port.sh 8000; - ../wait-for-port.sh 8001; - ../wait-for-port.sh 8002; - [ "$LOCAL_BACKEND_GEOAPI" = "true" ] && ../wait-for-port.sh 8003; - ../wait-for-port.sh 8004; - yarn mesh build; - cp logger.ts .mesh/; - yarn serve; + shell: ./mprocs-start.sh okuna-services: cwd: <CONFIG_DIR>/holi-okuna shell: > . ../.envrc.local.backends; if [ "$LOCAL_BACKEND_OKUNA" = "true" ]; then - pip3 install -r requirements-cli-only.txt; - python3 okuna-cli.py up-services-only; + ./mprocs-start-services.sh; else echo "Not starting local okuna because LOCAL_BACKEND_OKUNA is not set to 'true'"; fi; @@ -106,19 +72,7 @@ procs: shell: > . ../.envrc.local.backends; if [ "$LOCAL_BACKEND_OKUNA" = "true" ]; then - echo "waiting for services"; - until docker ps|grep okuna-redis; do - sleep 1; - echo -n .; - done - . .venv/bin/activate; - pip3 install -r requirements.txt; - . ./.envrc.local; - ../wait-for-port.sh 8085; - $(gcloud beta emulators pubsub env-init); - python3 manage.py migrate; - python3 manage.py collectstatic --no-input; - python3 start_server.py --reload || echo 'maybe you need to execute "python manage.py migrate" again?'; + ./mprocs-start.sh; else echo "Not starting local okuna because LOCAL_BACKEND_OKUNA is not set to 'true'"; fi; @@ -128,10 +82,10 @@ procs: . ../.envrc.local.backends; vr install; if [ "$LOCAL_BACKEND_DONATIONS" = "true" ]; then - vr dev; + ./mprocs-start.sh; else echo starting fake; - FAKE="true" vr dev; + FAKE="true" ./mprocs-start.sh; fi; geo-api: cwd: <CONFIG_DIR>/holi-geo-api @@ -140,10 +94,10 @@ procs: . ./.envrc.local; vr install; if [ "$LOCAL_BACKEND_GEOAPI" = "true" ]; then - vr dev; + ./mprocs-start.sh; else echo starting fake; - FAKE="true" vr dev; + FAKE="true" ./mprocs-start.sh; fi; goodnews-api: cwd: <CONFIG_DIR>/holi-app-goodnews @@ -152,10 +106,10 @@ procs: . ./.envrc.local; vr install; if [ "$LOCAL_BACKEND_GOODNEWS" = "true" ]; then - vr dev; + ./mprocs-start.sh; else echo starting fake; - FAKE="true" vr dev; + FAKE="true" ./mprocs-start.sh; fi; volunteering-api: cwd: <CONFIG_DIR>/holi-app-volunteering @@ -164,17 +118,16 @@ procs: . ./.envrc.local; vr install; if [ "$LOCAL_BACKEND_VOLUNTEERING" = "true" ]; then - vr dev; + ./mprocs-start.sh; else echo starting fake; - FAKE="true" vr dev; + FAKE="true" ./mprocs-start.sh; fi; ocis: cwd: <CONFIG_DIR>/holi-ocis shell: > if [ "$LOCAL_BACKEND_OCIS" = "true" ]; then - docker compose rm -f; - docker compose up; + ./mprocs-start.sh; else echo "Not starting local ocis because LOCAL_BACKEND_OCIS is not set to 'true'"; fi; @@ -187,12 +140,7 @@ procs: shell: > . ../.envrc.local.backends; if [ "$LOCAL_BACKEND_CHAT" = "true" ]; then - . ./.envrc.local; - ./generate-homeserver-config.sh; - . ./.envrc-push-gateway.local; - ./generate-push-gateway-config.sh; - docker compose rm -f; - docker compose up; + ./mprocs-start.sh; else echo "Not starting local chat because LOCAL_BACKEND_CHAT is not set to 'true'"; fi; diff --git a/pubsub/init.sh b/pubsub/init.sh new file mode 100755 index 0000000000000000000000000000000000000000..33821c6f4df17b64403aa7b7b02956ed89b86ba0 --- /dev/null +++ b/pubsub/init.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# This file contains any project specific shell commands that are needed to set up a working local dev environment +# for this project. It is used by the overall init.sh script in https://gitlab.holi.team/app/holi-meta + +# install the Python virtualenv +pyenv install -s "$(cat .python-version)" +pyenv local "$(cat .python-version)" +direnv allow . diff --git a/pubsub/mprocs-start.sh b/pubsub/mprocs-start.sh new file mode 100755 index 0000000000000000000000000000000000000000..8487da919008e1df38d1f2a272eb0b476aab6f69 --- /dev/null +++ b/pubsub/mprocs-start.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# This file is used by the mprocs yaml files in https://gitlab.holi.team/app/holi-meta + +set -m +gcloud beta emulators pubsub start --project=holi-dev --host-port=localhost:8085 & ../wait-for-port.sh 8085 +eval "$(gcloud beta emulators pubsub env-init)" +. .venv/bin/activate; pip3 install -r requirements.txt +python3 init.py +fg diff --git a/wait-for-port.sh b/wait-for-port.sh index 2c00b726cde531523290880c65cbd2393375ef75..c3de388f5893fc16c3214adfae9e4c18728661e0 100755 --- a/wait-for-port.sh +++ b/wait-for-port.sh @@ -2,9 +2,17 @@ PORT=$1 +if ! command -v nc &>/dev/null; then + echo "Error: netcat (nc) is not installed. Please install it to use this script." + exit 1 +fi + echo -n "Waiting for port ${PORT} to be open ..."; for _ in $(seq 1 60); do - nc -w 1 -z localhost "${PORT}" 2>/dev/null && echo "" && exit + if nc -w 1 -z localhost "${PORT}" 2>/dev/null ; then + echo "" + exit + fi sleep 1 echo -n "." done