Allow applications to be deployed without needing to set up a repository in a remote Docker registry. If the registry server starts with `localhost`, Kamal will start a local docker registry on that port and push the app image to it. Then when pulling the image onto the servers, we use net-ssh to forward the that port from the app server to the deployment server. This will allow the deployment server to pull the image from the registry as if it were local, meaning we don't need to set up a cert.
63 lines
2.1 KiB
Ruby
63 lines
2.1 KiB
Ruby
require_relative "cli_test_case"
|
|
|
|
class CliRegistryTest < CliTestCase
|
|
test "setup" do
|
|
run_command("setup").tap do |output|
|
|
assert_match /docker login -u \[REDACTED\] -p \[REDACTED\] as .*@localhost/, output
|
|
assert_match /docker login -u \[REDACTED\] -p \[REDACTED\] on 1.1.1.\d/, output
|
|
end
|
|
end
|
|
|
|
test "setup skip local" do
|
|
run_command("setup", "-L").tap do |output|
|
|
assert_no_match /docker login -u \[REDACTED\] -p \[REDACTED\] as .*@localhost/, output
|
|
assert_match /docker login -u \[REDACTED\] -p \[REDACTED\] on 1.1.1.\d/, output
|
|
end
|
|
end
|
|
|
|
test "setup skip remote" do
|
|
run_command("setup", "-R").tap do |output|
|
|
assert_match /docker login -u \[REDACTED\] -p \[REDACTED\] as .*@localhost/, output
|
|
assert_no_match /docker login -u \[REDACTED\] -p \[REDACTED\] on 1.1.1.\d/, output
|
|
end
|
|
end
|
|
|
|
test "remove" do
|
|
run_command("remove").tap do |output|
|
|
assert_match /docker logout as .*@localhost/, output
|
|
assert_match /docker logout on 1.1.1.\d/, output
|
|
end
|
|
end
|
|
|
|
test "remove skip local" do
|
|
run_command("remove", "-L").tap do |output|
|
|
assert_no_match /docker logout as .*@localhost/, output
|
|
assert_match /docker logout on 1.1.1.\d/, output
|
|
end
|
|
end
|
|
|
|
test "remove skip remote" do
|
|
run_command("remove", "-R").tap do |output|
|
|
assert_match /docker logout as .*@localhost/, output
|
|
assert_no_match /docker logout on 1.1.1.\d/, output
|
|
end
|
|
end
|
|
|
|
test "setup local registry" do
|
|
run_command("setup", fixture: :with_local_registry).tap do |output|
|
|
assert_match /docker start kamal-docker-registry || docker run --detach -p 5000:5000 --name kamal-docker-registry registry:2 as .*@localhost/, output
|
|
end
|
|
end
|
|
|
|
test "remove local registry" do
|
|
run_command("remove", fixture: :with_local_registry).tap do |output|
|
|
assert_match /docker stop kamal-docker-registry && docker rm kamal-docker-registry as .*@localhost/, output
|
|
end
|
|
end
|
|
|
|
private
|
|
def run_command(*command, fixture: :with_accessories)
|
|
stdouted { Kamal::Cli::Registry.start([ *command, "-c", "test/fixtures/deploy_#{fixture}.yml" ]) }
|
|
end
|
|
end
|