Created
February 18, 2026 16:44
-
-
Save dayio/463b354d00f02b4c8bc585cd6dbb2374 to your computer and use it in GitHub Desktop.
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
| services: | |
| setup: | |
| image: docker:cli | |
| volumes: | |
| - ./swarm-init.sh:/swarm-init.sh | |
| - ./nginx.yml:/nginx.yml | |
| - manager-docker:/var/run # Mount the volume (directory) containing docker.sock | |
| environment: | |
| - DOCKER_HOST=unix:///var/run/docker.sock | |
| - DOCKER_TLS_CERTDIR="" | |
| command: /bin/sh /swarm-init.sh | |
| depends_on: | |
| manager: | |
| condition: service_healthy | |
| networks: | |
| - swarm-net | |
| manager: | |
| image: docker:dind | |
| privileged: true | |
| environment: | |
| DOCKER_TLS_CERTDIR: "" | |
| command: dockerd --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375 | |
| volumes: | |
| - manager-docker:/var/run | |
| ports: | |
| - "7777:7777" | |
| - "8888:8888" | |
| - "9999:9999" | |
| networks: | |
| - swarm-net | |
| healthcheck: | |
| test: [ "CMD", "docker", "info" ] | |
| interval: 5s | |
| timeout: 3s | |
| retries: 5 | |
| agent: | |
| container_name: agent | |
| hostname: agent | |
| build: | |
| context: ../../ | |
| command: bun --watch run src/index.ts | |
| volumes: | |
| - ../../:/usr/src/app | |
| - manager-docker:/var/run:rw | |
| ports: | |
| - "3000:3000" | |
| env_file: ../../.env | |
| networks: | |
| - swarm-net | |
| depends_on: | |
| manager: | |
| condition: service_healthy | |
| setup: | |
| condition: service_completed_successfully | |
| volumes: | |
| manager-docker: | |
| networks: | |
| swarm-net: | |
| driver: bridge |
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
| #!/bin/bash | |
| # Initialize swarm manager (running inside setup container with manager socket mounted) | |
| MANAGER_IP=$(getent hosts manager | awk '{ print $1 }') | |
| # Check if already initialized | |
| if ! docker info | grep -q "Swarm: active"; then | |
| echo "Initializing Swarm at $MANAGER_IP..." | |
| docker swarm init --advertise-addr $MANAGER_IP | |
| else | |
| echo "Swarm already initialized." | |
| fi | |
| echo "Swarm initialized" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment