@@ -68,16 +68,18 @@ def push
6868
6969 desc "pull" , "Pull app image from registry onto servers"
7070 def pull
71- login_to_registry_remotely
72-
73- if ( first_hosts = mirror_hosts ) . any?
74- # Pull on a single host per mirror first to seed them
75- say "Pulling image on #{ first_hosts . join ( ", " ) } to seed the #{ "mirror" . pluralize ( first_hosts . count ) } ..." , :magenta
76- pull_on_hosts ( first_hosts )
77- say "Pulling image on remaining hosts..." , :magenta
78- pull_on_hosts ( KAMAL . app_hosts - first_hosts )
79- else
80- pull_on_hosts ( KAMAL . app_hosts )
71+ login_to_registry_remotely unless KAMAL . registry . local?
72+
73+ forward_local_registry_port do
74+ if ( first_hosts = mirror_hosts ) . any?
75+ # Pull on a single host per mirror first to seed them
76+ say "Pulling image on #{ first_hosts . join ( ", " ) } to seed the #{ "mirror" . pluralize ( first_hosts . count ) } ..." , :magenta
77+ pull_on_hosts ( first_hosts )
78+ say "Pulling image on remaining hosts..." , :magenta
79+ pull_on_hosts ( KAMAL . app_hosts - first_hosts )
80+ else
81+ pull_on_hosts ( KAMAL . app_hosts )
82+ end
8183 end
8284 end
8385
@@ -194,7 +196,11 @@ def pull_on_hosts(hosts)
194196
195197 def login_to_registry_locally
196198 run_locally do
197- execute *KAMAL . registry . login
199+ if KAMAL . registry . local?
200+ execute *KAMAL . registry . setup
201+ else
202+ execute *KAMAL . registry . login
203+ end
198204 end
199205 end
200206
@@ -203,4 +209,14 @@ def login_to_registry_remotely
203209 execute *KAMAL . registry . login
204210 end
205211 end
212+
213+ def forward_local_registry_port ( &block )
214+ if KAMAL . config . registry . local?
215+ Kamal ::Cli ::PortForwarding .
216+ new ( KAMAL . hosts , KAMAL . config . registry . local_port ) .
217+ forward ( &block )
218+ else
219+ yield
220+ end
221+ end
206222end
0 commit comments