docker内网部署hoppscotch
1.安装docker
(借鉴与)[https://book.loveliuran.cn/posts/study/docker]
2.安装Hoppscotch
2.1 在安装目录创建.env文件
#-----------------------Backend Config------------------------------#
# Prisma Config
DATABASE_URL=postgresql://admin:123456@postgres:5432/hoppscotch?schema=public # 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=80
# Auth Tokens Config
JWT_SECRET=secretcode123
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=anothersecretcode123
# Recommended 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=********************************
# Hoppscotch App Domain Config
REDIRECT_URL=http://192.168.110.251:3000
# 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=http://192.168.110.251:3170,http://192.168.110.251:3000,http://192.168.110.251:3100,app://localhost_3200,app://hoppscotch
VITE_ALLOWED_AUTH_PROVIDERS=GOOGLE,GITHUB,MICROSOFT,EMAIL
# Google Auth Config
GOOGLE_CLIENT_ID=************************************************
GOOGLE_CLIENT_SECRET=************************************************
GOOGLE_CALLBACK_URL=http://192.168.110.251:3170/v1/auth/google/callback
GOOGLE_SCOPE=email,profile
# Github Auth Config
GITHUB_CLIENT_ID=************************************************
GITHUB_CLIENT_SECRET=************************************************
GITHUB_CALLBACK_URL=http://192.168.110.251:3170/v1/auth/github/callback
GITHUB_SCOPE=user:email
# Microsoft Auth Config
MICROSOFT_CLIENT_ID=************************************************
MICROSOFT_CLIENT_SECRET=************************************************
MICROSOFT_CALLBACK_URL=http://192.168.110.251: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@example.com>
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=192.168.110.251
MAILER_SMTP_PORT=1025
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://192.168.110.251:3000
VITE_SHORTCODE_BASE_URL=http://192.168.110.251:3000
VITE_ADMIN_URL=http://192.168.110.251:3100
# Backend URLs
VITE_BACKEND_GQL_URL=http://192.168.110.251:3170/graphql
VITE_BACKEND_WS_URL=wss://192.168.110.251:3170/graphql
VITE_BACKEND_API_URL=http://192.168.110.251: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将上述IP地址修改为自己的IP地址。
2.2 创建docker-compose.yml文件
services:
hoppscotch:
image: hoppscotch/hoppscotch
container_name: hoppscotch
volumes:
- /home/hoppscotch-aio/hoppscotch/config:/config # 从本地创建一个目录挂载到容器中以保留原有配置
ports:
- 8888:80
- 3000:3000
- 3100:3100
- 3170:3170
- 3200:3200
env_file:
- .env
networks:
- postgres
restart: unless-stopped
networks:
postgres:
external: true2.3 由于会依赖smtp服务,需要启动smtp服务
启动smtp服务,这里使用docker启动,具体启动命令如下:
docker run -d --name smtp -p 1025:1025 -p 1080:1080 dockage/mailcatcher:latest2.4 启动Hoppscotch
docker-compose up -d注意首次需要初始化一下数据库中
sudo docker compose run hoppscotch sh pnpm dlx prisma migrate deploy然后重启容器就ok了
docker-compose restart hoppscotch