环境
macOS BigSur11.6 docker
ruby
2.6.5
Rails 6.0.4
想要达到
谢谢收看!
我已经安装了 clamav,一个图像病毒检查器,但是在上传图像时,它会给出以下日志并停止。
docker仪表板中的clamav错误
/bootstrap.sh: line 35: 18 Killed clamd
日志中的错误
rescue500 => SocketError : getaddrinfo: Name does not resolve
/web/app/app/services/clamav_service.rb:4:in `initialize'
我的团队成员没有遇到这种情况,并且即使我重新创建开发环境,错误也只会出现在我的环境中。我的团队成员使用的是 windows,而我是唯一一个使用 mac 的人,这会有影响吗?
代码
示例应用程序/docker-compose.yml
version: '3.4'
services:
db:
container_name: 'sample-app-db'
image: mysql:5.7.10
environment:
MYSQL_ROOT_PASSWORD: password
TZ: "Asia/Tokyo"
ports:
- "33006:3306"
volumes:
- ./containers/mysql_data:/var/lib/mysql
command: --innodb-use-native-aio=0
nginx:
container_name: 'sample-app-nginx'
build: ./nginx
command: >
/bin/bash -c
"envsubst '$$NGINX_SERVER_NAME $$NGINX_SERVER_PORT' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
&& nginx -g 'daemon off;'"
environment:
- TZ=Asia/Tokyo
- NGINX_SERVER_NAME=dev.sample-app.jp
- NGINX_SERVER_PORT=80
ports:
- 80:80
- 443:443
volumes:
- tmp:/web/app/tmp
- public:/web/app/public
depends_on:
- web
logging:
driver: json-file
options:
max-file: '1'
max-size: 1m
web: &app_base
container_name: 'sample-app-web'
build:
context: .
args:
ASSETS_PRECOMPILE: 'false'
environment:
RAILS_ENV: development
DB_USER: root
DB_PASSWORD: password
DB_HOST: db
DB_DATABASE: sample-app_development
USER_OTP_SECRET: xxxxxxxxxxxxxxxxxx
CLAMD_TCP_HOST: clamav
CLAMD_TCP_PORT: 3310
TZ: "Asia/Tokyo"
command: sh -c "rm -f /web/app/tmp/pids/server.pid && bundle exec rails s"
tty: true
stdin_open: true
volumes:
- ./web:/web/app
- bundle:/usr/local/bundle
- tmp:/web/app/tmp
- public:/web/app/public
links:
- db
- clamav
depends_on:
- db
- clamav
logging:
driver: json-file
options:
max-file: '1'
max-size: 3m
webpack:
<<: *app_base
container_name: 'sample-app-webpack'
command: "ruby bin/webpack-dev-server"
ports:
- "3035:3035"
depends_on:
- web
tty: false
stdin_open: false
smtp:
image: schickling/mailcatcher
ports:
- "1080:1080"
- "1025:1025"
clamav:
image: mkodockx/docker-clamav
ports:
- 3310
environment:
- TZ=Asia/Tokyo
volumes:
- clamav:/var/lib/clamav
- ./containers/clamav/clamd.conf:/etc/clamd/clamd.conf:ro
- ./containers/clamav/freshclam.conf:/etc/clamd/freshclam.conf:ro
logging:
driver: json-file
options:
max-file: '1'
max-size: 1m
volumes:
mysql_data:
bundle:
tmp:
public:
clamav:
driver: local
示例应用程序/网络/应用程序/服务/clamav_service.rb
class ClamavService
def self.connect
ClamAV::Connection.new(
socket: TCPSocket.new(Settings.clamav.tcp_host, Settings.clamav.tcp_port),
wrapper: ClamAV::Wrappers::NewLineWrapper.new
)
end
def self.connect_client
ClamAV::Client.new self.connect
end
end
示例应用程序/web/config/settings/development.yml
application:
url: https://dev.sample-app.ai/
notification:
cc: xxxxxxxxxxxxxxxx@gmail.com
clamav:
tcp_host: <%= ENV['CLAMD_TCP_HOST'] %>
tcp_port: <%= ENV['CLAMD_TCP_PORT'] %>