Repository navigation
feat(docker-compose): Add Docker Compose deployment. #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
11c9b5a
Add docker compose files
sitaowang1998 470f7e5
Fix network
sitaowang1998 139286e
Add image tag and worker image name
sitaowang1998 bb36fec
Add clean task
sitaowang1998 07baeee
Fix config
sitaowang1998 c6d4696
Merge branch 'main' into docker-compose
sitaowang1998 ce11907
Rename variables
sitaowang1998 4c7b4c0
Merge branch 'docker-compose' of github.com:sitaowang1998/spider into…
sitaowang1998 7f2d8f3
Merge branch 'main' into docker-compose
sitaowang1998 6b92262
Merge branch 'main' into docker-compose
sitaowang1998 bc35203
Expose user-facing config through env file
sitaowang1998 1bf2687
Merge branch 'docker-compose' of github.com:sitaowang1998/spider into…
sitaowang1998 d3dbf06
Fix generated storage config keys
sitaowang1998 0d6b169
Merge branch 'main' into docker-compose
sitaowang1998 b3eed39
Add defaults for Compose configuration
sitaowang1998 98ebc3b
Merge remote-tracking branch 'origin/main' into docker-compose
sitaowang1998 07f764e
Update Compose runtime configuration
sitaowang1998 ab5a157
Split configs out
sitaowang1998 d5c1a02
Merge branch 'main' into docker-compose
sitaowang1998 7807436
Rename env
sitaowang1998 0ccb692
Add 5 min wait timeout for docker compose up
sitaowang1998 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Optionally copy this file to `.env` to override Spider's embedded defaults. | ||
|
|
||
| # Deployment settings. | ||
| SPIDER_IMAGE_TAG=main | ||
| SPIDER_PULL_POLICY=always | ||
| SPIDER_RESTART_POLICY=on-failure:3 | ||
|
|
||
| # Database settings. | ||
| SPIDER_DATABASE_IMAGE_REF=mariadb:10.11.16 | ||
| SPIDER_DATABASE_NAME=spider-db | ||
| SPIDER_DATABASE_PORT=3306 | ||
| SPIDER_DATABASE_ROOT_PASSWORD=spider-root-password | ||
| SPIDER_STORAGE_DB_PASSWORD=spider-password | ||
| SPIDER_STORAGE_DB_USERNAME=spider-user | ||
|
|
||
| # Storage settings. | ||
| SPIDER_STORAGE_LOG_LEVEL=INFO | ||
| SPIDER_STORAGE_PORT=50051 | ||
| SPIDER_STORAGE_PUBLISHED_IP=127.0.0.1 | ||
| SPIDER_STORAGE_PUBLISHED_PORT=50051 | ||
| SPIDER_STORAGE_DB_MAX_CONNECTIONS=64 | ||
| SPIDER_STORAGE_INBOUND_QUEUE_CLEANUP_CAPACITY=256 | ||
| SPIDER_STORAGE_INBOUND_QUEUE_COMMIT_CAPACITY=256 | ||
| SPIDER_STORAGE_INBOUND_QUEUE_TASK_CAPACITY=1048576 | ||
| SPIDER_STORAGE_JOB_CACHE_GC_INTERVAL_SEC=30 | ||
| SPIDER_STORAGE_JOB_CACHE_TERMINATED_JOB_RETENTION_SEC=300 | ||
| SPIDER_STORAGE_TASK_INSTANCE_POOL_EXECUTION_MANAGER_STALE_CUTOFF_SEC=60 | ||
| SPIDER_STORAGE_TASK_INSTANCE_POOL_GC_INTERVAL_SEC=30 | ||
| SPIDER_STORAGE_TASK_INSTANCE_POOL_MESSAGE_CHANNEL_CAPACITY=128 | ||
|
|
||
| # Scheduler settings. | ||
| SPIDER_SCHEDULER_LOG_LEVEL=INFO | ||
| SPIDER_SCHEDULER_PORT=50052 | ||
| SPIDER_SCHEDULER_CONNECTION_POOL_SIZE=8 | ||
| SPIDER_SCHEDULER_STOP_TIMEOUT_SEC=30 | ||
| SPIDER_SCHEDULER_EM_REGISTRY_DEAD_EM_CUTOFF_SEC=30 | ||
| SPIDER_SCHEDULER_EM_REGISTRY_LIVENESS_TRACKING_INTERVAL_MS=1000 | ||
| SPIDER_SCHEDULER_POLICY=round_robin | ||
| SPIDER_SCHEDULER_ROUND_ROBIN_ACTIVE_JOB_QUEUE_CAPACITY=16 | ||
| SPIDER_SCHEDULER_ROUND_ROBIN_CLEANUP_READY_TASK_CAPACITY=256 | ||
| SPIDER_SCHEDULER_ROUND_ROBIN_COMMIT_READY_TASK_CAPACITY=256 | ||
| SPIDER_SCHEDULER_ROUND_ROBIN_DISPATCH_QUEUE_CAPACITY=16 | ||
| SPIDER_SCHEDULER_ROUND_ROBIN_FINALIZING_JOB_EXPIRATION_TIMEOUT_SEC=300 | ||
| SPIDER_SCHEDULER_ROUND_ROBIN_READY_TASK_CAPACITY=1048576 | ||
| SPIDER_SCHEDULER_ROUND_ROBIN_STORAGE_POLL_TIMEOUT_MS=10 | ||
| SPIDER_SCHEDULER_ROUND_ROBIN_TICK_INTERVAL_MS=5 | ||
|
|
||
| # Worker settings. | ||
| # A complete worker image reference takes precedence over `SPIDER_IMAGE_TAG` when set. | ||
| # SPIDER_WORKER_IMAGE_REF=ghcr.io/y-scope/spider/worker:main | ||
|
20001020ycx marked this conversation as resolved.
Resolved
|
||
| SPIDER_WORKER_REPLICAS=4 | ||
| SPIDER_WORKER_LOG_LEVEL=INFO | ||
| SPIDER_WORKER_CONNECTION_POOL_SIZE=4 | ||
| SPIDER_WORKER_LIVENESS_SCHEDULER_HEARTBEAT_INTERVAL_SEC=1 | ||
| SPIDER_WORKER_SCHEDULER_POLL_WAIT_MS=1000 | ||
| SPIDER_WORKER_LIVENESS_STORAGE_HEARTBEAT_INTERVAL_SEC=1 | ||
| SPIDER_WORKER_TASK_EXECUTOR_BIN_PATH=/usr/local/bin/spider-task-executor | ||
| SPIDER_WORKER_INHERITED_ENV=[] | ||
| SPIDER_WORKER_MAX_LOG_LINE_BYTES=65536 | ||
| SPIDER_WORKER_PACKAGE_DIR=/opt/spider/packages | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| name: "spider" | ||
|
|
||
| include: | ||
|
20001020ycx marked this conversation as resolved.
Resolved
|
||
| - "./configs/scheduler.yaml" | ||
| - "./configs/storage.yaml" | ||
| - "./configs/worker.yaml" | ||
|
|
||
| x-service-defaults: &service_defaults | ||
| logging: | ||
| driver: "local" | ||
| pull_policy: "${SPIDER_PULL_POLICY:-always}" | ||
| restart: "${SPIDER_RESTART_POLICY:-on-failure:3}" | ||
| stop_grace_period: "60s" | ||
|
|
||
| x-healthcheck-defaults: &healthcheck_defaults | ||
| interval: "30s" | ||
| retries: 3 | ||
| start_interval: "2s" | ||
| start_period: "60s" | ||
| timeout: "2s" | ||
|
|
||
| services: | ||
| spider-database: | ||
| <<: *service_defaults | ||
| image: "${SPIDER_DATABASE_IMAGE_REF:-mariadb:10.11.16}" | ||
| networks: | ||
| - "spider-internal" | ||
| command: [ | ||
| "--port=${SPIDER_DATABASE_PORT:-3306}", | ||
| ] | ||
| environment: | ||
| MYSQL_DATABASE: "${SPIDER_DATABASE_NAME:-spider-db}" | ||
| MYSQL_PASSWORD: "${SPIDER_STORAGE_DB_PASSWORD:-spider-password}" | ||
| MYSQL_ROOT_PASSWORD: "${SPIDER_DATABASE_ROOT_PASSWORD:-spider-root-password}" | ||
| MYSQL_USER: "${SPIDER_STORAGE_DB_USERNAME:-spider-user}" | ||
| volumes: | ||
| - type: "volume" | ||
| source: "spider-database-data" | ||
| target: "/var/lib/mysql" | ||
| healthcheck: | ||
| <<: *healthcheck_defaults | ||
| test: [ | ||
| "CMD", | ||
| "mysqladmin", "ping", | ||
| "--silent", | ||
| "-h", "127.0.0.1", | ||
| "-P", "${SPIDER_DATABASE_PORT:-3306}", | ||
| "-u", "${SPIDER_STORAGE_DB_USERNAME:-spider-user}", | ||
| "--password=${SPIDER_STORAGE_DB_PASSWORD:-spider-password}", | ||
| ] | ||
|
|
||
| spider-storage: | ||
| <<: *service_defaults | ||
| image: "ghcr.io/y-scope/spider/storage:${SPIDER_IMAGE_TAG:-main}" | ||
| networks: | ||
| - "default" | ||
| - "spider-internal" | ||
| command: [ | ||
| "spider-storage", | ||
| "--config", "/etc/spider/storage.yaml", | ||
| ] | ||
| environment: | ||
| RUST_LOG: "${SPIDER_STORAGE_LOG_LEVEL:-INFO}" | ||
| SPIDER_STORAGE_DB_PASSWORD: "${SPIDER_STORAGE_DB_PASSWORD:-spider-password}" | ||
| SPIDER_STORAGE_DB_USERNAME: "${SPIDER_STORAGE_DB_USERNAME:-spider-user}" | ||
| ports: | ||
| - host_ip: "${SPIDER_STORAGE_PUBLISHED_IP:-127.0.0.1}" | ||
| published: "${SPIDER_STORAGE_PUBLISHED_PORT:-50051}" | ||
| target: "${SPIDER_STORAGE_PORT:-50051}" | ||
| configs: | ||
| - source: "spider-storage-config" | ||
| target: "/etc/spider/storage.yaml" | ||
| depends_on: | ||
| spider-database: | ||
| condition: "service_healthy" | ||
| restart: true | ||
| healthcheck: | ||
| <<: *healthcheck_defaults | ||
| test: [ | ||
| "CMD", | ||
| "timeout", "2", | ||
| "bash", "-c", "</dev/tcp/127.0.0.1/${SPIDER_STORAGE_PORT:-50051}", | ||
| ] | ||
|
|
||
| spider-scheduler: | ||
| <<: *service_defaults | ||
| image: "ghcr.io/y-scope/spider/scheduler:${SPIDER_IMAGE_TAG:-main}" | ||
| networks: | ||
| - "spider-internal" | ||
| command: [ | ||
| "spider-scheduler", | ||
| "--config", "/etc/spider/scheduler.yaml", | ||
| ] | ||
| environment: | ||
| RUST_LOG: "${SPIDER_SCHEDULER_LOG_LEVEL:-INFO}" | ||
| configs: | ||
| - source: "spider-scheduler-config" | ||
| target: "/etc/spider/scheduler.yaml" | ||
| depends_on: | ||
| spider-storage: | ||
| condition: "service_healthy" | ||
| restart: true | ||
| healthcheck: | ||
| <<: *healthcheck_defaults | ||
| test: [ | ||
| "CMD", | ||
| "timeout", "2", | ||
| "bash", "-c", "</dev/tcp/127.0.0.1/${SPIDER_SCHEDULER_PORT:-50052}", | ||
| ] | ||
|
|
||
| spider-worker: | ||
| <<: *service_defaults | ||
| image: >- | ||
| ${SPIDER_WORKER_IMAGE_REF:-ghcr.io/y-scope/spider/worker:${SPIDER_IMAGE_TAG:-main}} | ||
| networks: | ||
| - "default" | ||
| - "spider-internal" | ||
|
20001020ycx marked this conversation as resolved.
Resolved
|
||
| command: [ | ||
| "spider-execution-manager", | ||
| "--config", "/etc/spider/worker.yaml", | ||
| ] | ||
| environment: | ||
| RUST_LOG: "${SPIDER_WORKER_LOG_LEVEL:-INFO}" | ||
| configs: | ||
| - source: "spider-worker-config" | ||
| target: "/etc/spider/worker.yaml" | ||
| depends_on: | ||
| spider-scheduler: | ||
| condition: "service_healthy" | ||
| restart: true | ||
| spider-storage: | ||
| condition: "service_healthy" | ||
| restart: true | ||
| deploy: | ||
| replicas: "${SPIDER_WORKER_REPLICAS:-4}" | ||
|
|
||
| networks: | ||
| default: | ||
| spider-internal: | ||
| internal: true | ||
|
|
||
| volumes: | ||
| spider-database-data: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| configs: | ||
| spider-scheduler-config: | ||
| content: | | ||
| connection_pool_size: ${SPIDER_SCHEDULER_CONNECTION_POOL_SIZE:-8} | ||
| host: "0.0.0.0" | ||
| port: ${SPIDER_SCHEDULER_PORT:-50052} | ||
| runtime: | ||
| advertised_endpoint: | ||
| host: "spider-scheduler" | ||
| port: ${SPIDER_SCHEDULER_PORT:-50052} | ||
| em_registry: | ||
| dead_em_cutoff_sec: ${SPIDER_SCHEDULER_EM_REGISTRY_DEAD_EM_CUTOFF_SEC:-30} | ||
| liveness_tracking_interval_ms: | ||
| ${SPIDER_SCHEDULER_EM_REGISTRY_LIVENESS_TRACKING_INTERVAL_MS:-1000} | ||
| scheduler: | ||
| policy: "${SPIDER_SCHEDULER_POLICY:-round_robin}" | ||
| config: | ||
| active_job_queue_capacity: | ||
| ${SPIDER_SCHEDULER_ROUND_ROBIN_ACTIVE_JOB_QUEUE_CAPACITY:-16} | ||
| cleanup_ready_task_capacity: | ||
| ${SPIDER_SCHEDULER_ROUND_ROBIN_CLEANUP_READY_TASK_CAPACITY:-256} | ||
| commit_ready_task_capacity: | ||
| ${SPIDER_SCHEDULER_ROUND_ROBIN_COMMIT_READY_TASK_CAPACITY:-256} | ||
| dispatch_queue_capacity: | ||
| ${SPIDER_SCHEDULER_ROUND_ROBIN_DISPATCH_QUEUE_CAPACITY:-16} | ||
| finalizing_job_expiration_timeout_sec: | ||
| ${SPIDER_SCHEDULER_ROUND_ROBIN_FINALIZING_JOB_EXPIRATION_TIMEOUT_SEC:-300} | ||
| ready_task_capacity: | ||
| ${SPIDER_SCHEDULER_ROUND_ROBIN_READY_TASK_CAPACITY:-1048576} | ||
| storage_poll_timeout_ms: | ||
| ${SPIDER_SCHEDULER_ROUND_ROBIN_STORAGE_POLL_TIMEOUT_MS:-10} | ||
| tick_interval_ms: ${SPIDER_SCHEDULER_ROUND_ROBIN_TICK_INTERVAL_MS:-5} | ||
| stop_timeout_sec: ${SPIDER_SCHEDULER_STOP_TIMEOUT_SEC:-30} | ||
| storage_endpoint: | ||
| host: "spider-storage" | ||
| port: ${SPIDER_STORAGE_PORT:-50051} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| configs: | ||
| spider-storage-config: | ||
| content: | | ||
| host: "0.0.0.0" | ||
| port: ${SPIDER_STORAGE_PORT:-50051} | ||
| runtime: | ||
| db: | ||
| host: "spider-database" | ||
| max_connections: ${SPIDER_STORAGE_DB_MAX_CONNECTIONS:-64} | ||
| name: "${SPIDER_DATABASE_NAME:-spider-db}" | ||
| port: ${SPIDER_DATABASE_PORT:-3306} | ||
| inbound_queue: | ||
| cleanup_capacity: ${SPIDER_STORAGE_INBOUND_QUEUE_CLEANUP_CAPACITY:-256} | ||
| commit_capacity: ${SPIDER_STORAGE_INBOUND_QUEUE_COMMIT_CAPACITY:-256} | ||
| task_capacity: ${SPIDER_STORAGE_INBOUND_QUEUE_TASK_CAPACITY:-1048576} | ||
| job_cache_gc: | ||
| gc_interval_sec: ${SPIDER_STORAGE_JOB_CACHE_GC_INTERVAL_SEC:-30} | ||
| terminated_job_retention_sec: | ||
| ${SPIDER_STORAGE_JOB_CACHE_TERMINATED_JOB_RETENTION_SEC:-300} | ||
| task_instance_pool: | ||
| execution_manager_stale_cutoff_sec: | ||
| ${SPIDER_STORAGE_TASK_INSTANCE_POOL_EXECUTION_MANAGER_STALE_CUTOFF_SEC:-60} | ||
| gc_interval_sec: ${SPIDER_STORAGE_TASK_INSTANCE_POOL_GC_INTERVAL_SEC:-30} | ||
| message_channel_capacity: | ||
| ${SPIDER_STORAGE_TASK_INSTANCE_POOL_MESSAGE_CHANNEL_CAPACITY:-128} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| configs: | ||
| spider-worker-config: | ||
| content: | | ||
| connection_pool_size: ${SPIDER_WORKER_CONNECTION_POOL_SIZE:-4} | ||
| liveness: | ||
| scheduler_heartbeat_interval_sec: | ||
| ${SPIDER_WORKER_LIVENESS_SCHEDULER_HEARTBEAT_INTERVAL_SEC:-1} | ||
| storage_heartbeat_interval_sec: | ||
| ${SPIDER_WORKER_LIVENESS_STORAGE_HEARTBEAT_INTERVAL_SEC:-1} | ||
| scheduler: | ||
| host: "spider-scheduler" | ||
| port: ${SPIDER_SCHEDULER_PORT:-50052} | ||
| scheduler_poll_wait_ms: ${SPIDER_WORKER_SCHEDULER_POLL_WAIT_MS:-1000} | ||
| storage: | ||
| host: "spider-storage" | ||
| port: ${SPIDER_STORAGE_PORT:-50051} | ||
| task_executor: | ||
| bin_path: "${SPIDER_WORKER_TASK_EXECUTOR_BIN_PATH:-/usr/local/bin/spider-task-executor}" | ||
| inherited_env: ${SPIDER_WORKER_INHERITED_ENV:-[]} | ||
| max_log_line_bytes: ${SPIDER_WORKER_MAX_LOG_LINE_BYTES:-65536} | ||
| package_dir: "${SPIDER_WORKER_PACKAGE_DIR:-/opt/spider/packages}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: y-scope/spider
Length of output: 299
🏁 Script executed:
Repository: y-scope/spider
Length of output: 29282
🏁 Script executed:
Repository: y-scope/spider
Length of output: 23494
🌐 Web query:
Docker Compose up --wait-timeout documentation💡 Result:
The --wait-timeout option in Docker Compose is used with the --wait flag to specify a maximum duration, in seconds, to wait for the services in a project to reach a running or healthy state [1][2][3]. Key details regarding this option: Purpose: It prevents the docker compose up command from waiting indefinitely when services fail to start or reach a healthy state within a reasonable timeframe [4][5]. Usage: It must be used in conjunction with the --wait flag, which signifies that the command should wait for services to be running or healthy [1][2]. Because the --wait flag implies detached mode, --wait-timeout is typically used when running services in the background [1][3]. Syntax: You can specify the timeout in seconds as follows: docker compose up -d --wait --wait-timeout Note: This option is distinct from the --timeout (or -t) flag, which is used to set the timeout for container shutdown [1][6]. While the --wait-timeout feature was introduced to address issues where processes would hang, users should be aware of ongoing maintenance and potential bugs in specific edge cases, such as complex dependency conditions (e.g., service_completed_successfully) [7][4].
Citations:
updocker/compose#10276Restore the bounded startup timeout.
tcompose:upusesdocker compose up --detach --waitwithout--wait-timeout, so startup waits are no longer bounded by the documented 120-second limit. AddSPIDER_COMPOSE_WAIT_TIMEOUT=120totools/deployment/spider-compose/.env.example, load the variable in the Taskfile, and pass--wait-timeout ${.SPIDER_COMPOSE_WAIT_TIMEOUT:-120}to the compose command.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sitaowang1998 sounds reasonable, can you confirm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, add a 5 minutes timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.