chatgpt-web-dev / chatgpt-web

A third-party ChatGPT Web UI page built with Express and Vue3, through the official OpenAI completion API. / 用 Express 和 Vue3 搭建的第三方 ChatGPT 前端页面, 基于 OpenAI 官方 completion API.
https://chatgpt-web.dev
MIT License
1.67k stars 448 forks source link

mongo-gui连接mongodb超时 #279

Open DoNotSayYes opened 1 year ago

DoNotSayYes commented 1 year ago

请教下大佬,我用的以下数据库配置,但是mongo-gui服务起不来,log提示连接超时,请问知道可能是什么原因吗?@Kerwin1202

> Failed to connect mongoDB - MongoTimeoutError: Server selection timed out after 30000 ms
> Connecting to mongoDB @ mongodb://chatgpt:admin123@chatgpt:27017
  database:
    image: mongo
    container_name: mongo
    ports:
      - '27017:27017'
    expose:
      - '27017'
    volumes:
      - ./mongodb:/data/db
    environment:
      MONGO_INITDB_ROOT_USERNAME: chatgpt
      MONGO_INITDB_ROOT_PASSWORD: admin123
      MONGO_INITDB_DATABASE: chatgpt

  mongo-gui:
    container_name: mongo-gui
    image: ugleiton/mongo-gui
    container_name: mongo-ui
    restart: always
    ports:
      - '4321:4321'
    environment:
      - MONGO_URL=mongodb://chatgpt:admin123@chatgpt:27017
    links:
      - database
    depends_on:
      - database
Kerwin1202 commented 1 year ago

这个是 ip 之类的 docker 里就是另一个 service 名字

image
DoNotSayYes commented 1 year ago

这个是 ip 之类的 docker 里就是另一个 service 名字

image

不太明白,大佬,这里是需要怎么修改吗?@@Kerwin1202

Kerwin1202 commented 1 year ago

就是圈出来的 改为 database

DoNotSayYes commented 1 year ago

就是圈出来的 改为 database

好嘞,我试试,非常感谢

DoNotSayYes commented 1 year ago

修改完之后mongo-gui处于unhealthy的状态,有以下错误信息,我是错漏了哪些步骤么,大佬。@Kerwin1202

}
[Error: ENOENT: no such file or directory, stat '/app../public/index.html'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/app../public/index.html',
  expose: false,
  statusCode: 404,
  status: 404
}

以下是完整的yaml内容:

version: '3'

services:
  app:
    image: kerwin1202/chatgpt-web # 总是使用latest,更新时重新pull该tag镜像即可
    container_name: chatgptweb
    restart: unless-stopped
    ports:
      - 3002:3002
    environment:
      TZ: Asia/Shanghai
      # 访问jwt加密参数,可选 不为空则允许登录 同时需要设置 MONGODB_URL
      AUTH_SECRET_KEY:
      # 每小时最大请求次数,可选,默认无限
      MAX_REQUEST_PER_HOUR: 0
      # 网站名称
      SITE_TITLE: ChatGpt Web
      # mongodb 的连接字符串
      MONGODB_URL: 'mongodb://chatgpt:admin123@database:27017'
      # 开启注册之后 密码加密的盐
      PASSWORD_MD5_SALT: anysalt
      # 开启注册之后 超级管理邮箱
      ROOT_USER: huang@gmail.com
      # 网站是否开启注册 必须开启, 否则管理员都没法注册, 可后续关闭
      REGISTER_ENABLED: 'true'
      # 更多配置, 在运行后, 注册管理员, 在管理员页面中设置
    links:
      - database
    depends_on:
      - database
    networks:
      - chatgpt-ns

  database:
    image: mongo
    container_name: mongo
    ports:
      - '27017:27017'
    expose:
      - '27017'
    volumes:
      - ./mongodb:/data/db
    environment:
      MONGO_INITDB_ROOT_USERNAME: chatgpt
      MONGO_INITDB_ROOT_PASSWORD: admin123
      MONGO_INITDB_DATABASE: chatgpt

  mongo-gui:
    container_name: mongo-gui
    image: ugleiton/mongo-gui
    container_name: mongo-ui
    restart: always
    ports:
      - '4321:4321'
    environment:
      - MONGO_URL=mongodb://chatgpt:admin123@database:27017
    links:
      - database
    depends_on:
      - database

  nginx:
    image: nginx:alpine
    container_name: chatgptweb-database
    restart: unless-stopped
    ports:
      - '80:80'
    expose:
      - '80'
    volumes:
      - ./nginx/html:/usr/share/nginx/html
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    links:
      - app

volumes:
  mongodb: {}

networks:
  chatgpt-ns:
    driver: bridge
Kerwin1202 commented 1 year ago

这个不要就可以了

image
DoNotSayYes commented 1 year ago

这个不要就可以了 image

很奇怪,我去掉了nginx的配置,docker-compose起来之后还是报一样的错误,大佬知道有可能是什么导致的吗?@Kerwin1202

root@iZ6weet4o735xl9smc4i8pZ:~/chatgpt# docker ps
CONTAINER ID   IMAGE                       COMMAND                  CREATED         STATUS                     PORTS                                           NAMES
9a5b9252175c   kerwin1202/chatgpt-web      "docker-entrypoint.s…"   2 minutes ago   Up 2 minutes               0.0.0.0:3002->3002/tcp, :::3002->3002/tcp       chatgptweb
e2848dfec303   ugleiton/mongo-gui          "sh /app/entrypoint.…"   2 minutes ago   Up 2 minutes (unhealthy)   0.0.0.0:4321->4321/tcp, :::4321->4321/tcp       mongo-ui
a81ce93816bb   mongo                       "docker-entrypoint.s…"   2 minutes ago   Up 2 minutes               0.0.0.0:27017->27017/tcp, :::27017->27017/tcp   mongo
root@iZ6weet4o735xl9smc4i8pZ:~/chatgpt# docker logs mongo-ui
> Connecting to mongoDB @ mongodb://chatgpt:admin123@database:27017
> Connected
> Access Mongo GUI at http://localhost:4321
[Error: ENOENT: no such file or directory, stat '/app../public/index.html'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/app../public/index.html',
  expose: false,
  statusCode: 404,
  status: 404
}

访问页面返回了500:

image
toniexly commented 1 year ago

我也碰到这个问题,你看用mango-gui进去看下数据库就知道了,应该是不知道什么原因没有创建设置里说的chatgpt数据库。。。我也不懂怎么解决,等大佬看看吧