From c4e341e2842ac6b4a103b634c3298caa81f666ad Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sun, 12 Jan 2025 22:39:57 +0100 Subject: [PATCH] chore: add hoppscotch self hosting experiment data --- docker compositions/hoppscotch/.env | 87 ++++++++++ docker compositions/hoppscotch/.env.upstream | 83 ++++++++++ docker compositions/hoppscotch/README.md | 26 +++ .../hoppscotch/docker-compose.upstream.yml | 155 ++++++++++++++++++ .../hoppscotch/docker-compose.yml | 98 +++++++++++ knowledge base/hoppscotch.md | 11 +- knowledge base/self-hosting.md | 2 + 7 files changed, 459 insertions(+), 3 deletions(-) create mode 100644 docker compositions/hoppscotch/.env create mode 100644 docker compositions/hoppscotch/.env.upstream create mode 100644 docker compositions/hoppscotch/README.md create mode 100644 docker compositions/hoppscotch/docker-compose.upstream.yml create mode 100644 docker compositions/hoppscotch/docker-compose.yml diff --git a/docker compositions/hoppscotch/.env b/docker compositions/hoppscotch/.env new file mode 100644 index 0000000..057e4e5 --- /dev/null +++ b/docker compositions/hoppscotch/.env @@ -0,0 +1,87 @@ +#-----------------------Backend Config------------------------------# + +# Prisma Config +DATABASE_URL=postgresql://postgres:dbPassword@db:5432/hoppscotch + +# (Optional) By default, the AIO container (when in subpath access mode) exposes the endpoint on port 80. +# Use this setting to specify a different port if needed. +HOPP_AIO_ALTERNATE_PORT=80 + +# Auth Tokens Config +JWT_SECRET=secretcode123 +TOKEN_SALT_COMPLEXITY=10 +MAGIC_LINK_TOKEN_VALIDITY=3 +REFRESH_TOKEN_VALIDITY=604800000 # Default validity is 7 days (604800000 ms) in ms +ACCESS_TOKEN_VALIDITY=86400000 # Default validity is 1 day (86400000 ms) in ms +SESSION_SECRET=anothersecretcode123 + +# Recommended to be true. Set to false if you are using http. +# Note: Some auth providers may not support http requests and may stop working when set to false. +ALLOW_SECURE_COOKIES=false + +# Sensitive Data Encryption Key while storing in Database (32 character) +# FIXME +DATA_ENCRYPTION_KEY=******************************** + +# Hoppscotch App Domain Config +REDIRECT_URL=http://localhost:3000 +WHITELISTED_ORIGINS=http://localhost:3170,http://localhost:3000,http://localhost:3100 +VITE_ALLOWED_AUTH_PROVIDERS=GOOGLE,GITHUB,MICROSOFT,EMAIL + +# Google Auth Config +# FIXME +GOOGLE_CLIENT_ID=***** +GOOGLE_CLIENT_SECRET=***** +GOOGLE_CALLBACK_URL=http://localhost:3170/v1/auth/google/callback +GOOGLE_SCOPE=email,profile + +# Github Auth Config +# FIXME +GITHUB_CLIENT_ID=***** +GITHUB_CLIENT_SECRET=**** +GITHUB_CALLBACK_URL=http://localhost:3170/v1/auth/github/callback +GITHUB_SCOPE=user:email + +# Microsoft Auth Config +# FIXME +MICROSOFT_CLIENT_ID=***** +MICROSOFT_CLIENT_SECRET=***** +MICROSOFT_CALLBACK_URL=http://localhost:3170/v1/auth/microsoft/callback +MICROSOFT_SCOPE=user.read +MICROSOFT_TENANT=common + +# Mailer config +MAILER_SMTP_ENABLE=false +MAILER_USE_CUSTOM_CONFIGS=false +MAILER_ADDRESS_FROM= +MAILER_SMTP_URL=smtps://user@domain.com:pass@smtp.domain.com # used if custom mailer configs is false +# The following are used if custom mailer configs is true +MAILER_SMTP_HOST=smtp.domain.com +MAILER_SMTP_PORT=587 +MAILER_SMTP_SECURE=true +MAILER_SMTP_USER=user@domain.com +MAILER_SMTP_PASSWORD=pass +MAILER_TLS_REJECT_UNAUTHORIZED=true + +# Rate Limit Config +RATE_LIMIT_TTL=60 # In seconds +RATE_LIMIT_MAX=100 # Max requests per IP + +#-----------------------Frontend Config------------------------------# + +# Base URLs +VITE_BASE_URL=http://localhost:3000 +VITE_SHORTCODE_BASE_URL=http://localhost:3000 +VITE_ADMIN_URL=http://localhost:3100 + +# Backend URLs +VITE_BACKEND_GQL_URL=http://localhost:3170/graphql +VITE_BACKEND_WS_URL=wss://localhost:3170/graphql +VITE_BACKEND_API_URL=http://localhost:3170/v1 + +# Terms Of Service And Privacy Policy Links (Optional) +VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms +VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy + +# Set to for subpath based access +ENABLE_SUBPATH_BASED_ACCESS=false diff --git a/docker compositions/hoppscotch/.env.upstream b/docker compositions/hoppscotch/.env.upstream new file mode 100644 index 0000000..fc8cb75 --- /dev/null +++ b/docker compositions/hoppscotch/.env.upstream @@ -0,0 +1,83 @@ +#-----------------------Backend Config------------------------------# +# Prisma Config +DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch + +# Auth Tokens Config +JWT_SECRET="secret1233" +TOKEN_SALT_COMPLEXITY=10 +MAGIC_LINK_TOKEN_VALIDITY= 3 +# Default validity is 7 days (604800000 ms) in ms +REFRESH_TOKEN_VALIDITY="604800000" +# Default validity is 1 day (86400000 ms) in ms +ACCESS_TOKEN_VALIDITY="86400000" +SESSION_SECRET='add some secret here' +# Reccomended to be true, set to false if you are using http +# Note: Some auth providers may not support http requests +ALLOW_SECURE_COOKIES=true + +# Sensitive Data Encryption Key while storing in Database (32 character) +DATA_ENCRYPTION_KEY="data encryption key with 32 char" + +# Hoppscotch App Domain Config +REDIRECT_URL="http://localhost:3000" +WHITELISTED_ORIGINS="http://localhost:3170,http://localhost:3000,http://localhost:3100" +VITE_ALLOWED_AUTH_PROVIDERS=GOOGLE,GITHUB,MICROSOFT,EMAIL + +# Google Auth Config +GOOGLE_CLIENT_ID="************************************************" +GOOGLE_CLIENT_SECRET="************************************************" +GOOGLE_CALLBACK_URL="http://localhost:3170/v1/auth/google/callback" +GOOGLE_SCOPE="email,profile" + +# Github Auth Config +GITHUB_CLIENT_ID="************************************************" +GITHUB_CLIENT_SECRET="************************************************" +GITHUB_CALLBACK_URL="http://localhost:3170/v1/auth/github/callback" +GITHUB_SCOPE="user:email" + +# Microsoft Auth Config +MICROSOFT_CLIENT_ID="************************************************" +MICROSOFT_CLIENT_SECRET="************************************************" +MICROSOFT_CALLBACK_URL="http://localhost:3170/v1/auth/microsoft/callback" +MICROSOFT_SCOPE="user.read" +MICROSOFT_TENANT="common" + +# Mailer config +MAILER_SMTP_ENABLE="true" +MAILER_USE_CUSTOM_CONFIGS="false" +MAILER_ADDRESS_FROM='"From Name Here" ' + +MAILER_SMTP_URL="smtps://user@domain.com:pass@smtp.domain.com" # used if custom mailer configs is false + +# The following are used if custom mailer configs is true +MAILER_SMTP_HOST="smtp.domain.com" +MAILER_SMTP_PORT="587" +MAILER_SMTP_SECURE="true" +MAILER_SMTP_USER="user@domain.com" +MAILER_SMTP_PASSWORD="pass" +MAILER_TLS_REJECT_UNAUTHORIZED="true" + +# Rate Limit Config +RATE_LIMIT_TTL=60 # In seconds +RATE_LIMIT_MAX=100 # Max requests per IP + + +#-----------------------Frontend Config------------------------------# + + +# Base URLs +VITE_BASE_URL=http://localhost:3000 +VITE_SHORTCODE_BASE_URL=http://localhost:3000 +VITE_ADMIN_URL=http://localhost:3100 + +# Backend URLs +VITE_BACKEND_GQL_URL=http://localhost:3170/graphql +VITE_BACKEND_WS_URL=ws://localhost:3170/graphql +VITE_BACKEND_API_URL=http://localhost:3170/v1 + +# Terms Of Service And Privacy Policy Links (Optional) +VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms +VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy + +# Set to `true` for subpath based access +ENABLE_SUBPATH_BASED_ACCESS=false diff --git a/docker compositions/hoppscotch/README.md b/docker compositions/hoppscotch/README.md new file mode 100644 index 0000000..d2d0b91 --- /dev/null +++ b/docker compositions/hoppscotch/README.md @@ -0,0 +1,26 @@ +# Hoppscotch + +> **NOT** working + +Check example files in the [codebase]. + +
+ +[docker-compose file]
+[.env file] + +
+ +## Sources + +- [Codebase] + + + + +[.env file]: https://github.com/hoppscotch/hoppscotch/blob/main/.env.example +[codebase]: https://github.com/hoppscotch/hoppscotch +[docker-compose file]: https://github.com/hoppscotch/hoppscotch/blob/main/docker-compose.yml diff --git a/docker compositions/hoppscotch/docker-compose.upstream.yml b/docker compositions/hoppscotch/docker-compose.upstream.yml new file mode 100644 index 0000000..c0e60f8 --- /dev/null +++ b/docker compositions/hoppscotch/docker-compose.upstream.yml @@ -0,0 +1,155 @@ +--- +# To make it easier to self-host, we have a preset docker compose config that also +# has a container with a Postgres instance running. +# You can tweak around this file to match your instances + +services: + # This service runs the backend app in the port 3170 + hoppscotch-backend: + container_name: hoppscotch-backend + build: + dockerfile: prod.Dockerfile + context: . + target: backend + env_file: + - ./.env + restart: always + environment: + # Edit the below line to match your PostgresDB URL if you have an outside DB (make sure to update the .env file as well) + - DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch?connect_timeout=300 + - PORT=8080 + volumes: + # Uncomment the line below when modifying code. Only applicable when using the "dev" target. + # - ./packages/hoppscotch-backend/:/usr/src/app + - /usr/src/app/node_modules/ + depends_on: + hoppscotch-db: + condition: service_healthy + ports: + - "3180:80" + - "3170:3170" + + # The main hoppscotch app. This will be hosted at port 3000 + # NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for + # the SH admin dashboard server at packages/hoppscotch-selfhost-web/Caddyfile + hoppscotch-app: + container_name: hoppscotch-app + build: + dockerfile: prod.Dockerfile + context: . + target: app + env_file: + - ./.env + depends_on: + - hoppscotch-backend + ports: + - "3080:80" + - "3000:3000" + + # The Self Host dashboard for managing the app. This will be hosted at port 3100 + # NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for + # the SH admin dashboard server at packages/hoppscotch-sh-admin/Caddyfile + hoppscotch-sh-admin: + container_name: hoppscotch-sh-admin + build: + dockerfile: prod.Dockerfile + context: . + target: sh_admin + env_file: + - ./.env + depends_on: + - hoppscotch-backend + ports: + - "3280:80" + - "3100:3100" + + # The service that spins up all 3 services at once in one container + hoppscotch-aio: + container_name: hoppscotch-aio + restart: unless-stopped + build: + dockerfile: prod.Dockerfile + context: . + target: aio + env_file: + - ./.env + depends_on: + hoppscotch-db: + condition: service_healthy + ports: + - "3000:3000" + - "3100:3100" + - "3170:3170" + - "3080:80" + + # The preset DB service, you can delete/comment the below lines if + # you are using an external postgres instance + # This will be exposed at port 5432 + hoppscotch-db: + image: postgres:15 + ports: + - "5432:5432" + user: postgres + environment: + # The default user defined by the docker image + POSTGRES_USER: postgres + # NOTE: Please UPDATE THIS PASSWORD! + POSTGRES_PASSWORD: testpass + POSTGRES_DB: hoppscotch + healthcheck: + test: + [ + "CMD-SHELL", + "sh -c 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}'", + ] + interval: 5s + timeout: 5s + retries: 10 + + # All the services listed below are deprececated + hoppscotch-old-backend: + container_name: hoppscotch-old-backend + build: + dockerfile: packages/hoppscotch-backend/Dockerfile + context: . + target: prod + env_file: + - ./.env + restart: always + environment: + # Edit the below line to match your PostgresDB URL if you have an outside DB (make sure to update the .env file as well) + - DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch?connect_timeout=300 + - PORT=3000 + volumes: + # Uncomment the line below when modifying code. Only applicable when using the "dev" target. + # - ./packages/hoppscotch-backend/:/usr/src/app + - /usr/src/app/node_modules/ + depends_on: + hoppscotch-db: + condition: service_healthy + ports: + - "3170:3000" + + hoppscotch-old-app: + container_name: hoppscotch-old-app + build: + dockerfile: packages/hoppscotch-selfhost-web/Dockerfile + context: . + env_file: + - ./.env + depends_on: + - hoppscotch-old-backend + ports: + - "3000:8080" + + hoppscotch-old-sh-admin: + container_name: hoppscotch-old-sh-admin + build: + dockerfile: packages/hoppscotch-sh-admin/Dockerfile + context: . + env_file: + - ./.env + depends_on: + - hoppscotch-old-backend + ports: + - "3100:8080" diff --git a/docker compositions/hoppscotch/docker-compose.yml b/docker compositions/hoppscotch/docker-compose.yml new file mode 100644 index 0000000..f463ba9 --- /dev/null +++ b/docker compositions/hoppscotch/docker-compose.yml @@ -0,0 +1,98 @@ +--- +name: hoppscotch +networks: + hoppscotch: +volumes: + db: +services: + db: + image: postgres:15 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: dbPassword + POSTGRES_DB: hoppscotch + healthcheck: + test: pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB} + interval: 5s + timeout: 5s + retries: 10 + ports: + - '5432:5432' + networks: + - hoppscotch + volumes: + - 'db:/var/lib/postgresql/data' + db_initializer: + depends_on: + db: + condition: service_healthy + image: hoppscotch/hoppscotch-backend + env_file: + - .env + command: pnpx prisma migrate deploy + networks: + - hoppscotch + backend: + depends_on: + db: + condition: service_healthy + db_initializer: + condition: service_completed_successfully + build: + dockerfile: prod.Dockerfile + context: . + target: backend + env_file: + - .env + healthcheck: + test: wget -q -O '/dev/null' 'localhost:3170' + interval: 5s + timeout: 4s + retries: 10 + start_period: 5s + ports: + - '3170:3170' + - '3180:80' + networks: + - hoppscotch + restart: unless-stopped + # mailer: + # image: dockage/mailcatcher + # ports: + # - '1080:1080' + # - '1025:1025' + # networks: + # - hoppscotch + # restart: unless-stopped + frontend: + depends_on: + backend: + condition: service_healthy + build: + dockerfile: prod.Dockerfile + context: . + target: app + env_file: + - .env + ports: + - '3000:3000' + - '3080:80' + networks: + - hoppscotch + restart: unless-stopped + admin: + depends_on: + backend: + condition: service_healthy + build: + dockerfile: prod.Dockerfile + context: . + target: sh_admin + env_file: + - .env + ports: + - '80:80' + - '3100:3100' + networks: + - hoppscotch + restart: unless-stopped diff --git a/knowledge base/hoppscotch.md b/knowledge base/hoppscotch.md index 9ecd0cb..057148a 100644 --- a/knowledge base/hoppscotch.md +++ b/knowledge base/hoppscotch.md @@ -1,6 +1,7 @@ # Hoppscotch 1. [TL;DR](#tldr) +1. [Self-hosting](#self-hosting) 1. [Further readings](#further-readings) 1. [Sources](#sources) @@ -45,12 +46,16 @@ pw.env.set("idToken", jsonData.id_token); // Set "idToken" to the value Access the variables in the request section by referencing the variable in the format `<>`. -post-request scripts == tests. +Post-request scripts == tests. + +## Self-hosting + +TODO ## Further readings - [Website] -- [Main repository] +- [Codebase] - [Documentation] Alternatives: @@ -74,8 +79,8 @@ Alternatives: +[codebase]: https://github.com/hoppscotch/hoppscotch [documentation]: https://docs.hoppscotch.io/ -[main repository]: https://github.com/hoppscotch/hoppscotch [website]: https://hoppscotch.com/ diff --git a/knowledge base/self-hosting.md b/knowledge base/self-hosting.md index b89bb60..32cea7e 100644 --- a/knowledge base/self-hosting.md +++ b/knowledge base/self-hosting.md @@ -18,6 +18,7 @@ The _art_ of hosting and managing applications on one's own servers instead of c | [Gitlab] | Git server | [Gitea], [Gogs] | | [Gogs] | Git server | [Gitea], [Gitlab] | | [Home Assistant] | Home automation platform | | +| [Hoppscotch] | API development environment | [Yaade] | | [Immich] | Photo and video management solution | Google Photo, [PhotoPrism] | | [NextCloud] | File sharing platform | [OwnCloud] | | [Nginx Proxy Manager] | Reverse Proxy | | @@ -48,6 +49,7 @@ The _art_ of hosting and managing applications on one's own servers instead of c [baikal]: baikal.md [gitea]: gitea.md [gitlab]: gitlab/README.md +[hoppscotch]: hoppscotch.md [immich]: immich.md [nextcloud]: nextcloud.md [nginx proxy manager]: nginx%20proxy%20manager.md