From f868037b55bed370700c616c2aa78a524f33d900 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Fri, 20 Sep 2024 03:56:48 +0200 Subject: [PATCH 01/34] fix: correct proxy pass from reconi to rekoni --- nginx/huly.nginx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nginx/huly.nginx b/nginx/huly.nginx index 58cd22b..1c924dd 100644 --- a/nginx/huly.nginx +++ b/nginx/huly.nginx @@ -57,13 +57,13 @@ server { proxy_pass http://transactor:3333; } - location /_reconi { + location /_rekoni { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - rewrite ^/_reconi(/.*)$ $1 break; - proxy_pass http://reconi:4004/; + rewrite ^/_rekoni(/.*)$ $1 break; + proxy_pass http://rekoni:4004/; } } \ No newline at end of file From 45254c0e9c3628e9fc80ae47271570af88b831c1 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Fri, 20 Sep 2024 05:47:48 +0200 Subject: [PATCH 02/34] feat: prompt to run docker compose --- nginx/setup.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nginx/setup.sh b/nginx/setup.sh index 49ac701..39f1cf0 100755 --- a/nginx/setup.sh +++ b/nginx/setup.sh @@ -1,6 +1,5 @@ #!/bin/bash -# Ask for the domain name read -p "Enter the domain name: " DOMAIN_NAME if [ -z "$DOMAIN_NAME" ]; then echo "DOMAIN_NAME is required" @@ -42,5 +41,18 @@ export HULY_SECRET="c37fef1f157efe09785844215225ee3d1ab8086eb822055d5aa1bdedc729 # replace the domain name and email address in the docker-compose file envsubst < template-compose.yml > docker-compose.yml -echo -e "\033[1;32mSetup is complete. Run 'docker compose up -d' to start the services.\033[0m" +echo -e "\033[1;32mSetup is complete!\033[0m" +read -p "Do you want to run 'docker compose up -d' now to spin up Huly? ([Y]es/[n]o): " RUN_DOCKER +case "${RUN_DOCKER,,}" in + y|yes|"" ) + echo -e "\033[1;32mRunning 'docker compose up -d' now...\033[0m" + docker compose up -d + ;; + n|no ) + echo "You can run 'docker compose up -d' later to start the services." + ;; + * ) + echo "Invalid input. You can run 'docker compose up -d' later to start the services." + ;; +esac \ No newline at end of file From 7b9575499aba3bd7e24ce1815147ab004fc2bfb0 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Fri, 20 Sep 2024 06:11:23 +0200 Subject: [PATCH 03/34] fix: specify project name --- nginx/{template-compose.yml => template.compose.yml} | 1 + 1 file changed, 1 insertion(+) rename nginx/{template-compose.yml => template.compose.yml} (99%) diff --git a/nginx/template-compose.yml b/nginx/template.compose.yml similarity index 99% rename from nginx/template-compose.yml rename to nginx/template.compose.yml index 4f24da3..7810b32 100644 --- a/nginx/template-compose.yml +++ b/nginx/template.compose.yml @@ -1,3 +1,4 @@ +project_name: huly services: nginx: image: "nginx:1.21.3" From b0f84444dc55ede5cf09ade9246cce157735365f Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Fri, 20 Sep 2024 06:12:08 +0200 Subject: [PATCH 04/34] fix: remove container name --- nginx/template.compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/nginx/template.compose.yml b/nginx/template.compose.yml index 7810b32..e402de2 100644 --- a/nginx/template.compose.yml +++ b/nginx/template.compose.yml @@ -13,7 +13,6 @@ services: mongodb: image: "mongo:7-jammy" - container_name: mongodb environment: - PUID=1000 - PGID=1000 From 32149bb5a5348d35c515b686917ad13981e39e05 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Fri, 20 Sep 2024 11:34:04 +0700 Subject: [PATCH 05/34] fix: update nginx configuration to huly v0.6.295 Signed-off-by: Alexander Onnikov --- .gitignore | 6 +- nginx/docker-compose.yml | 169 ------------ nginx/huly.nginx | 6 +- nginx/setup.sh | 11 +- ...late-compose.yml => template-compose.yaml} | 48 ++-- setup.sh | 5 +- template.compose.yaml | 14 +- template.conf | 2 +- traefik/README.md | 2 +- traefik/docker-compose.yml | 242 ------------------ ...late-compose.yml => template-compose.yaml} | 0 11 files changed, 50 insertions(+), 455 deletions(-) delete mode 100644 nginx/docker-compose.yml rename nginx/{template-compose.yml => template-compose.yaml} (75%) delete mode 100644 traefik/docker-compose.yml rename traefik/{template-compose.yml => template-compose.yaml} (100%) diff --git a/.gitignore b/.gitignore index 01d90e8..e20f53b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -letsencrypt/ \ No newline at end of file +letsencrypt/ +nginx/docker-compose.yaml +traefik/docker-compose.yaml +compose.yaml +nginx.conf \ No newline at end of file diff --git a/nginx/docker-compose.yml b/nginx/docker-compose.yml deleted file mode 100644 index 7d5c98d..0000000 --- a/nginx/docker-compose.yml +++ /dev/null @@ -1,169 +0,0 @@ -services: - nginx: - image: "nginx:1.21.3" - ports: - - "8080:80" - volumes: - - ./huly.nginx:/etc/nginx/conf.d/default.conf - restart: unless-stopped - networks: - - internal-services - - nginx-public - - mongodb: - image: "mongo:7-jammy" - container_name: mongodb - environment: - - PUID=1000 - - PGID=1000 - volumes: - - db:/data/db - restart: unless-stopped - networks: - - internal-services - - elastic: - image: "elasticsearch:7.14.2" - command: | - /bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment || yes | ./bin/elasticsearch-plugin install --silent ingest-attachment; - /usr/local/bin/docker-entrypoint.sh eswrapper" - volumes: - - elastic:/usr/share/elasticsearch/data - environment: - - ELASTICSEARCH_PORT_NUMBER=9200 - - BITNAMI_DEBUG=true - - discovery.type=single-node - - ES_JAVA_OPTS=-Xms1024m -Xmx1024m - - http.cors.enabled=true - - http.cors.allow-origin=http://localhost:8082 - healthcheck: - interval: 20s - retries: 10 - test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' - restart: unless-stopped - networks: - - internal-services - - minio: - image: "minio/minio" - command: server /data --address ":9000" --console-address ":9001" - volumes: - - files:/data - restart: unless-stopped - networks: - - internal-services - - rekoni: - image: hardcoreeng/rekoni-service:v0.6.245 - environment: - - SECRET=c37fef1f157efe09785844215225ee3d1ab8086eb822055d5aa1bdedc72921bd - deploy: - resources: - limits: - memory: 500M - restart: unless-stopped - networks: - - internal-services - - nginx-public - - transactor: - image: hardcoreeng/transactor:v0.6.245 - environment: - - SERVER_PORT=3333 - - SERVER_SECRET=c37fef1f157efe09785844215225ee3d1ab8086eb822055d5aa1bdedc72921bd - - SERVER_CURSOR_MAXTIMEMS=30000 - - ELASTIC_URL=http://elastic:9200 - - ELASTIC_INDEX_NAME=huly_storage_index - - MONGO_URL=mongodb://mongodb:27017 - - METRICS_CONSOLE=false - - METRICS_FILE=metrics.txt - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - - REKONI_URL=http://rekoni:4004 - - FRONT_URL=http://localhost:8087 - - SERVER_PROVIDER=wss - - ACCOUNTS_URL=http://account:3000 - - LAST_NAME_FIRST=true - - UPLOAD_URL=https://example.com/files - restart: unless-stopped - networks: - - internal-services - - nginx-public - - - collaborator: - image: hardcoreeng/collaborator:v0.6.245 - environment: - - COLLABORATOR_PORT=3078 - - SECRET=c37fef1f157efe09785844215225ee3d1ab8086eb822055d5aa1bdedc72921bd - - ACCOUNTS_URL=http://account:3000 - - TRANSACTOR_URL=ws://transactor:3333 - - UPLOAD_URL=/files - - MONGO_URL=mongodb://mongodb:27017 - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - restart: unless-stopped - networks: - - internal-services - - nginx-public - - account: - image: hardcoreeng/account:v0.6.245 - environment: - - SERVER_PORT=3000 - - SERVER_SECRET=c37fef1f157efe09785844215225ee3d1ab8086eb822055d5aa1bdedc72921bd - - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333 - - ENDPOINT_URL=${wss}://example.com/_transactor # this is the transactor endpoint - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - - FRONT_URL=http://front:8080 - - INIT_WORKSPACE=demo-tracker - - MODEL_ENABLED=* - - ACCOUNTS_URL=http://localhost:3000 - - ACCOUNT_PORT=3000 - restart: unless-stopped - networks: - - internal-services - - nginx-public - - front: - image: hardcoreeng/front:v0.6.245 - environment: - - SERVER_PORT=8080 - - SERVER_SECRET=c37fef1f157efe09785844215225ee3d1ab8086eb822055d5aa1bdedc72921bd - - ACCOUNTS_URL=https://example.com/_accounts - - REKONI_URL=https://example.com/_rekoni - - CALENDAR_URL=https://example.com:8095 - - GMAIL_URL=https://example.com:8088 - - TELEGRAM_URL=https://example.com:8086 - - UPLOAD_URL=/files - - TRANSACTOR_URL=${wss}://example.com/_transactor - - ELASTIC_URL=http://elastic:9200 - - COLLABORATOR_URL=${wss}://example.com/_collaborator - - COLLABORATOR_API_URL=https://example.com/_collaborator - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - - MONGO_URL=mongodb://mongodb:27017 - - TITLE=Huly Self Host - - DEFAULT_LANGUAGE=en - - LAST_NAME_FIRST=true - restart: unless-stopped - networks: - - internal-services - - nginx-public - -networks: - nginx-public: - name: nginx-public - internal-services: - name: internal-services - -volumes: - db: - elastic: - files: \ No newline at end of file diff --git a/nginx/huly.nginx b/nginx/huly.nginx index 58cd22b..1c924dd 100644 --- a/nginx/huly.nginx +++ b/nginx/huly.nginx @@ -57,13 +57,13 @@ server { proxy_pass http://transactor:3333; } - location /_reconi { + location /_rekoni { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - rewrite ^/_reconi(/.*)$ $1 break; - proxy_pass http://reconi:4004/; + rewrite ^/_rekoni(/.*)$ $1 break; + proxy_pass http://rekoni:4004/; } } \ No newline at end of file diff --git a/nginx/setup.sh b/nginx/setup.sh index 49ac701..502e64d 100755 --- a/nginx/setup.sh +++ b/nginx/setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Ask for the domain name read -p "Enter the domain name: " DOMAIN_NAME @@ -31,16 +31,17 @@ case "$NGINX_BEHIND_SSL" in esac -export HULY_VERSION="v0.6.245" -export SERVER_ADDRESS=$DOMAIN_NAME +export HULY_VERSION="v0.6.295" export NGINX_SERVICE_PORT=$NGINX_SERVICE_PORT export NGINX_HTTP_SCHEME=$NGINX_HTTP_SCHEME export NGINX_WS_SCHEME=$NGINX_WS_SCHEME +export SERVER_ADDRESS="${DOMAIN_NAME}:${NGINX_SERVICE_PORT}" + # $(openssl rand -hex 32) -export HULY_SECRET="c37fef1f157efe09785844215225ee3d1ab8086eb822055d5aa1bdedc72921bd" +export HULY_SECRET="secret" # replace the domain name and email address in the docker-compose file -envsubst < template-compose.yml > docker-compose.yml +envsubst < template-compose.yaml > docker-compose.yaml echo -e "\033[1;32mSetup is complete. Run 'docker compose up -d' to start the services.\033[0m" diff --git a/nginx/template-compose.yml b/nginx/template-compose.yaml similarity index 75% rename from nginx/template-compose.yml rename to nginx/template-compose.yaml index 4f24da3..7be25ce 100644 --- a/nginx/template-compose.yml +++ b/nginx/template-compose.yaml @@ -77,12 +77,9 @@ services: - MONGO_URL=mongodb://mongodb:27017 - METRICS_CONSOLE=false - METRICS_FILE=metrics.txt - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin + - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - REKONI_URL=http://rekoni:4004 - FRONT_URL=http://localhost:8087 - - SERVER_PROVIDER=wss - ACCOUNTS_URL=http://account:3000 - LAST_NAME_FIRST=true - UPLOAD_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/files @@ -98,12 +95,8 @@ services: - COLLABORATOR_PORT=3078 - SECRET=${HULY_SECRET} - ACCOUNTS_URL=http://account:3000 - - TRANSACTOR_URL=ws://transactor:3333 - - UPLOAD_URL=/files - MONGO_URL=mongodb://mongodb:27017 - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin + - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin restart: unless-stopped networks: - internal-services @@ -115,13 +108,9 @@ services: - SERVER_PORT=3000 - SERVER_SECRET=${HULY_SECRET} - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333 - - ENDPOINT_URL=${$NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor # this is the transactor endpoint - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin + - TRANSACTOR_URL=ws://transactor:3333;${NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor + - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - FRONT_URL=http://front:8080 - - INIT_WORKSPACE=demo-tracker - MODEL_ENABLED=* - ACCOUNTS_URL=http://localhost:3000 - ACCOUNT_PORT=3000 @@ -130,6 +119,21 @@ services: - internal-services - nginx-public + workspace: + image: hardcoreeng/workspace:${HULY_VERSION} + environment: + - SERVER_SECRET=${HULY_SECRET} + - MONGO_URL=mongodb://mongodb:27017 + - TRANSACTOR_URL=ws://transactor:3333;${NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor + - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin + - MODEL_ENABLED=* + - ACCOUNTS_URL=http://account:3000 + - NOTIFY_INBOX_ONLY=true + restart: unless-stopped + networks: + - internal-services + - nginx-public + front: image: hardcoreeng/front:${HULY_VERSION} environment: @@ -137,17 +141,13 @@ services: - SERVER_SECRET=${HULY_SECRET} - ACCOUNTS_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_accounts - REKONI_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_rekoni - - CALENDAR_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}:8095 - - GMAIL_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}:8088 - - TELEGRAM_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}:8086 + - CALENDAR_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_calendar + - GMAIL_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_gmail + - TELEGRAM_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_telegram - UPLOAD_URL=/files - - TRANSACTOR_URL=${$NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor - ELASTIC_URL=http://elastic:9200 - - COLLABORATOR_URL=${$NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_collaborator - - COLLABORATOR_API_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_collaborator - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin + - COLLABORATOR_URL=${NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_collaborator + - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - MONGO_URL=mongodb://mongodb:27017 - TITLE=Huly Self Host - DEFAULT_LANGUAGE=en diff --git a/setup.sh b/setup.sh index 1f42cda..8d2e5a0 100755 --- a/setup.sh +++ b/setup.sh @@ -1,5 +1,8 @@ -#!/bin/sh +#!/usr/bin/env bash + export SERVER_ADDRESS="$1" +export HULY_SECRET="secret" + echo "Setting Huly Server Address: $SERVER_ADDRESS" envsubst < template.conf > nginx.conf envsubst < template.env > .env diff --git a/template.compose.yaml b/template.compose.yaml index babe3e4..e14c65a 100644 --- a/template.compose.yaml +++ b/template.compose.yaml @@ -50,7 +50,7 @@ services: - 3000:3000 environment: - SERVER_PORT=3000 - - SERVER_SECRET=secret + - SERVER_SECRET=${HULY_SECRET} - MONGO_URL=mongodb://mongodb:27017 - TRANSACTOR_URL=ws://transactor:3333;ws://${SERVER_ADDRESS}:3333 - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin @@ -65,7 +65,7 @@ services: - mongodb - minio environment: - - SERVER_SECRET=secret + - SERVER_SECRET=${HULY_SECRET} - MONGO_URL=mongodb://mongodb:27017 - TRANSACTOR_URL=ws://transactor:3333;ws://${SERVER_ADDRESS}:3333 - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin @@ -85,7 +85,7 @@ services: - 8087:8080 environment: - SERVER_PORT=8080 - - SERVER_SECRET=secret + - SERVER_SECRET=${HULY_SECRET} - ACCOUNTS_URL=http://${SERVER_ADDRESS}:3000 - REKONI_URL=http://${SERVER_ADDRESS}:4004 - CALENDAR_URL=http://${SERVER_ADDRESS}:8095 @@ -110,7 +110,7 @@ services: - 3078:3078 environment: - COLLABORATOR_PORT=3078 - - SECRET=secret + - SECRET=${HULY_SECRET} - ACCOUNTS_URL=http://account:3000 - MONGO_URL=mongodb://mongodb:27017 - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin @@ -121,13 +121,12 @@ services: - mongodb - elastic - minio - - rekoni - account ports: - 3333:3333 environment: - SERVER_PORT=3333 - - SERVER_SECRET=secret + - SERVER_SECRET=${HULY_SECRET} - SERVER_CURSOR_MAXTIMEMS=30000 - ELASTIC_URL=http://elastic:9200 - ELASTIC_INDEX_NAME=huly_storage_index @@ -137,7 +136,6 @@ services: - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - REKONI_URL=http://rekoni:4004 - FRONT_URL=http://${SERVER_ADDRESS}:8087 - - SERVER_PROVIDER=ws - ACCOUNTS_URL=http://account:3000 - LAST_NAME_FIRST=true restart: unless-stopped @@ -146,7 +144,7 @@ services: ports: - 4004:4004 environment: - - SECRET=secret + - SECRET=${HULY_SECRET} deploy: resources: limits: diff --git a/template.conf b/template.conf index 471781c..a1a5fd6 100644 --- a/template.conf +++ b/template.conf @@ -3,7 +3,7 @@ server { listen [::]:80; server_name ${SERVER_ADDRESS}; - + location / { proxy_pass http://localhost:8087; include proxy_params; diff --git a/traefik/README.md b/traefik/README.md index 5a950c7..55d257a 100644 --- a/traefik/README.md +++ b/traefik/README.md @@ -30,7 +30,7 @@ Setup is complete. Run 'docker compose up -d' to start the services. ``` -4. Modify the `docker-compose.yml` file to customize any settings +4. Modify the `docker-compose.yaml` file to customize any settings 5. Start the services diff --git a/traefik/docker-compose.yml b/traefik/docker-compose.yml deleted file mode 100644 index dc96f8b..0000000 --- a/traefik/docker-compose.yml +++ /dev/null @@ -1,242 +0,0 @@ -services: - traefik: - restart: unless-stopped - image: "traefik:v2.10" - container_name: "traefik" - ports: - - "80:80" - - "443:443" - - "3333:3333" - - "3078:3078" - volumes: - - "/var/run/docker.sock:/var/run/docker.sock:ro" - - ./letsencrypt:/letsencrypt - networks: - - traefik-public - command: - - "--log.level=DEBUG" # set to INFO for production - - "--api.insecure=false" - - "--api.dashboard=true" - - "--global.sendAnonymousUsage=false" - - "--global.checkNewVersion=false" - - "--providers.docker=true" - - "--providers.docker.exposedbydefault=false" - - "--providers.docker.network=traefik-public" - - "--entrypoints.web.address=:80" - - "--entrypoints.websecure.address=:443" - - "--entrypoints.transactor.address=:3333" # for transactor wss - - "--entrypoints.collaborator.address=:3078" # for collaborator wss - - "--entrypoints.web.http.redirections.entryPoint.to=websecure" - - "--entrypoints.web.http.redirections.entryPoint.scheme=https" - - "--certificatesresolvers.myresolver.acme.email=admin@example.com" - - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json" - - "--certificatesresolvers.myresolver.acme.tlschallenge=true" - - "--certificatesresolvers.myresolver.acme.caserver=http://acme-staging-v02.api.letsencrypt.org/directory" # For testing, comment out for production - labels: - - "traefik.enable=true" - - "traefik.http.routers.traefik.rule=Host(`example.com`) && (PathPrefix(`/api`) || PathPrefix(`/traefik`))" - - "traefik.http.routers.traefik.service=api@internal" - - "traefik.http.routers.traefik.entrypoints=websecure" - # strip prefix for traefik dashboard - - "traefik.http.routers.traefik.middlewares=strip-prefix-traefik" - - "traefik.http.middlewares.strip-prefix-traefik.stripprefix.prefixes=/traefik" - - "traefik.http.routers.traefik.tls=true" - - "traefik.http.routers.traefik.tls.certresolver=myresolver" - - mongodb: - image: "mongo:7-jammy" - container_name: mongodb - environment: - - PUID=1000 - - PGID=1000 - volumes: - - db:/data/db - restart: unless-stopped - networks: - - internal-services - - elastic: - image: "elasticsearch:7.14.2" - command: | - /bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment || yes | ./bin/elasticsearch-plugin install --silent ingest-attachment; - /usr/local/bin/docker-entrypoint.sh eswrapper" - volumes: - - elastic:/usr/share/elasticsearch/data - environment: - - ELASTICSEARCH_PORT_NUMBER=9200 - - BITNAMI_DEBUG=true - - discovery.type=single-node - - ES_JAVA_OPTS=-Xms1024m -Xmx1024m - - http.cors.enabled=true - - http.cors.allow-origin=http://localhost:8082 - healthcheck: - interval: 20s - retries: 10 - test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' - restart: unless-stopped - networks: - - internal-services - - minio: - image: "minio/minio" - command: server /data --address ":9000" --console-address ":9001" - volumes: - - files:/data - restart: unless-stopped - networks: - - internal-services - - rekoni: - image: hardcoreeng/rekoni-service:v0.6.245 - environment: - - SECRET=secret - deploy: - resources: - limits: - memory: 500M - restart: unless-stopped - networks: - - internal-services - - traefik-public - labels: - - "traefik.enable=true" - - "traefik.http.routers.rekoni.entrypoints=websecure" - - "traefik.http.services.rekoni.loadbalancer.server.port=4004" - - "traefik.http.routers.rekoni.rule=Host(`example.com`) && PathPrefix(`/rekoni`)" - - "traefik.http.routers.rekoni.middlewares=rekoni-stripprefix" - - "traefik.http.middlewares.rekoni-stripprefix.stripprefix.prefixes=/rekoni" - - "traefik.http.routers.rekoni.tls=true" - - "traefik.http.routers.rekoni.tls.certresolver=myresolver" - - transactor: - image: hardcoreeng/transactor:v0.6.245 - environment: - - SERVER_PORT=3333 - - SERVER_SECRET=secret - - SERVER_CURSOR_MAXTIMEMS=30000 - - ELASTIC_URL=http://elastic:9200 - - ELASTIC_INDEX_NAME=huly_storage_index - - MONGO_URL=mongodb://mongodb:27017 - - METRICS_CONSOLE=false - - METRICS_FILE=metrics.txt - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - - REKONI_URL=http://rekoni:4004 - - FRONT_URL=http://localhost:8087 - - SERVER_PROVIDER=wss - - ACCOUNTS_URL=http://account:3000 - - LAST_NAME_FIRST=true - - UPLOAD_URL=https://example.com/files - restart: unless-stopped - networks: - - internal-services - - traefik-public - labels: - - "traefik.enable=true" - - "traefik.http.routers.transactor.entrypoints=transactor" - - "traefik.http.routers.transactor.rule=Host(`example.com`)" - - "traefik.http.services.transactor.loadbalancer.server.port=3333" - - "traefik.http.routers.transactor.tls=true" - - "traefik.http.routers.transactor.tls.certresolver=myresolver" - - - collaborator: - image: hardcoreeng/collaborator:v0.6.245 - environment: - - COLLABORATOR_PORT=3078 - - SECRET=secret - - ACCOUNTS_URL=http://account:3000 - - TRANSACTOR_URL=ws://transactor:3333 - - UPLOAD_URL=/files - - MONGO_URL=mongodb://mongodb:27017 - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - restart: unless-stopped - networks: - - internal-services - - traefik-public - labels: - - "traefik.enable=true" - - "traefik.http.routers.collaborator.entrypoints=collaborator" - - "traefik.http.services.collaborator.loadbalancer.server.port=3078" - - "traefik.http.routers.collaborator.rule=Host(`example.com`)" - - "traefik.http.routers.collaborator.tls=true" - - "traefik.http.routers.collaborator.tls.certresolver=myresolver" - - account: - image: hardcoreeng/account:v0.6.245 - environment: - - SERVER_PORT=3000 - - SERVER_SECRET=secret - - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333 - - ENDPOINT_URL=wss://example.com:3333 # this is the transactor endpoint - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - - FRONT_URL=http://front:8080 - - INIT_WORKSPACE=demo-tracker - - MODEL_ENABLED=* - - ACCOUNTS_URL=http://localhost:3000 - - ACCOUNT_PORT=3000 - restart: unless-stopped - networks: - - internal-services - - traefik-public - labels: - - "traefik.enable=true" - - "traefik.http.routers.account.entrypoints=websecure" - - "traefik.http.services.account.loadbalancer.server.port=3000" - - "traefik.http.routers.account.rule=Host(`example.com`) && PathPrefix(`/accounts`)" - - "traefik.http.routers.account.middlewares=account-stripprefix" - - "traefik.http.middlewares.account-stripprefix.stripprefix.prefixes=/accounts" - - "traefik.http.routers.account.tls=true" - - "traefik.http.routers.account.tls.certresolver=myresolver" - - front: - image: hardcoreeng/front:v0.6.245 - environment: - - SERVER_PORT=8080 - - SERVER_SECRET=secret - - ACCOUNTS_URL=https://example.com/accounts - - REKONI_URL=https://example.com/rekoni - - CALENDAR_URL=https://example.com:8095 - - GMAIL_URL=https://example.com:8088 - - TELEGRAM_URL=https://example.com:8086 - - UPLOAD_URL=/files - - TRANSACTOR_URL=wss://example.com:3333 - - ELASTIC_URL=http://elastic:9200 - - COLLABORATOR_URL=wss://example.com:3078 - - COLLABORATOR_API_URL=https://example.com:3078 - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - - MONGO_URL=mongodb://mongodb:27017 - - TITLE=Huly Self Host - - DEFAULT_LANGUAGE=en - - LAST_NAME_FIRST=true - restart: unless-stopped - networks: - - internal-services - - traefik-public - labels: - - "traefik.enable=true" - - "traefik.http.routers.front.entrypoints=websecure" - - "traefik.http.services.front.loadbalancer.server.port=8080" - - "traefik.http.routers.front.rule=Host(`example.com`)" - - "traefik.http.routers.front.tls=true" - - "traefik.http.routers.front.tls.certresolver=myresolver" - -networks: - traefik-public: - name: traefik-public - internal-services: - name: internal-services - -volumes: - db: - letsencrypt: - elastic: - files: diff --git a/traefik/template-compose.yml b/traefik/template-compose.yaml similarity index 100% rename from traefik/template-compose.yml rename to traefik/template-compose.yaml From 9c13565a0afcb4d9a0f472a4beed1bb3ece57645 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Fri, 20 Sep 2024 08:10:12 +0200 Subject: [PATCH 06/34] chore: move to compose --- nginx/{template-compose.yaml => compose.yml} | 2 +- nginx/template.compose.yml | 169 ------------------- 2 files changed, 1 insertion(+), 170 deletions(-) rename nginx/{template-compose.yaml => compose.yml} (99%) delete mode 100644 nginx/template.compose.yml diff --git a/nginx/template-compose.yaml b/nginx/compose.yml similarity index 99% rename from nginx/template-compose.yaml rename to nginx/compose.yml index 7be25ce..67f50fa 100644 --- a/nginx/template-compose.yaml +++ b/nginx/compose.yml @@ -1,3 +1,4 @@ +project_name: huly services: nginx: image: "nginx:1.21.3" @@ -12,7 +13,6 @@ services: mongodb: image: "mongo:7-jammy" - container_name: mongodb environment: - PUID=1000 - PGID=1000 diff --git a/nginx/template.compose.yml b/nginx/template.compose.yml deleted file mode 100644 index e402de2..0000000 --- a/nginx/template.compose.yml +++ /dev/null @@ -1,169 +0,0 @@ -project_name: huly -services: - nginx: - image: "nginx:1.21.3" - ports: - - "${NGINX_SERVICE_PORT}:80" - volumes: - - ./huly.nginx:/etc/nginx/conf.d/default.conf - restart: unless-stopped - networks: - - internal-services - - nginx-public - - mongodb: - image: "mongo:7-jammy" - environment: - - PUID=1000 - - PGID=1000 - volumes: - - db:/data/db - restart: unless-stopped - networks: - - internal-services - - elastic: - image: "elasticsearch:7.14.2" - command: | - /bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment || yes | ./bin/elasticsearch-plugin install --silent ingest-attachment; - /usr/local/bin/docker-entrypoint.sh eswrapper" - volumes: - - elastic:/usr/share/elasticsearch/data - environment: - - ELASTICSEARCH_PORT_NUMBER=9200 - - BITNAMI_DEBUG=true - - discovery.type=single-node - - ES_JAVA_OPTS=-Xms1024m -Xmx1024m - - http.cors.enabled=true - - http.cors.allow-origin=http://localhost:8082 - healthcheck: - interval: 20s - retries: 10 - test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' - restart: unless-stopped - networks: - - internal-services - - minio: - image: "minio/minio" - command: server /data --address ":9000" --console-address ":9001" - volumes: - - files:/data - restart: unless-stopped - networks: - - internal-services - - rekoni: - image: hardcoreeng/rekoni-service:${HULY_VERSION} - environment: - - SECRET=${HULY_SECRET} - deploy: - resources: - limits: - memory: 500M - restart: unless-stopped - networks: - - internal-services - - nginx-public - - transactor: - image: hardcoreeng/transactor:${HULY_VERSION} - environment: - - SERVER_PORT=3333 - - SERVER_SECRET=${HULY_SECRET} - - SERVER_CURSOR_MAXTIMEMS=30000 - - ELASTIC_URL=http://elastic:9200 - - ELASTIC_INDEX_NAME=huly_storage_index - - MONGO_URL=mongodb://mongodb:27017 - - METRICS_CONSOLE=false - - METRICS_FILE=metrics.txt - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - - REKONI_URL=http://rekoni:4004 - - FRONT_URL=http://localhost:8087 - - SERVER_PROVIDER=wss - - ACCOUNTS_URL=http://account:3000 - - LAST_NAME_FIRST=true - - UPLOAD_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/files - restart: unless-stopped - networks: - - internal-services - - nginx-public - - - collaborator: - image: hardcoreeng/collaborator:${HULY_VERSION} - environment: - - COLLABORATOR_PORT=3078 - - SECRET=${HULY_SECRET} - - ACCOUNTS_URL=http://account:3000 - - TRANSACTOR_URL=ws://transactor:3333 - - UPLOAD_URL=/files - - MONGO_URL=mongodb://mongodb:27017 - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - restart: unless-stopped - networks: - - internal-services - - nginx-public - - account: - image: hardcoreeng/account:${HULY_VERSION} - environment: - - SERVER_PORT=3000 - - SERVER_SECRET=${HULY_SECRET} - - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333 - - ENDPOINT_URL=${$NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor # this is the transactor endpoint - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - - FRONT_URL=http://front:8080 - - INIT_WORKSPACE=demo-tracker - - MODEL_ENABLED=* - - ACCOUNTS_URL=http://localhost:3000 - - ACCOUNT_PORT=3000 - restart: unless-stopped - networks: - - internal-services - - nginx-public - - front: - image: hardcoreeng/front:${HULY_VERSION} - environment: - - SERVER_PORT=8080 - - SERVER_SECRET=${HULY_SECRET} - - ACCOUNTS_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_accounts - - REKONI_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_rekoni - - CALENDAR_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}:8095 - - GMAIL_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}:8088 - - TELEGRAM_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}:8086 - - UPLOAD_URL=/files - - TRANSACTOR_URL=${$NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor - - ELASTIC_URL=http://elastic:9200 - - COLLABORATOR_URL=${$NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_collaborator - - COLLABORATOR_API_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_collaborator - - MINIO_ENDPOINT=minio - - MINIO_ACCESS_KEY=minioadmin - - MINIO_SECRET_KEY=minioadmin - - MONGO_URL=mongodb://mongodb:27017 - - TITLE=Huly Self Host - - DEFAULT_LANGUAGE=en - - LAST_NAME_FIRST=true - restart: unless-stopped - networks: - - internal-services - - nginx-public - -networks: - nginx-public: - name: nginx-public - internal-services: - name: internal-services - -volumes: - db: - elastic: - files: \ No newline at end of file From 7af7779534d02c50d66441c74ae1cb0e4d86cba5 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Fri, 20 Sep 2024 08:22:07 +0200 Subject: [PATCH 07/34] chore: create .env symlink --- .env | 1 + .gitignore | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) create mode 120000 .env diff --git a/.env b/.env new file mode 120000 index 0000000..de4ffb4 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +huly.conf \ No newline at end of file diff --git a/.gitignore b/.gitignore index e20f53b..3414420 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ letsencrypt/ -nginx/docker-compose.yaml traefik/docker-compose.yaml -compose.yaml nginx.conf \ No newline at end of file From 76c8e3a1e728f582d68c8530f870712a46ad68e3 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Fri, 20 Sep 2024 08:51:43 +0200 Subject: [PATCH 08/34] chore: remove network Network isn't needed as only the nginx port is exposed --- nginx/compose.yml => compose.yaml | 48 ++------- template.compose.yaml | 157 ------------------------------ 2 files changed, 7 insertions(+), 198 deletions(-) rename nginx/compose.yml => compose.yaml (86%) delete mode 100644 template.compose.yaml diff --git a/nginx/compose.yml b/compose.yaml similarity index 86% rename from nginx/compose.yml rename to compose.yaml index 67f50fa..fd0ebbd 100644 --- a/nginx/compose.yml +++ b/compose.yaml @@ -7,9 +7,6 @@ services: volumes: - ./huly.nginx:/etc/nginx/conf.d/default.conf restart: unless-stopped - networks: - - internal-services - - nginx-public mongodb: image: "mongo:7-jammy" @@ -19,8 +16,13 @@ services: volumes: - db:/data/db restart: unless-stopped - networks: - - internal-services + + minio: + image: "minio/minio" + command: server /data --address ":9000" --console-address ":9001" + volumes: + - files:/data + restart: unless-stopped elastic: image: "elasticsearch:7.14.2" @@ -41,17 +43,6 @@ services: retries: 10 test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' restart: unless-stopped - networks: - - internal-services - - minio: - image: "minio/minio" - command: server /data --address ":9000" --console-address ":9001" - volumes: - - files:/data - restart: unless-stopped - networks: - - internal-services rekoni: image: hardcoreeng/rekoni-service:${HULY_VERSION} @@ -62,9 +53,6 @@ services: limits: memory: 500M restart: unless-stopped - networks: - - internal-services - - nginx-public transactor: image: hardcoreeng/transactor:${HULY_VERSION} @@ -84,10 +72,6 @@ services: - LAST_NAME_FIRST=true - UPLOAD_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/files restart: unless-stopped - networks: - - internal-services - - nginx-public - collaborator: image: hardcoreeng/collaborator:${HULY_VERSION} @@ -98,9 +82,6 @@ services: - MONGO_URL=mongodb://mongodb:27017 - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin restart: unless-stopped - networks: - - internal-services - - nginx-public account: image: hardcoreeng/account:${HULY_VERSION} @@ -115,9 +96,6 @@ services: - ACCOUNTS_URL=http://localhost:3000 - ACCOUNT_PORT=3000 restart: unless-stopped - networks: - - internal-services - - nginx-public workspace: image: hardcoreeng/workspace:${HULY_VERSION} @@ -130,9 +108,6 @@ services: - ACCOUNTS_URL=http://account:3000 - NOTIFY_INBOX_ONLY=true restart: unless-stopped - networks: - - internal-services - - nginx-public front: image: hardcoreeng/front:${HULY_VERSION} @@ -153,15 +128,6 @@ services: - DEFAULT_LANGUAGE=en - LAST_NAME_FIRST=true restart: unless-stopped - networks: - - internal-services - - nginx-public - -networks: - nginx-public: - name: nginx-public - internal-services: - name: internal-services volumes: db: diff --git a/template.compose.yaml b/template.compose.yaml deleted file mode 100644 index e14c65a..0000000 --- a/template.compose.yaml +++ /dev/null @@ -1,157 +0,0 @@ -version: "3" -services: - mongodb: - image: "mongo:7-jammy" - container_name: mongodb - environment: - - PUID=1000 - - PGID=1000 - volumes: - - db:/data/db - ports: - - 27017:27017 - restart: unless-stopped - minio: - image: "minio/minio" - command: server /data --address ":9000" --console-address ":9001" - ports: - - 9000:9000 - - 9001:9001 - volumes: - - files:/data - restart: unless-stopped - elastic: - image: "elasticsearch:7.14.2" - command: | - /bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment || yes | ./bin/elasticsearch-plugin install --silent ingest-attachment; - /usr/local/bin/docker-entrypoint.sh eswrapper" - volumes: - - elastic:/usr/share/elasticsearch/data - ports: - - 9200:9200 - environment: - - ELASTICSEARCH_PORT_NUMBER=9200 - - BITNAMI_DEBUG=true - - discovery.type=single-node - - ES_JAVA_OPTS=-Xms1024m -Xmx1024m - - http.cors.enabled=true - - http.cors.allow-origin=http://localhost:8082 - healthcheck: - interval: 20s - retries: 10 - test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' - restart: unless-stopped - account: - image: hardcoreeng/account:${HULY_VERSION} - links: - - mongodb - - minio - ports: - - 3000:3000 - environment: - - SERVER_PORT=3000 - - SERVER_SECRET=${HULY_SECRET} - - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333;ws://${SERVER_ADDRESS}:3333 - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - - FRONT_URL=http://front:8080 - - MODEL_ENABLED=* - - ACCOUNTS_URL=http://${SERVER_ADDRESS}:3000 - - ACCOUNT_PORT=3000 - restart: unless-stopped - workspace: - image: hardcoreeng/workspace:${HULY_VERSION} - links: - - mongodb - - minio - environment: - - SERVER_SECRET=${HULY_SECRET} - - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333;ws://${SERVER_ADDRESS}:3333 - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - - MODEL_ENABLED=* - - ACCOUNTS_URL=http://account:3000 - - NOTIFY_INBOX_ONLY=true - restart: unless-stopped - front: - image: hardcoreeng/front:${HULY_VERSION} - links: - - mongodb - - minio - - elastic - - collaborator - - transactor - ports: - - 8087:8080 - environment: - - SERVER_PORT=8080 - - SERVER_SECRET=${HULY_SECRET} - - ACCOUNTS_URL=http://${SERVER_ADDRESS}:3000 - - REKONI_URL=http://${SERVER_ADDRESS}:4004 - - CALENDAR_URL=http://${SERVER_ADDRESS}:8095 - - GMAIL_URL=http://${SERVER_ADDRESS}:8088 - - TELEGRAM_URL=http://${SERVER_ADDRESS}:8086 - - UPLOAD_URL=/files - - ELASTIC_URL=http://elastic:9200 - - COLLABORATOR_URL=ws://${SERVER_ADDRESS}:3078 - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - - MONGO_URL=mongodb://mongodb:27017 - - TITLE=Huly Self Hosted - - DEFAULT_LANGUAGE=en - - LAST_NAME_FIRST=true - restart: unless-stopped - collaborator: - image: hardcoreeng/collaborator:${HULY_VERSION} - links: - - mongodb - - minio - - transactor - ports: - - 3078:3078 - environment: - - COLLABORATOR_PORT=3078 - - SECRET=${HULY_SECRET} - - ACCOUNTS_URL=http://account:3000 - - MONGO_URL=mongodb://mongodb:27017 - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - restart: unless-stopped - transactor: - image: hardcoreeng/transactor:${HULY_VERSION} - links: - - mongodb - - elastic - - minio - - account - ports: - - 3333:3333 - environment: - - SERVER_PORT=3333 - - SERVER_SECRET=${HULY_SECRET} - - SERVER_CURSOR_MAXTIMEMS=30000 - - ELASTIC_URL=http://elastic:9200 - - ELASTIC_INDEX_NAME=huly_storage_index - - MONGO_URL=mongodb://mongodb:27017 - - METRICS_CONSOLE=false - - METRICS_FILE=metrics.txt - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - - REKONI_URL=http://rekoni:4004 - - FRONT_URL=http://${SERVER_ADDRESS}:8087 - - ACCOUNTS_URL=http://account:3000 - - LAST_NAME_FIRST=true - restart: unless-stopped - rekoni: - image: hardcoreeng/rekoni-service:${HULY_VERSION} - ports: - - 4004:4004 - environment: - - SECRET=${HULY_SECRET} - deploy: - resources: - limits: - memory: 500M - restart: unless-stopped -volumes: - db: - files: - elastic: - etcd: From 8c7c3cd0280553b45cbbb2059411d6ef070195fb Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Fri, 20 Sep 2024 09:14:12 +0200 Subject: [PATCH 09/34] chore: add huly.conf to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3414420..be6d3b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ letsencrypt/ traefik/docker-compose.yaml -nginx.conf \ No newline at end of file +nginx.conf +huly.conf \ No newline at end of file From 14a9a49b4417eb2d696c5c0b06b23e4667e3c94d Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Mon, 23 Sep 2024 05:32:41 +0200 Subject: [PATCH 10/34] wip: setup and env creation --- .gitignore | 3 +- compose.yaml => compose.yml | 46 +++++---- nginx/huly.nginx => huly.nginx | 13 +++ nginx/setup.sh | 59 ------------ nginx/template-compose.yaml | 169 --------------------------------- setup.sh | 85 +++++++++++++++-- template.conf | 11 --- template.env | 1 - template.huly.conf | 19 ++++ use-version.sh | 4 - 10 files changed, 138 insertions(+), 272 deletions(-) rename compose.yaml => compose.yml (73%) rename nginx/huly.nginx => huly.nginx (83%) delete mode 100755 nginx/setup.sh delete mode 100644 nginx/template-compose.yaml delete mode 100644 template.conf delete mode 100644 template.env create mode 100644 template.huly.conf delete mode 100755 use-version.sh diff --git a/.gitignore b/.gitignore index be6d3b4..6c0a79b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ letsencrypt/ traefik/docker-compose.yaml nginx.conf -huly.conf \ No newline at end of file +huly.conf +huly.secret \ No newline at end of file diff --git a/compose.yaml b/compose.yml similarity index 73% rename from compose.yaml rename to compose.yml index fd0ebbd..b712579 100644 --- a/compose.yaml +++ b/compose.yml @@ -1,9 +1,9 @@ -project_name: huly +name: ${DOCKER_NAME} services: nginx: image: "nginx:1.21.3" ports: - - "${NGINX_SERVICE_PORT}:80" + - "${HTTP_BIND}:${HTTP_PORT}:80" volumes: - ./huly.nginx:/etc/nginx/conf.d/default.conf restart: unless-stopped @@ -47,7 +47,7 @@ services: rekoni: image: hardcoreeng/rekoni-service:${HULY_VERSION} environment: - - SECRET=${HULY_SECRET} + - SECRET=${SECRET} deploy: resources: limits: @@ -58,7 +58,7 @@ services: image: hardcoreeng/transactor:${HULY_VERSION} environment: - SERVER_PORT=3333 - - SERVER_SECRET=${HULY_SECRET} + - SERVER_SECRET=${SECRET} - SERVER_CURSOR_MAXTIMEMS=30000 - ELASTIC_URL=http://elastic:9200 - ELASTIC_INDEX_NAME=huly_storage_index @@ -69,15 +69,15 @@ services: - REKONI_URL=http://rekoni:4004 - FRONT_URL=http://localhost:8087 - ACCOUNTS_URL=http://account:3000 - - LAST_NAME_FIRST=true - - UPLOAD_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/files + - LAST_NAME_FIRST=${LAST_NAME_FIRST:-true} + - UPLOAD_URL=http${SECURE}://${HOST_ADDRESS}/files restart: unless-stopped collaborator: image: hardcoreeng/collaborator:${HULY_VERSION} environment: - COLLABORATOR_PORT=3078 - - SECRET=${HULY_SECRET} + - SECRET=${SECRET} - ACCOUNTS_URL=http://account:3000 - MONGO_URL=mongodb://mongodb:27017 - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin @@ -87,9 +87,9 @@ services: image: hardcoreeng/account:${HULY_VERSION} environment: - SERVER_PORT=3000 - - SERVER_SECRET=${HULY_SECRET} + - SERVER_SECRET=${SECRET} - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333;${NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor + - TRANSACTOR_URL=ws://transactor:3333;ws${SECURE}://${HOST_ADDRESS}/_transactor - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - FRONT_URL=http://front:8080 - MODEL_ENABLED=* @@ -100,33 +100,37 @@ services: workspace: image: hardcoreeng/workspace:${HULY_VERSION} environment: - - SERVER_SECRET=${HULY_SECRET} + - SERVER_SECRET=${SECRET} - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333;${NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor + - TRANSACTOR_URL=ws://transactor:3333;ws${SECURE}://${HOST_ADDRESS}/_transactor - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - MODEL_ENABLED=* - ACCOUNTS_URL=http://account:3000 - NOTIFY_INBOX_ONLY=true restart: unless-stopped + #love: + # image: hardcoreeng/love:${HULY_VERSION} + # restart: unless-stopped front: image: hardcoreeng/front:${HULY_VERSION} environment: - SERVER_PORT=8080 - - SERVER_SECRET=${HULY_SECRET} - - ACCOUNTS_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_accounts - - REKONI_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_rekoni - - CALENDAR_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_calendar - - GMAIL_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_gmail - - TELEGRAM_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_telegram + - SERVER_SECRET=${SECRET} + - LOVE_ENDPOINT=http${SECURE}://${HOST_ADDRESS}/_love + - ACCOUNTS_URL=http${SECURE}://${HOST_ADDRESS}/_accounts + - REKONI_URL=http${SECURE}://${HOST_ADDRESS}/_rekoni + - CALENDAR_URL=http${SECURE}://${HOST_ADDRESS}/_calendar + - GMAIL_URL=http${SECURE}://${HOST_ADDRESS}/_gmail + - TELEGRAM_URL=http${SECURE}://${HOST_ADDRESS}/_telegram - UPLOAD_URL=/files - ELASTIC_URL=http://elastic:9200 - - COLLABORATOR_URL=${NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_collaborator + - COLLABORATOR_URL=ws${SECURE}://${HOST_ADDRESS}/_collaborator - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - MONGO_URL=mongodb://mongodb:27017 - - TITLE=Huly Self Host - - DEFAULT_LANGUAGE=en - - LAST_NAME_FIRST=true + - TITLE=${TITLE:-Huly Self Host} + - DEFAULT_LANGUAGE=${DEFAULT_LANGUAGE:-en} + - LAST_NAME_FIRST=${LAST_NAME_FIRST:-true} restart: unless-stopped volumes: diff --git a/nginx/huly.nginx b/huly.nginx similarity index 83% rename from nginx/huly.nginx rename to huly.nginx index 1c924dd..6351e2e 100644 --- a/nginx/huly.nginx +++ b/huly.nginx @@ -19,6 +19,19 @@ server { proxy_pass http://account:3000/; } + location /_love { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + rewrite ^/_love(/.*)$ $1 break; + proxy_pass http://love:8096/; + } + location /_collaborator { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/nginx/setup.sh b/nginx/setup.sh deleted file mode 100755 index 12f5fe6..0000000 --- a/nginx/setup.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash - -read -p "Enter the domain name: " DOMAIN_NAME -if [ -z "$DOMAIN_NAME" ]; then - echo "DOMAIN_NAME is required" - exit 1 -fi - -read -p "Enter the port you want nginx to expose: " NGINX_SERVICE_PORT -if [ -z "$NGINX_SERVICE_PORT" ]; then - echo "NGINX_SERVICE_PORT address is required" - exit 1 -fi - -read -p "Do you run behind SSL proxy (did you setup HTTPS)? (Y/n): " NGINX_BEHIND_SSL -case "$NGINX_BEHIND_SSL" in - [Yy]* ) - NGINX_WS_SCHEME="wss" - NGINX_HTTP_SCHEME="https" - ;; - [Nn]* ) - NGINX_WS_SCHEME="ws" - NGINX_HTTP_SCHEME="http" - ;; - * ) - echo "SSL selected" - NGINX_WS_SCHEME="wss" - NGINX_HTTP_SCHEME="https" - ;; -esac - - -export HULY_VERSION="v0.6.295" -export NGINX_SERVICE_PORT=$NGINX_SERVICE_PORT -export NGINX_HTTP_SCHEME=$NGINX_HTTP_SCHEME -export NGINX_WS_SCHEME=$NGINX_WS_SCHEME -export SERVER_ADDRESS="${DOMAIN_NAME}:${NGINX_SERVICE_PORT}" - -# $(openssl rand -hex 32) -export HULY_SECRET="secret" - -# replace the domain name and email address in the docker-compose file -envsubst < template-compose.yaml > docker-compose.yaml - -echo -e "\033[1;32mSetup is complete!\033[0m" - -read -p "Do you want to run 'docker compose up -d' now to spin up Huly? ([Y]es/[n]o): " RUN_DOCKER -case "${RUN_DOCKER,,}" in - y|yes|"" ) - echo -e "\033[1;32mRunning 'docker compose up -d' now...\033[0m" - docker compose up -d - ;; - n|no ) - echo "You can run 'docker compose up -d' later to start the services." - ;; - * ) - echo "Invalid input. You can run 'docker compose up -d' later to start the services." - ;; -esac \ No newline at end of file diff --git a/nginx/template-compose.yaml b/nginx/template-compose.yaml deleted file mode 100644 index 7be25ce..0000000 --- a/nginx/template-compose.yaml +++ /dev/null @@ -1,169 +0,0 @@ -services: - nginx: - image: "nginx:1.21.3" - ports: - - "${NGINX_SERVICE_PORT}:80" - volumes: - - ./huly.nginx:/etc/nginx/conf.d/default.conf - restart: unless-stopped - networks: - - internal-services - - nginx-public - - mongodb: - image: "mongo:7-jammy" - container_name: mongodb - environment: - - PUID=1000 - - PGID=1000 - volumes: - - db:/data/db - restart: unless-stopped - networks: - - internal-services - - elastic: - image: "elasticsearch:7.14.2" - command: | - /bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment || yes | ./bin/elasticsearch-plugin install --silent ingest-attachment; - /usr/local/bin/docker-entrypoint.sh eswrapper" - volumes: - - elastic:/usr/share/elasticsearch/data - environment: - - ELASTICSEARCH_PORT_NUMBER=9200 - - BITNAMI_DEBUG=true - - discovery.type=single-node - - ES_JAVA_OPTS=-Xms1024m -Xmx1024m - - http.cors.enabled=true - - http.cors.allow-origin=http://localhost:8082 - healthcheck: - interval: 20s - retries: 10 - test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' - restart: unless-stopped - networks: - - internal-services - - minio: - image: "minio/minio" - command: server /data --address ":9000" --console-address ":9001" - volumes: - - files:/data - restart: unless-stopped - networks: - - internal-services - - rekoni: - image: hardcoreeng/rekoni-service:${HULY_VERSION} - environment: - - SECRET=${HULY_SECRET} - deploy: - resources: - limits: - memory: 500M - restart: unless-stopped - networks: - - internal-services - - nginx-public - - transactor: - image: hardcoreeng/transactor:${HULY_VERSION} - environment: - - SERVER_PORT=3333 - - SERVER_SECRET=${HULY_SECRET} - - SERVER_CURSOR_MAXTIMEMS=30000 - - ELASTIC_URL=http://elastic:9200 - - ELASTIC_INDEX_NAME=huly_storage_index - - MONGO_URL=mongodb://mongodb:27017 - - METRICS_CONSOLE=false - - METRICS_FILE=metrics.txt - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - - REKONI_URL=http://rekoni:4004 - - FRONT_URL=http://localhost:8087 - - ACCOUNTS_URL=http://account:3000 - - LAST_NAME_FIRST=true - - UPLOAD_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/files - restart: unless-stopped - networks: - - internal-services - - nginx-public - - - collaborator: - image: hardcoreeng/collaborator:${HULY_VERSION} - environment: - - COLLABORATOR_PORT=3078 - - SECRET=${HULY_SECRET} - - ACCOUNTS_URL=http://account:3000 - - MONGO_URL=mongodb://mongodb:27017 - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - restart: unless-stopped - networks: - - internal-services - - nginx-public - - account: - image: hardcoreeng/account:${HULY_VERSION} - environment: - - SERVER_PORT=3000 - - SERVER_SECRET=${HULY_SECRET} - - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333;${NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - - FRONT_URL=http://front:8080 - - MODEL_ENABLED=* - - ACCOUNTS_URL=http://localhost:3000 - - ACCOUNT_PORT=3000 - restart: unless-stopped - networks: - - internal-services - - nginx-public - - workspace: - image: hardcoreeng/workspace:${HULY_VERSION} - environment: - - SERVER_SECRET=${HULY_SECRET} - - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333;${NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_transactor - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - - MODEL_ENABLED=* - - ACCOUNTS_URL=http://account:3000 - - NOTIFY_INBOX_ONLY=true - restart: unless-stopped - networks: - - internal-services - - nginx-public - - front: - image: hardcoreeng/front:${HULY_VERSION} - environment: - - SERVER_PORT=8080 - - SERVER_SECRET=${HULY_SECRET} - - ACCOUNTS_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_accounts - - REKONI_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_rekoni - - CALENDAR_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_calendar - - GMAIL_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_gmail - - TELEGRAM_URL=${NGINX_HTTP_SCHEME}://${SERVER_ADDRESS}/_telegram - - UPLOAD_URL=/files - - ELASTIC_URL=http://elastic:9200 - - COLLABORATOR_URL=${NGINX_WS_SCHEME}://${SERVER_ADDRESS}/_collaborator - - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - - MONGO_URL=mongodb://mongodb:27017 - - TITLE=Huly Self Host - - DEFAULT_LANGUAGE=en - - LAST_NAME_FIRST=true - restart: unless-stopped - networks: - - internal-services - - nginx-public - -networks: - nginx-public: - name: nginx-public - internal-services: - name: internal-services - -volumes: - db: - elastic: - files: \ No newline at end of file diff --git a/setup.sh b/setup.sh index 8d2e5a0..00762ac 100755 --- a/setup.sh +++ b/setup.sh @@ -1,10 +1,83 @@ #!/usr/bin/env bash -export SERVER_ADDRESS="$1" -export HULY_SECRET="secret" +# Define the default values +HULY_VERSION="v0.6.295" +DOCKER_NAME="huly" +CONFIG_FILE="huly.conf" -echo "Setting Huly Server Address: $SERVER_ADDRESS" -envsubst < template.conf > nginx.conf -envsubst < template.env > .env -./use-version.sh v0.6.295 +if [ -f "$CONFIG_FILE" ]; then + source "$CONFIG_FILE" +fi +clear + +while true; do + read -p "Enter the host address (domain name or IP) [default: ${HOST_ADDRESS:-localhost}]: " input + _HOST_ADDRESS="${input:-${HOST_ADDRESS:-localhost}}" + #TODO: proper validation + #if [[ "$_HOST_ADDRESS" =~ ^[a-zA-Z0-9.-]+$ || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then + break + #else + # echo "Invalid host address. Please enter a valid domain name or IP." + #fi +done +clear + +while true; do + read -p "Enter the port for HTTP [default: ${HTTP_PORT:-80}]: " input + _HTTP_PORT="${input:-${HTTP_PORT:-80}}" + if [[ "$_HTTP_PORT" =~ ^[0-9]+$ && "$_HTTP_PORT" -ge 1 && "$_HTTP_PORT" -le 65535 ]]; then + break + else + echo "Invalid port. Please enter a number between 1 and 65535." + fi +done +clear +# TODO: true/false +while true; do + read -p "Will you serve Huly over SSL? (y/N) [default: ${SECURE}]: " SECURE_INPUT + case "$SECURE_INPUT" in + [Yy]* ) + SECURE="s";break;; + [Nn]* ) + SECURE="";break;; + * ) + echo "Invalid input. Please enter Y or N.";; + esac +done +clear + +SECRET=false +if [ "$1" == "--secret" ]; then + SECRET=true +fi + +if [ ! -f huly.secret ] || [ "$SECRET" == true ]; then + openssl rand -hex 32 > huly.secret + echo "Secret generated and stored in huly.secret" +else + echo -e "\033[33mhuly.secret already exists, not overwriting." + echo "Run this script with --secret to generate a new secret." +fi + + +export SECURE +export HOST_ADDRESS=$_HOST_ADDRESS +export HTTP_PORT=$_HTTP_PORT +export HULY_SECRET=$(cat huly.secret) + +envsubst < template.huly.conf > $CONFIG_FILE + +echo -e "\033[1;32mSetup is complete!\033[0m" + +read -p "Do you want to run 'docker compose up -d' now to start Huly? (Y/n): " RUN_DOCKER +case "${RUN_DOCKER:-Y}" in + [Yy]* ) + echo -e "\033[1;32mRunning 'docker compose up -d' now...\033[0m" + docker compose up -d + ;; + [Nn]* ) + echo "You can run 'docker compose up -d' later to start Huly." + ;; + +esac diff --git a/template.conf b/template.conf deleted file mode 100644 index a1a5fd6..0000000 --- a/template.conf +++ /dev/null @@ -1,11 +0,0 @@ -server { - listen 80; - listen [::]:80; - - server_name ${SERVER_ADDRESS}; - - location / { - proxy_pass http://localhost:8087; - include proxy_params; - } -} diff --git a/template.env b/template.env deleted file mode 100644 index be9f094..0000000 --- a/template.env +++ /dev/null @@ -1 +0,0 @@ -SERVER_ADDRESS=${SERVER_ADDRESS} diff --git a/template.huly.conf b/template.huly.conf new file mode 100644 index 0000000..04af3de --- /dev/null +++ b/template.huly.conf @@ -0,0 +1,19 @@ +HULY_VERSION=v0.6.295 +DOCKER_NAME="huly" + +# The address of the host or server from which you will access your huly instance. +# This can be a domain name or an IP address. +HOST_ADDRESS=${HOST_ADDRESS} +# Flag to enable secure connections. Use "s" for HTTPS/WSS or leave blank for HTTP/WS. +# "s", "" +# TODO: allow true/false +SECURE=${SECURE} + + +# Specify the IP address to bind to; leave blank to bind to all interfaces (0.0.0.0). +# Do not use IP:PORT format in HTTP_BIND or HTTP_PORT. +HTTP_PORT=${HTTP_PORT} +HTTP_BIND= + +# Auto-generated by the setup script. Run with --secret to regenerate. +SECRET=${HULY_SECRET} diff --git a/use-version.sh b/use-version.sh deleted file mode 100755 index 74b7157..0000000 --- a/use-version.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -export HULY_VERSION="$1" -echo "Setting Huly Version: $HULY_VERSION" -envsubst < template.compose.yaml > compose.yaml From 90659ea92771e62b629d00d9769d4770124d337f Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Tue, 24 Sep 2024 04:40:23 +0200 Subject: [PATCH 11/34] chore(nginx): comment out love endpoint --- huly.nginx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/huly.nginx b/huly.nginx index 6351e2e..9aed695 100644 --- a/huly.nginx +++ b/huly.nginx @@ -19,18 +19,18 @@ server { proxy_pass http://account:3000/; } - location /_love { - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + #location /_love { + # proxy_set_header Host $host; + # proxy_set_header X-Real-IP $remote_addr; + # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + # proxy_set_header X-Forwarded-Proto $scheme; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - rewrite ^/_love(/.*)$ $1 break; - proxy_pass http://love:8096/; - } + # proxy_http_version 1.1; + # proxy_set_header Upgrade $http_upgrade; + # proxy_set_header Connection "upgrade"; + # rewrite ^/_love(/.*)$ $1 break; + # proxy_pass http://love:8096/; + #} location /_collaborator { proxy_set_header Host $host; From 6b2d84b7ec789ed088928c6370651785eb34dad2 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Tue, 24 Sep 2024 04:41:13 +0200 Subject: [PATCH 12/34] chore(compose): use secure endpoints is env is defined --- compose.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/compose.yml b/compose.yml index b712579..d2125b2 100644 --- a/compose.yml +++ b/compose.yml @@ -70,7 +70,7 @@ services: - FRONT_URL=http://localhost:8087 - ACCOUNTS_URL=http://account:3000 - LAST_NAME_FIRST=${LAST_NAME_FIRST:-true} - - UPLOAD_URL=http${SECURE}://${HOST_ADDRESS}/files + - UPLOAD_URL=http${SECURE:+s}://${HOST_ADDRESS}/files restart: unless-stopped collaborator: @@ -89,7 +89,7 @@ services: - SERVER_PORT=3000 - SERVER_SECRET=${SECRET} - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333;ws${SECURE}://${HOST_ADDRESS}/_transactor + - TRANSACTOR_URL=ws://transactor:3333;ws${SECURE:+s}://${HOST_ADDRESS}/_transactor - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - FRONT_URL=http://front:8080 - MODEL_ENABLED=* @@ -102,7 +102,7 @@ services: environment: - SERVER_SECRET=${SECRET} - MONGO_URL=mongodb://mongodb:27017 - - TRANSACTOR_URL=ws://transactor:3333;ws${SECURE}://${HOST_ADDRESS}/_transactor + - TRANSACTOR_URL=ws://transactor:3333;ws${SECURE:+s}://${HOST_ADDRESS}/_transactor - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - MODEL_ENABLED=* - ACCOUNTS_URL=http://account:3000 @@ -117,15 +117,15 @@ services: environment: - SERVER_PORT=8080 - SERVER_SECRET=${SECRET} - - LOVE_ENDPOINT=http${SECURE}://${HOST_ADDRESS}/_love - - ACCOUNTS_URL=http${SECURE}://${HOST_ADDRESS}/_accounts - - REKONI_URL=http${SECURE}://${HOST_ADDRESS}/_rekoni - - CALENDAR_URL=http${SECURE}://${HOST_ADDRESS}/_calendar - - GMAIL_URL=http${SECURE}://${HOST_ADDRESS}/_gmail - - TELEGRAM_URL=http${SECURE}://${HOST_ADDRESS}/_telegram + - LOVE_ENDPOINT=http${SECURE:+s}://${HOST_ADDRESS}/_love + - ACCOUNTS_URL=http${SECURE:+s}://${HOST_ADDRESS}/_accounts + - REKONI_URL=http${SECURE:+s}://${HOST_ADDRESS}/_rekoni + - CALENDAR_URL=http${SECURE:+s}://${HOST_ADDRESS}/_calendar + - GMAIL_URL=http${SECURE:+s}://${HOST_ADDRESS}/_gmail + - TELEGRAM_URL=http${SECURE:+s}://${HOST_ADDRESS}/_telegram - UPLOAD_URL=/files - ELASTIC_URL=http://elastic:9200 - - COLLABORATOR_URL=ws${SECURE}://${HOST_ADDRESS}/_collaborator + - COLLABORATOR_URL=ws${SECURE:+s}://${HOST_ADDRESS}/_collaborator - STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin - MONGO_URL=mongodb://mongodb:27017 - TITLE=${TITLE:-Huly Self Host} From e24dc21a63706d4656d05da0f9222f3c1082936e Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Tue, 24 Sep 2024 05:34:04 +0200 Subject: [PATCH 13/34] wip: improve setup, handle ip host and ssl config --- setup.sh | 68 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/setup.sh b/setup.sh index 00762ac..324edbd 100755 --- a/setup.sh +++ b/setup.sh @@ -1,27 +1,24 @@ #!/usr/bin/env bash -# Define the default values HULY_VERSION="v0.6.295" DOCKER_NAME="huly" CONFIG_FILE="huly.conf" - if [ -f "$CONFIG_FILE" ]; then source "$CONFIG_FILE" fi -clear while true; do - read -p "Enter the host address (domain name or IP) [default: ${HOST_ADDRESS:-localhost}]: " input - _HOST_ADDRESS="${input:-${HOST_ADDRESS:-localhost}}" - #TODO: proper validation - #if [[ "$_HOST_ADDRESS" =~ ^[a-zA-Z0-9.-]+$ || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then + read -p "Enter the host address (domain name or IP) [default: ${HOST_ADDRESS:-}]: " input + _HOST_ADDRESS="${input:-${HOST_ADDRESS:-$(hostname -I | awk '{print $1}')}}" + # TODO: proper validation + # if [[ "$_HOST_ADDRESS" =~ ^[a-zA-Z0-9.-]+$ || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then break - #else - # echo "Invalid host address. Please enter a valid domain name or IP." - #fi + # else + # echo "Invalid host address. Please enter a valid domain name or IP." + # fi done -clear + while true; do read -p "Enter the port for HTTP [default: ${HTTP_PORT:-80}]: " input @@ -32,19 +29,26 @@ while true; do echo "Invalid port. Please enter a number between 1 and 65535." fi done -clear -# TODO: true/false -while true; do - read -p "Will you serve Huly over SSL? (y/N) [default: ${SECURE}]: " SECURE_INPUT - case "$SECURE_INPUT" in - [Yy]* ) - SECURE="s";break;; - [Nn]* ) - SECURE="";break;; - * ) - echo "Invalid input. Please enter Y or N.";; - esac -done + +if [[ "$_HOST_ADDRESS" == "localhost" || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then + _HOST_ADDRESS="${_HOST_ADDRESS}:\${HTTP_PORT}" + SECURE="" +else + while true; do + read -p "Will you serve Huly over SSL? (y/N) [default: ${SECURE}]: " input + case "${input}" in + [Yy]* ) + _SECURE="true"; break;; + [Nn]* ) + _SECURE=""; break;; + "" ) + _SECURE="${SECURE:+true}"; break;; + * ) + echo "Invalid input. Please enter Y or N.";; + esac + done +fi + clear SECRET=false @@ -60,16 +64,21 @@ else echo "Run this script with --secret to generate a new secret." fi - -export SECURE +export SECURE=$_SECURE export HOST_ADDRESS=$_HOST_ADDRESS export HTTP_PORT=$_HTTP_PORT export HULY_SECRET=$(cat huly.secret) envsubst < template.huly.conf > $CONFIG_FILE -echo -e "\033[1;32mSetup is complete!\033[0m" - +echo -e "\n\033[1;34mConfiguration Summary:\033[0m" +echo -e "Host Address: \033[1;32m$_HOST_ADDRESS\033[0m" +echo -e "HTTP Port: \033[1;32m$_HTTP_PORT\033[0m" +if [[ -n "$SECURE" ]]; then + echo -e "SSL Enabled: \033[1;32mYes\033[0m" +else + echo -e "SSL Enabled: \033[1;31mNo\033[0m" +fi read -p "Do you want to run 'docker compose up -d' now to start Huly? (Y/n): " RUN_DOCKER case "${RUN_DOCKER:-Y}" in [Yy]* ) @@ -79,5 +88,6 @@ case "${RUN_DOCKER:-Y}" in [Nn]* ) echo "You can run 'docker compose up -d' later to start Huly." ;; - esac + +echo -e "\033[1;32mSetup is complete!\033[0m" From 34e02628c62f2b59c43c2377ef0fad02a6289f4b Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Tue, 24 Sep 2024 05:34:46 +0200 Subject: [PATCH 14/34] chore: update template config --- template.huly.conf | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/template.huly.conf b/template.huly.conf index 04af3de..921115b 100644 --- a/template.huly.conf +++ b/template.huly.conf @@ -1,19 +1,21 @@ HULY_VERSION=v0.6.295 -DOCKER_NAME="huly" +DOCKER_NAME=huly -# The address of the host or server from which you will access your huly instance. -# This can be a domain name or an IP address. +# The address of the host or server from which you will access your Huly instance. +# This can be a domain name (e.g., huly.example.com) or an IP address (e.g., 192.168.1.1). HOST_ADDRESS=${HOST_ADDRESS} -# Flag to enable secure connections. Use "s" for HTTPS/WSS or leave blank for HTTP/WS. -# "s", "" -# TODO: allow true/false -SECURE=${SECURE} +# Set this variable to 'true' to enable SSL (HTTPS/WSS). +# Leave it empty to use non-SSL (HTTP/WS). +SECURE=${SECURE} # Specify the IP address to bind to; leave blank to bind to all interfaces (0.0.0.0). # Do not use IP:PORT format in HTTP_BIND or HTTP_PORT. HTTP_PORT=${HTTP_PORT} HTTP_BIND= -# Auto-generated by the setup script. Run with --secret to regenerate. -SECRET=${HULY_SECRET} +# The following configs are auto-generated by the setup script. +# Please do not manually overwrite. + +# Run with --secret to regenerate. +SECRET=${HULY_SECRET} From 91591b5f2ef540915b3267fef51261d03220d8f2 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Tue, 24 Sep 2024 06:01:51 +0200 Subject: [PATCH 15/34] chore(love): add livekit resource --- compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compose.yml b/compose.yml index d2125b2..f98abcc 100644 --- a/compose.yml +++ b/compose.yml @@ -109,6 +109,8 @@ services: - NOTIFY_INBOX_ONLY=true restart: unless-stopped + # THIS REQUIRES MANUAL SETUP + # https://docs.livekit.io/home/self-hosting/vm/ #love: # image: hardcoreeng/love:${HULY_VERSION} # restart: unless-stopped From 6aaf22baab94d707d5b07ed725411ba7aaf98979 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 00:39:20 +0200 Subject: [PATCH 16/34] feat: generate nginx config --- nginx.sh | 37 +++++++++++++++++++++++++++++++++++++ setup.sh | 5 +++-- template.nginx.conf | 15 +++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100755 nginx.sh create mode 100644 template.nginx.conf diff --git a/nginx.sh b/nginx.sh new file mode 100755 index 0000000..a621f4e --- /dev/null +++ b/nginx.sh @@ -0,0 +1,37 @@ +if [ -f "huly.conf" ]; then + source "huly.conf" +fi + +# Check for --recreate flag +RECREATE=false +if [ "$1" == "--recreate" ]; then + RECREATE=true +fi + +# Handle nginx.conf recreation or updating +if [ "$RECREATE" == true ]; then + cp template.nginx.conf nginx.conf + echo "nginx.conf has been recreated from the template." +else + if [ ! -f "nginx.conf" ]; then + echo "nginx.conf not found, creating from template." + cp template.nginx.conf nginx.conf + else + echo "nginx.conf already exists. Only updating server_name and proxy_pass." + echo "Run with --recreate to fully overwrite nginx.conf." + fi +fi + +sed -i "s|server_name .*;|server_name ${HOST_ADDRESS};|" ./nginx.conf +sed -i "s|proxy_pass .*;|proxy_pass http://${HTTP_BIND:-127.0.0.1}:${HTTP_PORT};|" ./nginx.conf + +# Update listen directive to either port 80 or 443, while preserving IP address +if [[ -n "$SECURE" ]]; then + # Secure (use port 443 and add 'ssl') + sed -i -E "s|(listen )(.*:)?([0-9]+)?;|\1\2443 ssl;|" ./nginx.conf + echo "Serving over SSL. Make sure to add your SSL certificates." +else + # Non-secure (use port 80 and remove 'ssl') + sed -i -E "s|(listen )(.*:)?[0-9]+ ssl;|\1\280;|" ./nginx.conf + sed -i -E "s|(listen )(.*:)?[0-9]+;|\1\280;|" ./nginx.conf +fi diff --git a/setup.sh b/setup.sh index 324edbd..db27335 100755 --- a/setup.sh +++ b/setup.sh @@ -35,7 +35,7 @@ if [[ "$_HOST_ADDRESS" == "localhost" || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[ SECURE="" else while true; do - read -p "Will you serve Huly over SSL? (y/N) [default: ${SECURE}]: " input + read -p "Will you serve Huly over SSL? (y/n) [default: ${SECURE}]: " input case "${input}" in [Yy]* ) _SECURE="true"; break;; @@ -90,4 +90,5 @@ case "${RUN_DOCKER:-Y}" in ;; esac -echo -e "\033[1;32mSetup is complete!\033[0m" +echo -e "\033[1;32mSetup is complete!\n Generating nginx.conf...\033[0m" +./nginx \ No newline at end of file diff --git a/template.nginx.conf b/template.nginx.conf new file mode 100644 index 0000000..cfbffff --- /dev/null +++ b/template.nginx.conf @@ -0,0 +1,15 @@ +server { + server_name ; + listen ; + location / { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_pass ; + } +} \ No newline at end of file From bd03cbbbc75a2d3511c90098d483d5d71602943e Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 00:40:15 +0200 Subject: [PATCH 17/34] chore: update readme --- README.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9b1ada7..2e504fc 100644 --- a/README.md +++ b/README.md @@ -19,33 +19,35 @@ $ sudo snap install docker ## Clone the `huly-selfhost` repository and configure `nginx` -Next, let's clone the `huly-selfhost` repository and configure the server address. _Please replace **x.y.z.w** with your server's IP address_. +Next, let's clone the `huly-selfhost` repository and configure Huly. ```bash $ git clone https://github.com/hcengineering/huly-selfhost.git $ cd huly-selfhost -$ ./setup.sh x.y.z.w # Replace x.y.z.w with your server's IP address -$ sudo ln -s $(pwd)/nginx.conf /etc/nginx/sites-enabled/ +$ ./setup.sh ``` +This will generate a [huly.conf](./huly.conf) file with your chosen values and create your nginx config. -## Now we're ready to run Huly +To add the generated configuration to your Nginx setup, run the following: +```bash +sudo ln -s $(pwd)/nginx.conf /etc/nginx/sites-enabled/ +``` +> [!NOTE] +> If you change `HOST_ADDRESS`, `HTTP_PORT`, `HTTP_BIND` be sure to update your [nginx.conf](./nginx.conf) by running: +> ```bash +> ./nginx.sh +> ``` +>You can safely execute this script after adding your custom configurations like ssl. It will only overwrite the necessary settings. -Finally, let's restart `nginx` and run Huly with `docker compose`. +Finally, let's reload `nginx` and start Huly with `docker compose`. ```bash -$ sudo systemctl restart nginx -$ sudo docker compose up +$ sudo nginx -s reload +$ sudo docker compose up -d ``` Now, launch your web browser and enjoy Huly! -## Security - -When exposing your self-hosted Huly deployment to the internet, it's crucial to implement some security measures to protect your server and data. - -1. Do not expose MongoDB, MinIO, and Elastic services to the internet. Huly does not require them to be accessible from the internet. -2. It is highly recommended to change the default credentials. By default the services, mentioned above, require no authentication, or use default well-known credentials. - ## Generating Public and Private VAPID keys for front-end You'll need `Node.js` installed on your machine. Installing `npm` on Debian based distro: From 2ac79dc429e88caea01cc6904026981daff6d145 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 00:42:33 +0200 Subject: [PATCH 18/34] fix: keep HTTP_BIND on setup rerun --- setup.sh | 1 + template.huly.conf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index db27335..05b225e 100755 --- a/setup.sh +++ b/setup.sh @@ -64,6 +64,7 @@ else echo "Run this script with --secret to generate a new secret." fi +export HTTP_BIND=$HTTP_BIND export SECURE=$_SECURE export HOST_ADDRESS=$_HOST_ADDRESS export HTTP_PORT=$_HTTP_PORT diff --git a/template.huly.conf b/template.huly.conf index 921115b..7364dc3 100644 --- a/template.huly.conf +++ b/template.huly.conf @@ -12,7 +12,7 @@ SECURE=${SECURE} # Specify the IP address to bind to; leave blank to bind to all interfaces (0.0.0.0). # Do not use IP:PORT format in HTTP_BIND or HTTP_PORT. HTTP_PORT=${HTTP_PORT} -HTTP_BIND= +HTTP_BIND=${HTTP_BIND} # The following configs are auto-generated by the setup script. # Please do not manually overwrite. From 1c825a636a7f08b6f6a833dcc5c8b7a5deddd741 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 00:54:55 +0200 Subject: [PATCH 19/34] chore: use dot files --- huly.nginx => .huly.nginx | 0 template.huly.conf => .template.huly.conf | 0 template.nginx.conf => .template.nginx.conf | 0 nginx.sh | 4 ++-- setup.sh | 12 ++++++------ 5 files changed, 8 insertions(+), 8 deletions(-) rename huly.nginx => .huly.nginx (100%) rename template.huly.conf => .template.huly.conf (100%) rename template.nginx.conf => .template.nginx.conf (100%) diff --git a/huly.nginx b/.huly.nginx similarity index 100% rename from huly.nginx rename to .huly.nginx diff --git a/template.huly.conf b/.template.huly.conf similarity index 100% rename from template.huly.conf rename to .template.huly.conf diff --git a/template.nginx.conf b/.template.nginx.conf similarity index 100% rename from template.nginx.conf rename to .template.nginx.conf diff --git a/nginx.sh b/nginx.sh index a621f4e..54f1345 100755 --- a/nginx.sh +++ b/nginx.sh @@ -10,12 +10,12 @@ fi # Handle nginx.conf recreation or updating if [ "$RECREATE" == true ]; then - cp template.nginx.conf nginx.conf + cp .template.nginx.conf nginx.conf echo "nginx.conf has been recreated from the template." else if [ ! -f "nginx.conf" ]; then echo "nginx.conf not found, creating from template." - cp template.nginx.conf nginx.conf + cp .template.nginx.conf nginx.conf else echo "nginx.conf already exists. Only updating server_name and proxy_pass." echo "Run with --recreate to fully overwrite nginx.conf." diff --git a/setup.sh b/setup.sh index 05b225e..364c6c8 100755 --- a/setup.sh +++ b/setup.sh @@ -56,11 +56,11 @@ if [ "$1" == "--secret" ]; then SECRET=true fi -if [ ! -f huly.secret ] || [ "$SECRET" == true ]; then - openssl rand -hex 32 > huly.secret - echo "Secret generated and stored in huly.secret" +if [ ! -f .huly.secret ] || [ "$SECRET" == true ]; then + openssl rand -hex 32 > .huly.secret + echo "Secret generated and stored in .huly.secret" else - echo -e "\033[33mhuly.secret already exists, not overwriting." + echo -e "\033[33m.huly.secret already exists, not overwriting." echo "Run this script with --secret to generate a new secret." fi @@ -68,9 +68,9 @@ export HTTP_BIND=$HTTP_BIND export SECURE=$_SECURE export HOST_ADDRESS=$_HOST_ADDRESS export HTTP_PORT=$_HTTP_PORT -export HULY_SECRET=$(cat huly.secret) +export HULY_SECRET=$(cat .huly.secret) -envsubst < template.huly.conf > $CONFIG_FILE +envsubst < .template.huly.conf > $CONFIG_FILE echo -e "\n\033[1;34mConfiguration Summary:\033[0m" echo -e "Host Address: \033[1;32m$_HOST_ADDRESS\033[0m" From da8828128e161fe61b931253a4f236c8d333430c Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 02:56:07 +0200 Subject: [PATCH 20/34] feat: improved nginx config creation --- .gitignore | 2 +- .template.nginx.conf | 3 +-- nginx.sh | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 6c0a79b..cdd189c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ letsencrypt/ traefik/docker-compose.yaml nginx.conf huly.conf -huly.secret \ No newline at end of file +.huly.secret \ No newline at end of file diff --git a/.template.nginx.conf b/.template.nginx.conf index cfbffff..4c37a07 100644 --- a/.template.nginx.conf +++ b/.template.nginx.conf @@ -9,7 +9,6 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass ; } -} \ No newline at end of file +} diff --git a/nginx.sh b/nginx.sh index 54f1345..5c0db1b 100755 --- a/nginx.sh +++ b/nginx.sh @@ -22,16 +22,44 @@ else fi fi +# Update server_name and proxy_pass sed -i "s|server_name .*;|server_name ${HOST_ADDRESS};|" ./nginx.conf sed -i "s|proxy_pass .*;|proxy_pass http://${HTTP_BIND:-127.0.0.1}:${HTTP_PORT};|" ./nginx.conf # Update listen directive to either port 80 or 443, while preserving IP address if [[ -n "$SECURE" ]]; then # Secure (use port 443 and add 'ssl') - sed -i -E "s|(listen )(.*:)?([0-9]+)?;|\1\2443 ssl;|" ./nginx.conf + sed -i -E '0,/listen/s|(listen )(.*:)?([0-9]+)?;|\1\2443 ssl;|' ./nginx.conf echo "Serving over SSL. Make sure to add your SSL certificates." else # Non-secure (use port 80 and remove 'ssl') sed -i -E "s|(listen )(.*:)?[0-9]+ ssl;|\1\280;|" ./nginx.conf - sed -i -E "s|(listen )(.*:)?[0-9]+;|\1\280;|" ./nginx.conf + sed -i -E "s|(listen )(.*:)?([0-9]+)?;|\1\280;|" ./nginx.conf fi + +IP_ADDRESS=$(grep -oP 'listen \K[^:]+(?=:[0-9]+ ssl;)' nginx.conf) +echo $IP_ADDRESS + +# Remove HTTP to HTTPS redirect server block if SSL is enabled +if [[ -z "$SECURE" ]]; then + echo "Enabling SSL; removing HTTP to HTTPS redirect block..." + # Remove the entire server block for port 80 + if grep -q 'return 301 https://$host$request_uri;' nginx.conf; then + sed -i '/# !/,/!/d' nginx.conf + fi +else + if grep -q 'return 301 https://$host$request_uri;' nginx.conf; then + sed -i '/# !/,/!/d' nginx.conf + fi + + # Check if the HTTP to HTTPS redirect block already exists + echo "Creating HTTP to HTTPS redirect..." + echo -e "# ! DO NOT REMOVE COMMENT +# DO NOT MODIFY, CHANGES WILL BE OVERWRITTEN +server { + listen ${IP_ADDRESS:+${IP_ADDRESS}:}80; + server_name ${HOST_ADDRESS}; + return 301 https://\$host\$request_uri; +} +# DO NOT REMOVE COMMENT !" >> ./nginx.conf +fi \ No newline at end of file From b09187f179f007c5f221331044f59a9f396ba0b4 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 03:02:28 +0200 Subject: [PATCH 21/34] chore: cleanup --- nginx.sh | 1 - setup.sh | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/nginx.sh b/nginx.sh index 5c0db1b..ca1b589 100755 --- a/nginx.sh +++ b/nginx.sh @@ -38,7 +38,6 @@ else fi IP_ADDRESS=$(grep -oP 'listen \K[^:]+(?=:[0-9]+ ssl;)' nginx.conf) -echo $IP_ADDRESS # Remove HTTP to HTTPS redirect server block if SSL is enabled if [[ -z "$SECURE" ]]; then diff --git a/setup.sh b/setup.sh index 364c6c8..d34683a 100755 --- a/setup.sh +++ b/setup.sh @@ -35,7 +35,7 @@ if [[ "$_HOST_ADDRESS" == "localhost" || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[ SECURE="" else while true; do - read -p "Will you serve Huly over SSL? (y/n) [default: ${SECURE}]: " input + read -p "Will you serve Huly over SSL? (y/n) [default: ${SECURE:-false}]: " input case "${input}" in [Yy]* ) _SECURE="true"; break;; @@ -92,4 +92,4 @@ case "${RUN_DOCKER:-Y}" in esac echo -e "\033[1;32mSetup is complete!\n Generating nginx.conf...\033[0m" -./nginx \ No newline at end of file +./nginx.sh \ No newline at end of file From ab7c977eb3e6647c7e30fc6b51ef254d735d62fb Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 03:08:28 +0200 Subject: [PATCH 22/34] chore: make nginx conf recognizable --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e504fc..fd2e17a 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ This will generate a [huly.conf](./huly.conf) file with your chosen values and c To add the generated configuration to your Nginx setup, run the following: ```bash -sudo ln -s $(pwd)/nginx.conf /etc/nginx/sites-enabled/ +sudo ln -s $(pwd)/nginx.conf /etc/nginx/sites-enabled/huly.conf ``` > [!NOTE] > If you change `HOST_ADDRESS`, `HTTP_PORT`, `HTTP_BIND` be sure to update your [nginx.conf](./nginx.conf) by running: From b029be0d13f267fc2d02a1e7e3a190d95cbd35db Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 03:25:31 +0200 Subject: [PATCH 23/34] feat: show current or default value --- setup.sh | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/setup.sh b/setup.sh index d34683a..fce921c 100755 --- a/setup.sh +++ b/setup.sh @@ -9,19 +9,27 @@ if [ -f "$CONFIG_FILE" ]; then fi while true; do - read -p "Enter the host address (domain name or IP) [default: ${HOST_ADDRESS:-}]: " input - _HOST_ADDRESS="${input:-${HOST_ADDRESS:-$(hostname -I | awk '{print $1}')}}" - # TODO: proper validation - # if [[ "$_HOST_ADDRESS" =~ ^[a-zA-Z0-9.-]+$ || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then - break - # else - # echo "Invalid host address. Please enter a valid domain name or IP." - # fi + if [[ -n "$HOST_ADDRESS" ]]; then + prompt_type="current" + prompt_value="${HOST_ADDRESS}" + else + prompt_type="default" + prompt_value="" + fi + read -p "Enter the host address (domain name or IP) [${prompt_type}: ${prompt_value}]: " input + _HOST_ADDRESS="${input:-${HOST_ADDRESS:-$(hostname -i)}}" + break done - while true; do - read -p "Enter the port for HTTP [default: ${HTTP_PORT:-80}]: " input + if [[ -n "$HTTP_PORT" ]]; then + prompt_type="current" + prompt_value="${HTTP_PORT}" + else + prompt_type="default" + prompt_value="80" + fi + read -p "Enter the port for HTTP [${prompt_type}: ${prompt_value}]: " input _HTTP_PORT="${input:-${HTTP_PORT:-80}}" if [[ "$_HTTP_PORT" =~ ^[0-9]+$ && "$_HTTP_PORT" -ge 1 && "$_HTTP_PORT" -le 65535 ]]; then break @@ -35,7 +43,14 @@ if [[ "$_HOST_ADDRESS" == "localhost" || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[ SECURE="" else while true; do - read -p "Will you serve Huly over SSL? (y/n) [default: ${SECURE:-false}]: " input + if [[ -n "$SECURE" ]]; then + prompt_type="current" + prompt_value="Yes" + else + prompt_type="default" + prompt_value="No" + fi + read -p "Will you serve Huly over SSL? (y/n) [${prompt_type}: ${prompt_value}]: " input case "${input}" in [Yy]* ) _SECURE="true"; break;; @@ -84,7 +99,7 @@ read -p "Do you want to run 'docker compose up -d' now to start Huly? (Y/n): " R case "${RUN_DOCKER:-Y}" in [Yy]* ) echo -e "\033[1;32mRunning 'docker compose up -d' now...\033[0m" - docker compose up -d + sudo docker compose up -d ;; [Nn]* ) echo "You can run 'docker compose up -d' later to start Huly." From bfa293ba8f7d789ea266aa6692d4d269c8680313 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 03:27:15 +0200 Subject: [PATCH 24/34] fix(compose): point to dotfile --- compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yml b/compose.yml index f98abcc..8b89fa5 100644 --- a/compose.yml +++ b/compose.yml @@ -5,7 +5,7 @@ services: ports: - "${HTTP_BIND}:${HTTP_PORT}:80" volumes: - - ./huly.nginx:/etc/nginx/conf.d/default.conf + - ./.huly.nginx:/etc/nginx/conf.d/default.conf restart: unless-stopped mongodb: From ee4b1406a526e729dabdbc932808896d16d031fa Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 03:28:17 +0200 Subject: [PATCH 25/34] eat: prompt to reload nginx --- nginx.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nginx.sh b/nginx.sh index ca1b589..567eca6 100755 --- a/nginx.sh +++ b/nginx.sh @@ -17,7 +17,7 @@ else echo "nginx.conf not found, creating from template." cp .template.nginx.conf nginx.conf else - echo "nginx.conf already exists. Only updating server_name and proxy_pass." + echo "nginx.conf already exists. Only updating server_name, listen and proxy_pass." echo "Run with --recreate to fully overwrite nginx.conf." fi fi @@ -61,4 +61,15 @@ server { return 301 https://\$host\$request_uri; } # DO NOT REMOVE COMMENT !" >> ./nginx.conf -fi \ No newline at end of file +fi + +read -p "Do you want to run 'nginx -s reload' now to load your updated Huly config? (Y/n): " RUN_NGINX +case "${RUN_NGINX:-Y}" in + [Yy]* ) + echo -e "\033[1;32mRunning 'nginx -s reload' now...\033[0m" + sudo nginx -s reload + ;; + [Nn]* ) + echo "You can run 'nginx -s reload' later to load your updated Huly config." + ;; +esac \ No newline at end of file From 32b2ccefc023e4447623922c05c66804de4e7c28 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 03:38:38 +0200 Subject: [PATCH 26/34] feat: add huly specific envs --- .template.huly.conf | 5 +++++ setup.sh | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.template.huly.conf b/.template.huly.conf index 7364dc3..6dbb5c9 100644 --- a/.template.huly.conf +++ b/.template.huly.conf @@ -14,6 +14,11 @@ SECURE=${SECURE} HTTP_PORT=${HTTP_PORT} HTTP_BIND=${HTTP_BIND} +# Huly specific variables +TITLE=${TITLE} +DEFAULT_LANGUAGE=${DEFAULT_LANGUAGE} +LAST_NAME_FIRST=${LAST_NAME_FIRST} + # The following configs are auto-generated by the setup script. # Please do not manually overwrite. diff --git a/setup.sh b/setup.sh index fce921c..d907fc7 100755 --- a/setup.sh +++ b/setup.sh @@ -79,10 +79,13 @@ else echo "Run this script with --secret to generate a new secret." fi -export HTTP_BIND=$HTTP_BIND -export SECURE=$_SECURE export HOST_ADDRESS=$_HOST_ADDRESS +export SECURE=$_SECURE export HTTP_PORT=$_HTTP_PORT +export HTTP_BIND=$HTTP_BIND +export TITLE=${TITLE:-Huly} +export DEFAULT_LANGUAGE=${DEFAULT_LANGUAGE:-en} +export LAST_NAME_FIRST=${LAST_NAME_FIRST:-true} export HULY_SECRET=$(cat .huly.secret) envsubst < .template.huly.conf > $CONFIG_FILE From 5e52247038d56b3c4a78aa9ebc7d49ebacb67174 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 19:37:08 +0200 Subject: [PATCH 27/34] chore: remove $ from readme This allows for easily copy and pasting the commands --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index fd2e17a..6fff4b1 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ If you prefer Kubernetes deployment, there is a sample Kubernetes configuration First, let's install `nginx` and `docker` using the commands below if you have not already installed them on your machine. ```bash -$ sudo apt update -$ sudo apt install nginx -$ sudo snap install docker +sudo apt update +sudo apt install nginx +sudo snap install docker ``` ## Clone the `huly-selfhost` repository and configure `nginx` @@ -22,9 +22,9 @@ $ sudo snap install docker Next, let's clone the `huly-selfhost` repository and configure Huly. ```bash -$ git clone https://github.com/hcengineering/huly-selfhost.git -$ cd huly-selfhost -$ ./setup.sh +git clone https://github.com/hcengineering/huly-selfhost.git +cd huly-selfhost +./setup.sh ``` This will generate a [huly.conf](./huly.conf) file with your chosen values and create your nginx config. @@ -42,8 +42,8 @@ sudo ln -s $(pwd)/nginx.conf /etc/nginx/sites-enabled/huly.conf Finally, let's reload `nginx` and start Huly with `docker compose`. ```bash -$ sudo nginx -s reload -$ sudo docker compose up -d +sudo nginx -s reload +sudo docker compose up -d ``` Now, launch your web browser and enjoy Huly! From 47f585157c53f4251e34904eee7cb38a064e36aa Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Wed, 25 Sep 2024 19:40:12 +0200 Subject: [PATCH 28/34] chore(README.md): update nginx.conf note --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fff4b1..cff8e5d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ To add the generated configuration to your Nginx setup, run the following: sudo ln -s $(pwd)/nginx.conf /etc/nginx/sites-enabled/huly.conf ``` > [!NOTE] -> If you change `HOST_ADDRESS`, `HTTP_PORT`, `HTTP_BIND` be sure to update your [nginx.conf](./nginx.conf) by running: +> If you change `HOST_ADDRESS`, `SECURE`, `HTTP_PORT` or `HTTP_BIND` be sure to update your [nginx.conf](./nginx.conf) by running: > ```bash > ./nginx.sh > ``` From 2f51a3c1b22a3dfd3f26c0ba8fc4bcb4c4828024 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Thu, 26 Sep 2024 06:03:22 +0200 Subject: [PATCH 29/34] fix: use different method to get ip Signed-off-by: veryCrunchy --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index d907fc7..84bad2b 100755 --- a/setup.sh +++ b/setup.sh @@ -17,7 +17,7 @@ while true; do prompt_value="" fi read -p "Enter the host address (domain name or IP) [${prompt_type}: ${prompt_value}]: " input - _HOST_ADDRESS="${input:-${HOST_ADDRESS:-$(hostname -i)}}" + _HOST_ADDRESS="${input:-${HOST_ADDRESS:-$(curl -s https://checkip.amazonaws.com)}}" break done From 7a177e2134e0eda36573c9de7825c3bb8681f0ba Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Thu, 26 Sep 2024 06:22:44 +0200 Subject: [PATCH 30/34] fix(setup.sh): keep port on rerun --- setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 84bad2b..eaea6d6 100755 --- a/setup.sh +++ b/setup.sh @@ -14,10 +14,10 @@ while true; do prompt_value="${HOST_ADDRESS}" else prompt_type="default" - prompt_value="" + prompt_value="localhost" fi read -p "Enter the host address (domain name or IP) [${prompt_type}: ${prompt_value}]: " input - _HOST_ADDRESS="${input:-${HOST_ADDRESS:-$(curl -s https://checkip.amazonaws.com)}}" + _HOST_ADDRESS="${input:-${HOST_ADDRESS:-localhost}}" break done @@ -38,8 +38,8 @@ while true; do fi done -if [[ "$_HOST_ADDRESS" == "localhost" || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then - _HOST_ADDRESS="${_HOST_ADDRESS}:\${HTTP_PORT}" +if [[ "$_HOST_ADDRESS" == "localhost" || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}:?$ ]]; then + _HOST_ADDRESS="${_HOST_ADDRESS%:}:\${HTTP_PORT}" SECURE="" else while true; do From 4fe8477f3d5c4a98381973ad350c601c43aeb03e Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Thu, 26 Sep 2024 06:28:17 +0200 Subject: [PATCH 31/34] fix: specify bak for sed for mac compatibility --- .gitignore | 1 + nginx.sh | 33 ++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index cdd189c..34c6225 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ letsencrypt/ traefik/docker-compose.yaml nginx.conf +nginx.conf.bak huly.conf .huly.secret \ No newline at end of file diff --git a/nginx.sh b/nginx.sh index 567eca6..649abf3 100755 --- a/nginx.sh +++ b/nginx.sh @@ -1,3 +1,5 @@ +#!/bin/bash + if [ -f "huly.conf" ]; then source "huly.conf" fi @@ -17,41 +19,42 @@ else echo "nginx.conf not found, creating from template." cp .template.nginx.conf nginx.conf else - echo "nginx.conf already exists. Only updating server_name, listen and proxy_pass." + echo "nginx.conf already exists. Only updating server_name, listen, and proxy_pass." echo "Run with --recreate to fully overwrite nginx.conf." fi fi -# Update server_name and proxy_pass -sed -i "s|server_name .*;|server_name ${HOST_ADDRESS};|" ./nginx.conf -sed -i "s|proxy_pass .*;|proxy_pass http://${HTTP_BIND:-127.0.0.1}:${HTTP_PORT};|" ./nginx.conf +# Update server_name and proxy_pass using sed +sed -i.bak "s|server_name .*;|server_name ${HOST_ADDRESS};|" ./nginx.conf +sed -i.bak "s|proxy_pass .*;|proxy_pass http://${HTTP_BIND:-127.0.0.1}:${HTTP_PORT};|" ./nginx.conf # Update listen directive to either port 80 or 443, while preserving IP address if [[ -n "$SECURE" ]]; then # Secure (use port 443 and add 'ssl') - sed -i -E '0,/listen/s|(listen )(.*:)?([0-9]+)?;|\1\2443 ssl;|' ./nginx.conf + sed -i.bak -E 's|(listen )(.*:)?([0-9]+)?;|\1443 ssl;|' ./nginx.conf echo "Serving over SSL. Make sure to add your SSL certificates." else # Non-secure (use port 80 and remove 'ssl') - sed -i -E "s|(listen )(.*:)?[0-9]+ ssl;|\1\280;|" ./nginx.conf - sed -i -E "s|(listen )(.*:)?([0-9]+)?;|\1\280;|" ./nginx.conf + sed -i.bak -E "s|(listen )(.*:)?[0-9]+ ssl;|\1\280;|" ./nginx.conf + sed -i.bak -E "s|(listen )(.*:)?([0-9]+)?;|\1\280;|" ./nginx.conf fi +# Extract IP address for redirect configuration IP_ADDRESS=$(grep -oP 'listen \K[^:]+(?=:[0-9]+ ssl;)' nginx.conf) # Remove HTTP to HTTPS redirect server block if SSL is enabled if [[ -z "$SECURE" ]]; then echo "Enabling SSL; removing HTTP to HTTPS redirect block..." # Remove the entire server block for port 80 - if grep -q 'return 301 https://$host$request_uri;' nginx.conf; then - sed -i '/# !/,/!/d' nginx.conf + if grep -q 'return 301 https://\$host\$request_uri;' nginx.conf; then + sed -i.bak '/# !/,/!/d' nginx.conf fi else - if grep -q 'return 301 https://$host$request_uri;' nginx.conf; then - sed -i '/# !/,/!/d' nginx.conf + # Check if the HTTP to HTTPS redirect block already exists + if grep -q 'return 301 https://\$host\$request_uri;' nginx.conf; then + sed -i.bak '/# !/,/!/d' nginx.conf fi - # Check if the HTTP to HTTPS redirect block already exists echo "Creating HTTP to HTTPS redirect..." echo -e "# ! DO NOT REMOVE COMMENT # DO NOT MODIFY, CHANGES WILL BE OVERWRITTEN @@ -66,9 +69,9 @@ fi read -p "Do you want to run 'nginx -s reload' now to load your updated Huly config? (Y/n): " RUN_NGINX case "${RUN_NGINX:-Y}" in [Yy]* ) - echo -e "\033[1;32mRunning 'nginx -s reload' now...\033[0m" - sudo nginx -s reload - ;; + echo -e "\033[1;32mRunning 'nginx -s reload' now...\033[0m" + sudo nginx -s reload + ;; [Nn]* ) echo "You can run 'nginx -s reload' later to load your updated Huly config." ;; From 86986c612518dd283da885a894981588ee079e3d Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Thu, 26 Sep 2024 06:47:40 +0200 Subject: [PATCH 32/34] fix(nginx.sh): grep mac compatibility --- nginx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.sh b/nginx.sh index 649abf3..4c0ec0f 100755 --- a/nginx.sh +++ b/nginx.sh @@ -40,7 +40,7 @@ else fi # Extract IP address for redirect configuration -IP_ADDRESS=$(grep -oP 'listen \K[^:]+(?=:[0-9]+ ssl;)' nginx.conf) +IP_ADDRESS=$(grep -oE 'listen \K[^:]+(?=:[0-9]+ ssl;)' nginx.conf) # Remove HTTP to HTTPS redirect server block if SSL is enabled if [[ -z "$SECURE" ]]; then From 19e894281bc29063b9fbaddc9dc168957daa3783 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Thu, 21 Nov 2024 05:03:38 +0100 Subject: [PATCH 33/34] chore: fix local instances --- setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index eaea6d6..21879fa 100755 --- a/setup.sh +++ b/setup.sh @@ -37,9 +37,9 @@ while true; do echo "Invalid port. Please enter a number between 1 and 65535." fi done - -if [[ "$_HOST_ADDRESS" == "localhost" || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}:?$ ]]; then - _HOST_ADDRESS="${_HOST_ADDRESS%:}:\${HTTP_PORT}" +echo $_HOST_ADDRESS $HOST_ADDRESS $_HTTP_PORT $HTTP_PORT +if [[ "$_HOST_ADDRESS" == "localhost" || "$_HOST_ADDRESS" == "127.0.0.1" || "$_HOST_ADDRESS" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}:?$ ]]; then + _HOST_ADDRESS="${_HOST_ADDRESS%:}:${_HTTP_PORT}" SECURE="" else while true; do From b407f724aa56621262f8791dff35a5a3a3e81ce7 Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Tue, 3 Dec 2024 21:55:42 +0100 Subject: [PATCH 34/34] chore: remove duplicate env --- compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/compose.yml b/compose.yml index 89bbfab..91a06c7 100644 --- a/compose.yml +++ b/compose.yml @@ -103,7 +103,6 @@ services: workspace: image: hardcoreeng/workspace:${HULY_VERSION} environment: - - SERVER_SECRET=${HULY_SECRET} - SERVER_SECRET=${SECRET} - DB_URL=mongodb://mongodb:27017 - MONGO_URL=mongodb://mongodb:27017