From 9e12d32cc3a700ec31bbc96fdfc085637ccb6397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20K=C5=82os?= Date: Mon, 24 Jun 2024 12:45:56 +0200 Subject: [PATCH] Expand on docker-setup.sample script so it creates docker network "kamal" on each of the defined hosts. --- .../cli/templates/sample_hooks/docker-setup.sample | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/kamal/cli/templates/sample_hooks/docker-setup.sample b/lib/kamal/cli/templates/sample_hooks/docker-setup.sample index ce263fffe..d914913d5 100755 --- a/lib/kamal/cli/templates/sample_hooks/docker-setup.sample +++ b/lib/kamal/cli/templates/sample_hooks/docker-setup.sample @@ -1,7 +1,13 @@ -#!/bin/sh +#!/usr/bin/env ruby # A sample docker-setup hook # -# Sets up a Docker network which can then be used by the application’s containers +# Sets up a Docker network on defined hosts which can then be used by the application’s containers -ssh user@example.com docker network create kamal +hosts = ENV["KAMAL_HOSTS"].split(",") + +hosts.each do |ip| + destination = "root@#{ip}" + puts "Creating a Docker network \"kamal\" on #{destination}" + `ssh #{destination} docker network create kamal` +end