From 926beee83277116dea34914abb99f566577172b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sezer=20Bozk=C4=B1r?= <6623948+Natgho@users.noreply.github.com> Date: Fri, 7 Feb 2025 12:11:51 +0300 Subject: [PATCH] base-config structure is changed (#618) refactor(docker): restructure docker-compose for modular configuration - Added reusable base configuration block (x-base-config) for ports, environment variables, volumes, deployment resources, restart policy, and health check. - Updated services to include base configuration directly using `<<: *base-config` syntax. - Removed redundant `base-config` service definition. --- docker-compose.yml | 64 ++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4b22fd98..6a7bf7cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,30 @@ +# Base configuration (not a service, just a reusable config block) +x-base-config: &base-config + ports: + - "11235:11235" + - "8000:8000" + - "9222:9222" + - "8080:8080" + environment: + - CRAWL4AI_API_TOKEN=${CRAWL4AI_API_TOKEN:-} + - OPENAI_API_KEY=${OPENAI_API_KEY:-} + - CLAUDE_API_KEY=${CLAUDE_API_KEY:-} + volumes: + - /dev/shm:/dev/shm + deploy: + resources: + limits: + memory: 4G + reservations: + memory: 1G + restart: unless-stopped + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:11235/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + services: # Local build services for different platforms crawl4ai-amd64: @@ -11,9 +38,7 @@ services: platforms: - linux/amd64 profiles: ["local-amd64"] - extends: &base-config - file: docker-compose.yml - service: base-config + <<: *base-config # extends yerine doğrudan yapılandırmayı dahil ettik crawl4ai-arm64: build: @@ -26,42 +51,15 @@ services: platforms: - linux/arm64 profiles: ["local-arm64"] - extends: *base-config + <<: *base-config # Hub services for different platforms and versions crawl4ai-hub-amd64: image: unclecode/crawl4ai:${VERSION:-basic}-amd64 profiles: ["hub-amd64"] - extends: *base-config + <<: *base-config crawl4ai-hub-arm64: image: unclecode/crawl4ai:${VERSION:-basic}-arm64 profiles: ["hub-arm64"] - extends: *base-config - - # Base configuration to be extended - base-config: - ports: - - "11235:11235" - - "8000:8000" - - "9222:9222" - - "8080:8080" - environment: - - CRAWL4AI_API_TOKEN=${CRAWL4AI_API_TOKEN:-} - - OPENAI_API_KEY=${OPENAI_API_KEY:-} - - CLAUDE_API_KEY=${CLAUDE_API_KEY:-} - volumes: - - /dev/shm:/dev/shm - deploy: - resources: - limits: - memory: 4G - reservations: - memory: 1G - restart: unless-stopped - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:11235/health"] - interval: 30s - timeout: 10s - retries: 3 - start_period: 40s \ No newline at end of file + <<: *base-config \ No newline at end of file