本文主要研究一下如何用docker运行perplexica

步骤

git clone

git clone https://github.com/ItzCrazyKns/Perplexica.git

app.dockerfile

FROM docker.1ms.run/node:20.18.0-alpine

ARG NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
ARG NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
ENV NEXT_PUBLIC_WS_URL=${NEXT_PUBLIC_WS_URL}
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}

WORKDIR /home/perplexica

COPY ui /home/perplexica/
RUN yarn config set registry 'https://registry.npmmirror.com'
RUN yarn install --frozen-lockfile --verbose
RUN yarn build

CMD ["yarn", "start"]

backend.dockerfile

FROM docker.1ms.run/node:18-slim

WORKDIR /home/perplexica

COPY src /home/perplexica/src
COPY tsconfig.json /home/perplexica/
COPY drizzle.config.ts /home/perplexica/
COPY package.json /home/perplexica/
COPY yarn.lock /home/perplexica/

RUN mkdir /home/perplexica/data
RUN mkdir /home/perplexica/uploads

RUN yarn install --frozen-lockfile --network-timeout 600000
RUN yarn build

CMD ["yarn", "start"]

config.toml

[API_KEYS]
OPENAI = ""
GROQ = ""
ANTHROPIC = ""
GEMINI = ""

[API_ENDPOINTS]
OLLAMA = "http://host.docker.internal:11434"
SEARXNG = "http://127.0.0.1:4000"

[GENERAL]
PORT = 3_001
SIMILARITY_MEASURE = "cosine"
KEEP_ALIVE = "5m"

docker-compose.yaml

services:
  searxng:
    image: docker.1ms.run/searxng/searxng:latest
    volumes:
      - ./searxng:/etc/searxng:rw
    ports:
      - 4000:8080
    networks:
      - perplexica-network
    restart: unless-stopped

  perplexica-backend:
    build:
      context: .
      dockerfile: backend.dockerfile
    image: docker.1ms.run/itzcrazykns1337/perplexica-backend:main
    environment:
      - SEARXNG_API_URL=http://host.docker.internal:4000
      - OLLAMA=http://host.docker.internal:11434
    depends_on:
      - searxng
    ports:
      - 3001:3001
    volumes:
      - backend-dbstore:/home/perplexica/data
      - uploads:/home/perplexica/uploads
      - ./config.toml:/home/perplexica/config.toml
    # extra_hosts:
    #   - 'host.docker.internal:host-gateway'
    networks:
      - perplexica-network
    restart: unless-stopped

  perplexica-frontend:
    build:
      context: .
      dockerfile: app.dockerfile
      args:
        - NEXT_PUBLIC_API_URL=http://host.docker.internal:3001/api
        - NEXT_PUBLIC_WS_URL=ws://host.docker.internal:3001
    image: itzcrazykns1337/perplexica-frontend:main
    depends_on:
      - perplexica-backend
    ports:
      - 3000:3000
    networks:
      - perplexica-network
    restart: unless-stopped

networks:
  perplexica-network:

volumes:
  backend-dbstore:
  uploads:

运行

docker-compose up
之后访问http://localhost:3000,如果是searxng则访问http://localhost:4000

小结

searxng目前国内能访问的就是bing和wolframalpha,研究了半天添加搜狗搜索没成功,可能需要代码定制。perplexica目前还没有找到如何定制知识库,只能每次搜索的时候上传一下相关文档。

doc


codecraft
11.9k 声望2k 粉丝

当一个代码的工匠回首往事时,不因虚度年华而悔恨,也不因碌碌无为而羞愧,这样,当他老的时候,可以很自豪告诉世人,我曾经将代码注入生命去打造互联网的浪潮之巅,那是个很疯狂的时代,我在一波波的浪潮上留下...