Use local docker registry to push and pull app images

This commit is contained in:
T. R. Bernstein
2025-08-29 16:55:50 +02:00
parent 18f1bbbeac
commit 95cbc62ef1
24 changed files with 352 additions and 64 deletions

View File

@@ -29,14 +29,14 @@ class AppTest < IntegrationTest
images = kamal :app, :images, capture: true
assert_match "App Host: vm1", images
assert_match "App Host: vm2", images
assert_match /registry:4443\/app\s+#{latest_app_version}/, images
assert_match /registry:4443\/app\s+latest/, images
assert_match /localhost:5000\/app\s+#{latest_app_version}/, images
assert_match /localhost:5000\/app\s+latest/, images
containers = kamal :app, :containers, capture: true
assert_match "App Host: vm1", containers
assert_match "App Host: vm2", containers
assert_match "registry:4443/app:#{latest_app_version}", containers
assert_match "registry:4443/app:latest", containers
assert_match "localhost:5000/app:#{latest_app_version}", containers
assert_match "localhost:5000/app:latest", containers
exec_output = kamal :app, :exec, :ps, capture: true
assert_match "App Host: vm1", exec_output

View File

@@ -2,12 +2,12 @@ service: app
image: app
servers:
- vm1
- vm2: [ tag1, tag2 ]
- vm2: [tag1, tag2]
env:
clear:
CLEAR_TOKEN: 4321
CLEAR_TAG: ""
HOST_TOKEN: "${HOST_TOKEN}"
CLEAR_TAG: ''
HOST_TOKEN: '${HOST_TOKEN}'
secret:
- SECRET_TOKEN
- INTERPOLATED_SECRET1
@@ -26,9 +26,7 @@ readiness_delay: 0
proxy:
host: 127.0.0.1
registry:
server: registry:4443
username: root
password: root
server: localhost:5000
builder:
driver: docker
arch: <%= Kamal::Utils.docker_arch %>

View File

@@ -131,7 +131,9 @@ class IntegrationTest < ActiveSupport::TestCase
def wait_for_healthy(timeout: 30)
timeout_at = Time.now + timeout
while docker_compose("ps -a | tail -n +2 | grep -v '(healthy)' | wc -l", capture: true) != "0"
loop do
result = docker_compose("ps -a | tail -n +2 | grep -v '(healthy)' | wc -l", capture: true)
break if result.split.last == "0" || result == "0"
if timeout_at < Time.now
docker_compose("ps -a | tail -n +2 | grep -v '(healthy)'")
raise "Container not healthy after #{timeout} seconds" if timeout_at < Time.now

View File

@@ -33,7 +33,7 @@ class MainTest < IntegrationTest
assert_match /App Host: vm1/, details
assert_match /App Host: vm2/, details
assert_match /basecamp\/kamal-proxy:#{Kamal::Configuration::Proxy::Boot::MINIMUM_VERSION}/, details
assert_match /registry:4443\/app:#{first_version}/, details
assert_match /localhost:5000\/app:#{first_version}/, details
audit = kamal :audit, capture: true
assert_match /Booted app version #{first_version}.*Booted app version #{second_version}.*Booted app version #{first_version}.*/m, audit
@@ -67,8 +67,8 @@ class MainTest < IntegrationTest
assert_equal [ "vm1", "vm2", "vm3" ], config[:hosts]
assert_equal "vm1", config[:primary_host]
assert_equal version, config[:version]
assert_equal "registry:4443/app", config[:repository]
assert_equal "registry:4443/app:#{version}", config[:absolute_image]
assert_equal "localhost:5000/app", config[:repository]
assert_equal "localhost:5000/app:#{version}", config[:absolute_image]
assert_equal "app-#{version}", config[:service_with_version]
assert_equal [], config[:volume_args]
assert_equal({ user: "root", port: 22, keepalive: true, keepalive_interval: 30, log_level: :fatal }, config[:ssh_options])