-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
149 lines (142 loc) Β· 5.98 KB
/
Copy pathdocker-compose.yaml
File metadata and controls
149 lines (142 loc) Β· 5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# =============================================================================
# UNTHREAD TELEGRAM BOT - DOCKER COMPOSE CONFIGURATION
# =============================================================================
# Complete application stack for the Unthread Telegram Bot integration
#
# Services:
# ββ server β Main Telegram bot application
# ββ unthread-webhook-server β Handles incoming Unthread webhooks
# ββ postgres-platform β PostgreSQL database for bot data
# ββ redis-platform β Redis for bot operations & caching
# ββ redis-webhook β Redis for webhook message queuing
#
# Usage:
# docker-compose up -d # Start all services
# docker-compose logs -f server # View bot logs
# docker-compose exec postgres-platform psql -U postgres -d unthread_telegram_bot
#
# Prerequisites:
# - Copy .env.example to .env and configure your tokens
# - Ensure external network exists: docker network create unthread-integration-network
# =============================================================================
services:
# =============================================================================
# TELEGRAM BOT APPLICATION
# =============================================================================
# Main Node.js application that handles Telegram bot interactions
server:
build: . # Build from local Dockerfile instead of pulling from Docker Hub
environment:
NODE_ENV: production
env_file:
- .env # Contains bot tokens, API keys, and database URLs
depends_on:
- postgres-platform # Requires database to be ready
- redis-platform # Requires Redis for caching
- redis-webhook # Requires Redis for webhook communication
networks:
- unthread-integration-network
# =============================================================================
# WEBHOOK SERVER
# =============================================================================
# Handles incoming webhooks from Unthread and queues them for processing
unthread-webhook-server:
image: wgtechlabs/unthread-webhook-server:latest
ports:
- "3000:3000" # Expose webhook endpoint
env_file:
- .env
environment:
# Override Redis URL to use webhook-specific Redis instance
- REDIS_URL=redis://redis-webhook:6379
# Set target platform for webhook routing
- TARGET_PLATFORM=telegram
depends_on:
redis-webhook:
condition: service_healthy # Wait for Redis to be ready
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- unthread-integration-network
# =============================================================================
# DATABASE
# =============================================================================
# PostgreSQL database for storing tickets, customers, and user states
postgres-platform:
image: ghcr.io/railwayapp-templates/postgres-ssl:17 # Railway's PostgreSQL 17 with SSL support
restart: always
environment:
POSTGRES_DB: ${POSTGRES_DB:-unthread_telegram_bot} # Database name (with fallback)
POSTGRES_USER: ${POSTGRES_USER} # Username from .env file
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # Password from .env file (secure!)
ports:
- "5432:5432" # Expose for external connections (optional)
volumes:
- postgres_data:/var/lib/postgresql/data # Persistent data storage
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- unthread-integration-network
# =============================================================================
# REDIS - PLATFORM OPERATIONS
# =============================================================================
# Redis instance for bot caching, session management, and general operations
redis-platform:
image: redis:8-alpine # Latest Redis with Alpine for smaller image size
restart: always
ports:
- "6379:6379" # Standard Redis port
volumes:
- redis_platform_data:/data # Persistent Redis data
command: redis-server --appendonly yes # Enable data persistence
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- unthread-integration-network
# =============================================================================
# REDIS - WEBHOOK OPERATIONS
# =============================================================================
# Dedicated Redis instance for webhook message queuing and communication
redis-webhook:
image: redis:8-alpine # Latest Redis with Alpine for smaller image size
ports:
- "6380:6379" # Different external port to avoid conflicts
volumes:
- redis_webhook_data:/data # Separate data storage
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 3s
retries: 3
start_period: 30s
networks:
- unthread-integration-network
# =============================================================================
# PERSISTENT VOLUMES
# =============================================================================
# Named volumes for data persistence across container restarts
volumes:
postgres_data: # PostgreSQL database files
redis_platform_data: # Redis platform cache data
redis_webhook_data: # Redis webhook queue data
# =============================================================================
# NETWORKING
# =============================================================================
# Shared network for communication between services
# Will be created automatically if it doesn't exist
networks:
unthread-integration-network:
driver: bridge
name: unthread-integration-network