667 字
3 分钟
Hoppscotch 部署教程
Hoppscotch
部署教程
数据库准备
sudo -s -u postgrespsqlCREATE USER (用户名) WITH PASSWORD (密码)CREATE DATABASE (数据库名称)GRANT ALL PRIVILEGES ON DATABASE (数据库名称) to (用户名)使用 AIO 容器
创建并进入项目文件夹:
mkdir hoppscotchcd hoppscotch创建32个字符(无特殊符号)的密钥:
tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w 32 | head -1创建 .env 文件,内容参考如下:
#-----------------------Backend Config------------------------------#
# Prisma ConfigDATABASE_URL=postgresql://(用户名):(密码)@172.17.0.1:5432/(数据库名称) # or replace with your database URL
# (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=(服务端口)
# Sensitive Data Encryption Key while storing in Database (32 character)DATA_ENCRYPTION_KEY=(32个字符(无特殊符号)的密钥)
# Whitelisted origins for the Hoppscotch App.# This list controls which origins can interact with the app through cross-origin comms.# - localhost ports (3170, 3000, 3100): app, backend, development servers and services# - app://localhost_3200: Bundle server origin identifier# NOTE: `3200` here refers to the bundle server (port 3200) that provides the bundles,# NOT where the app runs. The app itself uses the `app://` protocol with dynamic# bundle names like `app://{bundle-name}/`WHITELISTED_ORIGINS=https://(你的域名),http://localhost:3170,http://localhost:3000,http://localhost:3100,app://localhost_3200,app://hoppscotch
#-----------------------Frontend Config------------------------------#
# Base URLsVITE_BASE_URL=https://(你的域名)VITE_SHORTCODE_BASE_URL=https://(你的域名)VITE_ADMIN_URL=https://(你的域名)/admin
# Backend URLsVITE_BACKEND_GQL_URL=https://(你的域名)/backend/graphqlVITE_BACKEND_WS_URL=wss://(你的域名)/backend/graphqlVITE_BACKEND_API_URL=https://(你的域名)/backend/v1
# Terms Of Service And Privacy Policy Links (Optional)VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/termsVITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy
# Set to `true` for subpath based accessENABLE_SUBPATH_BASED_ACCESS=true拉取容器:
docker pull hoppscotch/hoppscotch运行容器:
docker run -d -p (宿主机的服务端口):(容器的服务端口) --env-file .env --restart unless-stopped hoppscotch/hoppscotch宿主机的服务端口和容器的服务端口需要保持一致
数据库迁移
# 查询容器 iddocker ps -a# 创建 AIO 容器docker run -it --entrypoint sh --env-file .env hoppscotch/hoppscotch# 数据库迁移pnpm exec prisma migrate deploy用户登录 SMTP
容器运行后可通过 https://(你的域名)/admin 进入管理员控制面板
使用 网易邮箱 配置参考:
- Mailer From Address: 你的163邮箱地址
- Smtp Host: smtp.163.com
- Smtp Port: 465
- Smtp User: 你的163邮箱地址
- Smtp Password: 不是登录密码,是授权密码
- Smtp Secure: 勾选
- Smtp Ignore Tls: 不勾选
- Tls Reject Unauthorized: 勾选
用户登录 Github OAuth
使用 Github OAuth:
- 点击右上角头像,在下拉框中点击
Settings - 左侧侧边栏点击
Developer settings - 选择
OAuth Apps - 填写应用配置:
- Homepage URL: 域名根目录,例如
https://{你的域名}/ - Authorization callback URL: 授权回调,如果使用的 AIO,例如
https://{你的域名}/backend/v1/auth/github/callback - Client secrets: 创建客户端密钥
- Homepage URL: 域名根目录,例如
访问 https://你的域名/admin,进入 Settings >> Authentication >> OAuth:
- Client Id: 和 Github Auth App 里一样
- Client Secret: 使用 Github Auth App 创建的客户端密钥
- Callback Url: 和 Github Auth App 里一样
- Scope: 必须填写
user:email,固定的文本内容
Hoppscotch 部署教程
https://fuwari.vercel.app/posts/运维/hoppscotch-部署教程/