教程:postman的平替hoppscotch,又叫postwoman,hoppscotch的docker-compose安装过程

1. 背景

postman强制登录,不登录不给用,登录也就算了,还默认自动同步,这样的话就尴尬了。有些私人的接口啊,私人的账密啊,私人的token啊,真心不敢同步到别人的服务器上,把隐私安全寄托在别人的节操上。

一直在找平替,也有几家国产,现在不都喊着支持国货嘛,试用了一下,也是各种登录,各种同步,各种大版本升级,然后小版本的内容就不见了,寻寻觅觅的,可算是找到了一款开源的平替。

hoppscotch,以前还叫做postwoman,看看这个命名,想干啥懂的都懂。

看了开源代码的文档,只说了原生docker的用法,自带的docker-compose又很多坑,本科普就是把这个过程捋一遍,理论上照着做就行!

2. 前期准备

2.1 准备docker-compose文件,两个版本,一个3合1,一个分开

  • 稍微介绍一下,hoppscotch的服务容器分为4个,1个容器是api测试平台hoppscotch-frontend,端口是3000,(也就是常用的使用界面),即前台界面,如图,眼熟吧,跟postman差不多,主要使用的也是这个:
    在这里插入图片描述

  • 1个容器是后端接口hoppscotch-backend,端口是3170,没啥好说,所有核心服务都在这个里

  • 1个容器是后台管理平台hoppscotch-admin,端口是3100,如图
    在这里插入图片描述

  • 还有一个容器就是postgresql数据库了,hoppscotch不能换数据库,说是用了postgresql的什么json独有的功能,不能换mysql

2.1.1 3合1版本(推荐)

  • 推荐使用这个版本,可以直接把3个服务合成1个启动
  • 只需要确认一下容器hoppscotch-db数据库配置就行,完全可以一点不改,直接拿来就用
# 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:
  # The service that spins up all 3 services at once in one container
  hoppscotch-aio:
    container_name: hoppscotch-aio
    image: hoppscotch/hoppscotch
    restart: unless-stopped
    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"
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    environment:
      # The default user defined by the docker image
      POSTGRES_USER: postgres
      # NOTE: Please UPDATE THIS PASSWORD!
      POSTGRES_PASSWORD: password
      POSTGRES_DB: hoppscotch
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "sh -c 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}'",
        ]
      interval: 5s
      timeout: 5s
      retries: 10

2.1.2 独立版本

  • 这个版本就是多个容器都分开了,各起各的
  • 直接在下面的docker-compose里修改成你自己版本的就行,主要就是改一下数据库连接
  • hoppscotch-backend容器里的DATABASE_URL,数据库连接,账号是postgresql默认的,可以不改,密码如果想改,要改对应的hoppscotch-db容器里的postgresql配置里的POSTGRES_PASSWORD字段,172.17.0.1这个要看你本地的docker 网络 ip(一般本地开发都用127.0.0.1,这个就是docker自己的本地开发ip,类似的),理论上应该是这个,可以通过ifconfig,找到docker0,复制列出来的ip就行
  • 其实除了172.17.0.1要确认一下是否一样,其他的都可以不改的
# 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
    image: hoppscotch/hoppscotch-backend
    restart: unless-stopped
    env_file:
      - ./.env
    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:password@172.17.0.1:5432/hoppscotch?connect_timeout=300
    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-frontend:
    container_name: hoppscotch-frontend
    image: hoppscotch/hoppscotch-frontend
    restart: unless-stopped
    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-admin:
    container_name: hoppscotch-admin
    image: hoppscotch/hoppscotch-admin
    restart: unless-stopped
    env_file:
      - ./.env
    depends_on:
      - hoppscotch-backend
    ports:
      - "3280:80"
      - "3100:3100"

  # 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"
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    environment:
      # The default user defined by the docker image
      POSTGRES_USER: postgres
      # NOTE: Please UPDATE THIS PASSWORD!
      POSTGRES_PASSWORD: password
      POSTGRES_DB: hoppscotch
    healthcheck
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值