Files
dokploy/apps/dokploy/templates/chatwoot/docker-compose.yml
2024-11-13 05:33:37 -05:00

129 lines
3.5 KiB
YAML

version: "3.8"
services:
base: &base
image: chatwoot/chatwoot:v3.14.1
networks:
- dokploy-network
volumes:
- storage_data:/app/storage
postgres:
image: postgres:12
networks:
- dokploy-network
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=chatwoot_production
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -h localhost -d chatwoot_production"]
interval: 10s
timeout: 5s
retries: 5
restart: always
redis:
image: redis:alpine
networks:
- dokploy-network
command: ["sh", "-c", "redis-server --requirepass \"${REDIS_PASSWORD}\""]
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
restart: always
setup:
<<: *base
environment:
- NODE_ENV=production
- RAILS_ENV=production
- INSTALLATION_ENV=docker
- FRONTEND_URL=http://${CHATWOOT_HOST}
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
- POSTGRES_HOST=postgres
- POSTGRES_USERNAME=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DATABASE=chatwoot_production
- REDIS_URL=redis://redis:6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- ENABLE_ACCOUNT_SIGNUP=false
- FORCE_SSL=false
- RAILS_LOG_TO_STDOUT=true
command: >
sh -c "
echo 'Waiting for postgres...'
while ! PGPASSWORD='${POSTGRES_PASSWORD}' psql -h postgres -U postgres -d chatwoot_production -c 'SELECT 1' > /dev/null 2>&1; do
sleep 1
done
echo 'PostgreSQL is ready!'
bundle exec rails db:chatwoot_prepare
"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
rails:
<<: *base
depends_on:
setup:
condition: service_completed_successfully
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
- NODE_ENV=production
- RAILS_ENV=production
- INSTALLATION_ENV=docker
- FRONTEND_URL=http://${CHATWOOT_HOST}
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
- POSTGRES_HOST=postgres
- POSTGRES_USERNAME=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DATABASE=chatwoot_production
- REDIS_URL=redis://redis:6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- ENABLE_ACCOUNT_SIGNUP=false
- FORCE_SSL=false
- RAILS_LOG_TO_STDOUT=true
entrypoint: docker/entrypoints/rails.sh
command: ['bundle', 'exec', 'rails', 's', '-p', '3000', '-b', '0.0.0.0']
restart: always
sidekiq:
<<: *base
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
- NODE_ENV=production
- RAILS_ENV=production
- INSTALLATION_ENV=docker
- FRONTEND_URL=http://${CHATWOOT_HOST}
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
- POSTGRES_HOST=postgres
- POSTGRES_USERNAME=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DATABASE=chatwoot_production
- REDIS_URL=redis://redis:6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- FORCE_SSL=false
- RAILS_LOG_TO_STDOUT=true
command: ['bundle', 'exec', 'sidekiq', '-C', 'config/sidekiq.yml']
restart: always
volumes:
storage_data:
postgres_data:
redis_data: