跳到主內容

【DockerCompose】hoppscotch 安裝

使用線上版 https://hoppscotch.io/

確認安裝套件 (安裝 Node.js、npm、pnpm)

https://docs.hoppscotch.io/documentation/self-host/community-edition/prerequisites

安裝pnpm


✅ 最推薦:使用 curl 官方安裝腳本

curl -fsSL https://get.pnpm.io/install.sh | sh -

安裝完後,pnpm 會被安裝到:

  • ~/.local/share/pnpm

  • ~/.local/share/pnpm/pnpm 是主程式

  • 也會把 ~/.local/share/pnpm 加到你的 PATH 環境變數中(需重新開機或重新登入 shell)

如果你沒有自動加到 PATH,可手動加在 .bashrc.zshrc

export PATH="$HOME/.local/share/pnpm:$PATH"

然後重新載入:

source ~/.bashrc
# 或者
source ~/.zshrc

👇 替代方式:透過 npm 安裝(需先裝好 Node.js)

如果你已經有 Node.js 和 npm:

npm install -g pnpm

🚀 驗證是否安裝成功

pnpm -v

會輸出版本號,例如:

9.1.2

✅ 附註:如果你還沒裝 Node.js

建議搭配 nvm(Node Version Manager)來安裝 Node.js,再用 npmpnpm

# 安裝 nvm(Node.js 管理工具)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# 載入 nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# 安裝 Node.js(例如最新版)
nvm install node

# 再裝 pnpm
npm install -g pnpm

build Image &&  container

# clone 專案
git clone https://github.com/hoppscotch/hoppscotch.git

cd hoppscotch
# 確認port沒衝突(有的話要修改docker-compose.yml => ports)
hoppscotch-aio:
    profiles: ["default"]
    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:
      - "3005:3000"
      - "3100:3100"
      - "3170:3170"
      - "3200:3200"
      - "3080:80"

# 使用default 類型(profiles: ["default"])(all in one)
docker compose --profile default up -d

成功運行必要的容器後,下一步是建立管理員帳戶來管理 Hoppscotch。
系統會自動將第一個透過管理儀表板登入的使用者指定為管理員。

建立管理員帳號
  1. 開啟新的瀏覽器標籤並造訪http://localhost:3100
  2. 這將授予您存取管理儀表板的權限。
  3. 使用您的憑證登入或建立一個新帳戶。
  4. 第一個登入的使用者將被賦予管理員權限。

訪問 Hoppscotch 應用程式

設定管理員帳戶後,您現在可以開始使用 Hoppscotch 應用進行 API 測試和開發。

  1. 開啟新的瀏覽器標籤並造訪http://localhost:3000
  2. 開始使用 Hoppscotch 無縫測試和開發您的 API。