Class: Dash::Commands::Registry
- Defined in:
- lib/dash/commands/registry.rb
Constant Summary collapse
- LOCAL_CONTAINER_NAME =
"dash-docker-registry"- LEGACY_LOCAL_CONTAINER_NAME =
"kamal-docker-registry"
Constants inherited from Base
Base::DOCKER_HEALTH_STATUS_FORMAT, Base::EXEC_PROBE_FAILED, Base::NO_HEALTHCHECK, Base::READINESS_PROGRESS_PREFIX, Base::READY_STATUSES
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #local? ⇒ Boolean
- #login(registry_config: nil) ⇒ Object
-
#login_then(*commands, registry_config: nil) ⇒ Object
The login and whatever has to happen after it on the same host, in one round trip.
- #logout(registry_config: nil) ⇒ Object
-
#remove ⇒ Object
The legacy container is torn down alongside the current one so an operator's laptop doesn't keep a stray kamal-docker-registry holding the local port after upgrading.
- #setup(registry_config: nil) ⇒ Object
Methods inherited from Base
#confirmed_empty?, #container_id_for, #ensure_docker_installed, #ensure_run_directory, #initialize, #make_directory, #make_directory_for, #read_file, #remove_directory, #remove_file, #run_over_ssh
Constructor Details
This class inherits a constructor from Dash::Commands::Base
Instance Method Details
#local? ⇒ Boolean
55 56 57 |
# File 'lib/dash/commands/registry.rb', line 55 def local? config.registry.local? end |
#login(registry_config: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/dash/commands/registry.rb', line 5 def login(registry_config: nil) registry_config ||= config.registry return if registry_config.local? docker :login, registry_config.server, "-u", sensitive(Dash::Utils.escape_shell_value(registry_config.username)), "-p", sensitive(Dash::Utils.escape_shell_value(registry_config.password)) end |
#login_then(*commands, registry_config: nil) ⇒ Object
The login and whatever has to happen after it on the same host, in one round trip.
docker login prints "Login Succeeded" to stdout, so its output is redirected away:
a caller that captures this gets the folded command's answer and nothing else. A local
registry needs no login at all, and the fold collapses to the commands alone.
The credentials stay wrapped in sensitive(...) - composing keeps the array elements intact, so SSHKit redacts them here exactly as it does for a standalone login.
23 24 25 26 27 28 |
# File 'lib/dash/commands/registry.rb', line 23 def login_then(*commands, registry_config: nil) login = login(registry_config: registry_config) login = [ *login, ">", "/dev/null" ] if login combine login, *commands end |
#logout(registry_config: nil) ⇒ Object
30 31 32 33 34 |
# File 'lib/dash/commands/registry.rb', line 30 def logout(registry_config: nil) registry_config ||= config.registry docker :logout, registry_config.server end |
#remove ⇒ Object
The legacy container is torn down alongside the current one so an operator's laptop doesn't keep a stray kamal-docker-registry holding the local port after upgrading. Dash::Cli::Registry#remove already runs this with raise_on_non_zero_exit: false, so a missing container of either name is fine.
49 50 51 52 53 |
# File 'lib/dash/commands/registry.rb', line 49 def remove chain \ combine(docker(:stop, LOCAL_CONTAINER_NAME), docker(:rm, LOCAL_CONTAINER_NAME)), combine(docker(:stop, LEGACY_LOCAL_CONTAINER_NAME), docker(:rm, LEGACY_LOCAL_CONTAINER_NAME)) end |
#setup(registry_config: nil) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/dash/commands/registry.rb', line 36 def setup(registry_config: nil) registry_config ||= config.registry combine \ docker(:start, LOCAL_CONTAINER_NAME), docker(:run, "--detach", "-p", "127.0.0.1:#{registry_config.local_port}:5000", "--name", LOCAL_CONTAINER_NAME, "registry:3"), by: "||" end |