小萝卜
发表于 2024-3-27 17:20:37
misakafa 发表于 2024-3-27 17:19
这个是iptables命令报错了,看看你的docker-compose.yml文件
version: '3'
services:
base: &base
image: chatwoot/chatwoot:latest
env_file: .env ## Change this file for customized env variables
volumes:
- /data/storage:/app/storage
rails:
<<: *base
depends_on:
- postgres
- redis
ports:
- '127.0.0.1:3000:3000'
environment:
- NODE_ENV=production
- RAILS_ENV=production
- INSTALLATION_ENV=docker
entrypoint: docker/entrypoints/rails.sh
command: ['bundle', 'exec', 'rails', 's', '-p', '3000', '-b', '0.0.0.0']
sidekiq:
<<: *base
depends_on:
- postgres
- redis
environment:
- NODE_ENV=production
- RAILS_ENV=production
- INSTALLATION_ENV=docker
command: ['bundle', 'exec', 'sidekiq', '-C', 'config/sidekiq.yml']
postgres:
image: postgres:12
restart: always
ports:
- '127.0.0.1:5431:5432'
volumes:
- /data/postgres:/var/lib/postgresql/data
environment:
- POSTGRES_DB=chatwoot
- POSTGRES_USER=postgres
# Please provide your own password.
- POSTGRES_PASSWORD=bb4539bbef963874da80cedc0ecaca989
redis:
image: redis:alpine
restart: always
command: ["sh", "-c", "redis-server --requirepass \"$REDIS_PASSWORD\""]
env_file: .env
volumes:
- /data/redis:/data
ports:
- '127.0.0.1:6378:6379'
misakafa
发表于 2024-3-27 17:37:34
小萝卜 发表于 2024-3-27 17:12
关闭防火墙还是连不上
docker的规则被你清掉了,删除镜像重新启吧,参考28楼提供docker-compose试试,docker-compose中的有些端口要改一下,别和你宝塔启动的服务端口冲突了
小萝卜
发表于 2024-3-27 17:49:45
misakafa 发表于 2024-3-27 17:37
docker的规则被你清掉了,删除镜像重新启吧,参考28楼提供docker-compose试试,docker-compose中的有些端 ...
# docker compose run --rm rails bundle exec rails db:chatwoot_prepare
WARN /www/wwwroot/support.rose.com/chatwoot/docker-compose.yaml: `version` is obsolete
[+] Creating 2/2
✔ Container chatwoot-redis-1 Created 2.5s
✔ Container chatwoot-postgres-1Created 2.5s
[+] Running 0/2
⠸ Container chatwoot-redis-1 Starting 4.3s
⠸ Container chatwoot-postgres-1Starting 4.3s
Error response from daemon: driver failed programming external connectivity on endpoint chatwoot-redis-1 (2ab104c1ba6c4af259ac6bab16adea28bd354c27006d252917b81b352ea19a62):(iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 127.0.0.1 --dport 6378 -j DNAT --to-destination 172.24.0.2:6379 ! -i br-0442c7e2ad68: iptables: No chain/target/match by that name.
(exit status 1))
# docker compose run --rm rails bundle exec rails db:chatwoot_prepare
WARN /www/wwwroot/support.rose.com/chatwoot/docker-compose.yaml: `version` is obsolete
[+] Creating 2/2
✔ Container chatwoot-redis-1 Created 2.1s
✔ Container chatwoot-postgres-1Created 2.1s
[+] Running 2/2
✔ Container chatwoot-redis-1 Started 2.1s
✔ Container chatwoot-postgres-1Started 2.1s
[+] Running 12/12
✔ rails 11 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 43.9s
✔ c926b61bad3b Pull complete 0.4s
✔ 0bfb8f508c71 Pull complete 0.4s
✔ e49674a1e21a Pull complete 0.3s
✔ a8d637e9f7e0 Pull complete 1.6s
✔ 80c3bd4e2c8c Pull complete 1.0s
✔ 71db01de2232 Pull complete 4.4s
✔ d81ce3c1e381 Pull complete 1.3s
✔ fb043248c8af Pull complete 7.7s
✔ 28c50097771b Pull complete 4.9s
✔ 6ac8f70d1ae3 Pull complete 4.9s
✔ 4f4fb700ef54 Pull complete 5.2s
+ rm -rf /app/tmp/pids/server.pid
+ rm -rf '/app/tmp/cache/*'
+ echo 'Waiting for postgres to become ready....'
Waiting for postgres to become ready....
+ docker/entrypoints/helpers/pg_database_url.rb
+ export 'POSTGRES_PORT=5432'
+ PG_READY='pg_isready -h postgres -p 5432 -U postgres'
+ pg_isready -h postgres -p 5432 -U postgres
postgres:5432 - accepting connections
+ echo 'Database ready to accept connections.'
Database ready to accept connections.
+ bundle install
Bundle complete! 126 Gemfile dependencies, 247 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Bundled gems are installed into `/gems`
+ BUNDLE='bundle check'
+ bundle check
The Gemfile's dependencies are satisfied
+ exec bundle exec rails db:chatwoot_prepare
Created database 'chatwoot_production'
rails aborted!
Redis::CannotConnectError: Connection refused - connect(2) for 127.0.0.1:6378 (Redis::CannotConnectError)
/app/lib/global_config.rb:24:in `block in clear_cache'
/app/lib/global_config.rb:24:in `clear_cache'
/app/db/seeds.rb:2:in `<main>'
/app/lib/tasks/db_enhancements.rake:28:in `rescue in block (3 levels) in <main>'
/app/lib/tasks/db_enhancements.rake:19:in `block (3 levels) in <main>'
/app/lib/tasks/db_enhancements.rake:18:in `each'
/app/lib/tasks/db_enhancements.rake:18:in `block (2 levels) in <main>'
Caused by:
RedisClient::CannotConnectError: Connection refused - connect(2) for 127.0.0.1:6378 (RedisClient::CannotConnectError)
/app/lib/global_config.rb:24:in `block in clear_cache'
/app/lib/global_config.rb:24:in `clear_cache'
/app/db/seeds.rb:2:in `<main>'
/app/lib/tasks/db_enhancements.rake:28:in `rescue in block (3 levels) in <main>'
/app/lib/tasks/db_enhancements.rake:19:in `block (3 levels) in <main>'
/app/lib/tasks/db_enhancements.rake:18:in `each'
/app/lib/tasks/db_enhancements.rake:18:in `block (2 levels) in <main>'
Caused by:
Errno::ECONNREFUSED: Connection refused - connect(2) for 127.0.0.1:6378 (Errno::ECONNREFUSED)/app/lib/global_config.rb:24:in `block in clear_cache'
/app/lib/global_config.rb:24:in `clear_cache'
/app/db/seeds.rb:2:in `<main>'
/app/lib/tasks/db_enhancements.rake:28:in `rescue in block (3 levels) in <main>'
/app/lib/tasks/db_enhancements.rake:19:in `block (3 levels) in <main>'
/app/lib/tasks/db_enhancements.rake:18:in `each'
/app/lib/tasks/db_enhancements.rake:18:in `block (2 levels) in <main>'
Caused by:
ActiveRecord::NoDatabaseError: We could not find your database: chatwoot_production. Which can be found in the database configuration file located at config/database.yml. (ActiveRecord::NoDatabaseError)
To resolve this issue:
- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.
To create your database, run:
bin/rails db:create
/app/lib/tasks/db_enhancements.rake:20:in `block (3 levels) in <main>'
/app/lib/tasks/db_enhancements.rake:18:in `each'
/app/lib/tasks/db_enhancements.rake:18:in `block (2 levels) in <main>'
Caused by:
PG::ConnectionBad: connection to server at "172.24.0.2", port 5432 failed: FATAL:database "chatwoot_production" does not exist (PG::ConnectionBad)
/app/lib/tasks/db_enhancements.rake:20:in `block (3 levels) in <main>'
/app/lib/tasks/db_enhancements.rake:18:in `each'
/app/lib/tasks/db_enhancements.rake:18:in `block (2 levels) in <main>'
Tasks: TOP => db:setup => db:seed
(See full trace by running task with --trace)
用28楼的配置文件把pgsql改成跟.env一样后就这样
misakafa
发表于 2024-3-27 18:59:50
小萝卜 发表于 2024-3-27 17:49
用28楼的配置文件把pgsql改成跟.env一样后就这样
搞好没
ceplavia
发表于 2024-3-27 19:02:29
你在容器内要怎么连127.0.0.1,redis在宿主机就把参数换成docker网卡的网关,要是redis也在容器内塞进一个网络里不就好了
misakafa
发表于 2024-3-27 19:04:21
本帖最后由 misakafa 于 2024-3-27 19:10 编辑
小萝卜 发表于 2024-3-27 17:49
用28楼的配置文件把pgsql改成跟.env一样后就这样
.env文件中REDIS_URL=redis://redis:6379 改成这个
docker-compose文件中这里改一下
redis:
image: redis:alpine
restart: always
command: ["sh", "-c", "redis-server --requirepass \"$REDIS_PASSWORD\""]
env_file: .env
volumes:
- ./data/redis:/data
ports:
- 6378:6379
在重新启一下试试
小萝卜
发表于 2024-3-27 19:38:04
misakafa 发表于 2024-3-27 19:04
.env文件中REDIS_URL=redis://redis:6379 改成这个
docker-compose文件中这里改一下
redis:
# docker compose run --rm rails bundle exec rails db:chatwoot_prepare
WARN /www/wwwroot/support.rosehacker.com/chatwoot/docker-compose.yaml: `version` is obsolete
[+] Creating 2/2
✔ Container chatwoot-redis-1 Created 1.0s
✔ Container chatwoot-postgres-1Created 1.0s
[+] Running 2/2
✔ Container chatwoot-redis-1 Started 1.8s
✔ Container chatwoot-postgres-1Started 1.9s
[+] Running 12/12
✔ rails 11 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 43.6s
✔ c926b61bad3b Pull complete 0.4s
✔ 0bfb8f508c71 Pull complete 0.4s
✔ e49674a1e21a Pull complete 0.3s
✔ a8d637e9f7e0 Pull complete 1.1s
✔ 80c3bd4e2c8c Pull complete 0.8s
✔ 71db01de2232 Pull complete 5.4s
✔ d81ce3c1e381 Pull complete 1.2s
✔ fb043248c8af Pull complete 7.0s
✔ 28c50097771b Pull complete 5.1s
✔ 6ac8f70d1ae3 Pull complete 5.5s
✔ 4f4fb700ef54 Pull complete 5.7s
+ rm -rf /app/tmp/pids/server.pid
+ rm -rf '/app/tmp/cache/*'
+ echo 'Waiting for postgres to become ready....'
Waiting for postgres to become ready....
+ docker/entrypoints/helpers/pg_database_url.rb
+ export 'POSTGRES_PORT=5432'
+ PG_READY='pg_isready -h postgres -p 5432 -U postgres'
+ pg_isready -h postgres -p 5432 -U postgres
postgres:5432 - accepting connections
+ echo 'Database ready to accept connections.'
Database ready to accept connections.
+ bundle install
Bundle complete! 126 Gemfile dependencies, 247 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Bundled gems are installed into `/gems`
+ BUNDLE='bundle check'
+ bundle check
The Gemfile's dependencies are satisfied
+ exec bundle exec rails db:chatwoot_prepare
Loading Installation config
现在按大佬说的改完,好像是完成了,但是访问起来还是502错误。
https://i.vgy.me/rVLqHY.png
misakafa
发表于 2024-3-27 20:10:32
小萝卜 发表于 2024-3-27 19:38
现在按大佬说的改完,好像是完成了,但是访问起来还是502错误。
自己看看是不是ngx配置错了
小萝卜
发表于 2024-3-27 22:46:49
misakafa 发表于 2024-3-27 20:10
自己看看是不是ngx配置错了
#PROXY-START/
location ^~ /
{
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
# proxy_hide_header Upgrade;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
set $static_filexRm0w58E 0;
if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
{
set $static_filexRm0w58E 1;
expires 1m;
}
if ( $static_filexRm0w58E = 0 )
{
add_header Cache-Control no-cache;
}
}
#PROXY-END/
刚刚出门了下,我感觉没有配错呢。
小萝卜
发表于 2024-3-27 22:52:19
misakafa 发表于 2024-3-27 20:10
自己看看是不是ngx配置错了
大佬方便加个联系方式不,虽然还没成功,但我感觉应该快成功了,发个小红包请你喝个奶茶。