@@ -57,36 +57,128 @@ jobs:
5757 script : |
5858 echo "==== Altyapı Servisleri Yönetimi Başlatılıyor ===="
5959
60- set -e # Herhangi bir komut hata verirse scripti durdur
60+ set -e
6161
62- # Infrastructure dizinini oluştur (yoksa)
62+ # Infrastructure dizinini oluştur
6363 sudo mkdir -p /opt/craftpilot/infrastructure
6464 sudo chown -R $USER:$USER /opt/craftpilot/infrastructure
6565
6666 cd /opt/craftpilot/infrastructure || exit 1
6767
68- # Mevcut docker-compose.infra.yml dosyasını yedekle
69- if [ -f docker-compose.infra.yml ]; then
70- cp docker-compose.infra.yml docker-compose.infra.yml.bak.$(date +%Y%m%d%H%M%S)
71- fi
68+ # Docker compose dosyasını oluştur
69+ cat > docker-compose.infra.yml << 'EOL'
70+ version: "3.8"
7271
73- # GitHub repository'den docker-compose dosyasını indir ve hata kontrolü yap
74- echo "Docker compose dosyası indiriliyor..."
75- HTTP_CODE=$(curl -s -w '%{http_code}' -H "Accept: application/vnd.github.v3.raw" \
76- -o docker-compose.infra.yml \
77- -L "https://raw.githubusercontent.com/OmerSah/Craft-Pilot-Ai/main/infrastructure/docker-compose.infra.yml")
78-
79- if [ "$HTTP_CODE" != "200" ]; then
80- echo "HATA: docker-compose.infra.yml dosyası indirilemedi! HTTP Code: $HTTP_CODE"
81- exit 1
82- fi
72+ services:
73+ zookeeper:
74+ image: confluentinc/cp-zookeeper:7.3.0
75+ container_name: zookeeper
76+ restart: unless-stopped
77+ environment:
78+ ZOOKEEPER_CLIENT_PORT: 2181
79+ ZOOKEEPER_TICK_TIME: 2000
80+ ports:
81+ - "2181:2181"
82+ volumes:
83+ - zookeeper-data:/var/lib/zookeeper/data
84+ - zookeeper-log:/var/lib/zookeeper/log
85+ networks:
86+ - craftpilot-network
87+ healthcheck:
88+ test: ["CMD", "bash", "-c", "echo ruok | nc localhost 2181 | grep imok"]
89+ interval: 10s
90+ timeout: 5s
91+ retries: 5
92+ start_period: 30s
93+
94+ kafka:
95+ image: confluentinc/cp-kafka:7.3.0
96+ container_name: kafka
97+ restart: unless-stopped
98+ depends_on:
99+ zookeeper:
100+ condition: service_healthy
101+ ports:
102+ - "9092:9092"
103+ environment:
104+ KAFKA_BROKER_ID: 1
105+ KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
106+ KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
107+ KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
108+ KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
109+ KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
110+ KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
111+ volumes:
112+ - kafka-data:/var/lib/kafka/data
113+ networks:
114+ - craftpilot-network
115+ healthcheck:
116+ test: ["CMD-SHELL", "kafka-topics --bootstrap-server localhost:9092 --list"]
117+ interval: 30s
118+ timeout: 10s
119+ retries: 3
120+ start_period: 60s
121+
122+ kafka-tools:
123+ image: confluentinc/cp-kafka:7.3.0
124+ container_name: kafka-tools
125+ restart: unless-stopped
126+ depends_on:
127+ kafka:
128+ condition: service_healthy
129+ entrypoint: /bin/bash
130+ tty: true
131+ stdin_open: true
132+ command: -c "echo 'Kafka CLI tools hazır.' && sleep infinity"
133+ environment:
134+ KAFKA_BROKER_ID: ignored
135+ KAFKA_ZOOKEEPER_CONNECT: ignored
136+ networks:
137+ - craftpilot-network
138+
139+ redis:
140+ image: redis:7.0-alpine
141+ container_name: redis
142+ restart: unless-stopped
143+ ports:
144+ - "6379:6379"
145+ command: >
146+ --requirepass 13579ada
147+ --maxmemory 800mb
148+ --maxmemory-policy volatile-lru
149+ --appendonly yes
150+ --appendfsync everysec
151+ --no-appendfsync-on-rewrite yes
152+ volumes:
153+ - redis-data:/data
154+ networks:
155+ - craftpilot-network
156+ healthcheck:
157+ test: ["CMD", "redis-cli", "-a", "13579ada", "ping"]
158+ interval: 5s
159+ timeout: 3s
160+ retries: 3
161+ start_period: 10s
162+
163+ volumes:
164+ zookeeper-data:
165+ zookeeper-log:
166+ kafka-data:
167+ redis-data:
168+
169+ networks:
170+ craftpilot-network:
171+ external: true
172+ name: craftpilot-network
173+ EOL
83174
84- if [ ! -f docker-compose.infra.yml ] || [ ! -s docker-compose.infra.yml ]; then
85- echo "HATA: docker-compose.infra.yml dosyası boş veya eksik!"
175+ # Dosya oluşturulduğunu kontrol et
176+ if [ ! -f docker-compose.infra.yml ]; then
177+ echo "HATA: docker-compose.infra.yml dosyası oluşturulamadı!"
86178 exit 1
87179 fi
88180
89- # Docker compose dosyasının geçerliliğini kontrol et
181+ # Docker compose geçerliliğini kontrol et
90182 if ! docker-compose -f docker-compose.infra.yml config > /dev/null; then
91183 echo "HATA: docker-compose.infra.yml dosyası geçersiz!"
92184 exit 1
0 commit comments