diff --git a/Gemfile.lock b/Gemfile.lock index 731b6b4db..99da1956b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - kamal (1.9.2) + kamal (1.9.3) activesupport (>= 7.0) base64 (~> 0.2) bcrypt_pbkdf (~> 1.0) @@ -78,11 +78,11 @@ GEM net-sftp (4.0.0) net-ssh (>= 5.0.0, < 8.0.0) net-ssh (7.2.1) - nokogiri (1.16.0-arm64-darwin) + nokogiri (1.18.8-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.0-x86_64-darwin) + nokogiri (1.18.8-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.0-x86_64-linux) + nokogiri (1.18.8-x86_64-linux-gnu) racc (~> 1.4) parallel (1.24.0) parser (3.3.0.5) diff --git a/lib/kamal/cli/base.rb b/lib/kamal/cli/base.rb index ab67a0e9b..9bde6e025 100644 --- a/lib/kamal/cli/base.rb +++ b/lib/kamal/cli/base.rb @@ -37,9 +37,9 @@ def reload_env def load_env if destination = options[:destination] - Dotenv.load(".env.#{destination}", ".env") + Dotenv.overload(".env", ".env.#{destination}") else - Dotenv.load(".env") + Dotenv.overload(".env") end end diff --git a/lib/kamal/version.rb b/lib/kamal/version.rb index b37cd8f02..2cd1e267a 100644 --- a/lib/kamal/version.rb +++ b/lib/kamal/version.rb @@ -1,3 +1,3 @@ module Kamal - VERSION = "1.9.2" + VERSION = "1.9.3" end diff --git a/test/cli/main_test.rb b/test/cli/main_test.rb index 0e09074fe..4320dfe13 100644 --- a/test/cli/main_test.rb +++ b/test/cli/main_test.rb @@ -490,6 +490,39 @@ class CliMainTest < CliTestCase end end + test "env files overwrite shell environment variables" do + ENV["TEST_VAR"] = "shell_value" + ENV["AWS_ACCESS_KEY_ID"] = "local_dev_key" + + with_test_dotenv(".env": "TEST_VAR=dotenv_value\nAWS_ACCESS_KEY_ID=production_key") do + # Create a simple CLI command instance to trigger load_env + Kamal::Cli::Main.new.send(:load_env) + + assert_equal "dotenv_value", ENV["TEST_VAR"] + assert_equal "production_key", ENV["AWS_ACCESS_KEY_ID"] + end + ensure + ENV.delete("TEST_VAR") + ENV.delete("AWS_ACCESS_KEY_ID") + end + + test "destination env files overwrite base env files" do + ENV["TEST_VAR"] = "shell_value" + + with_test_dotenv(".env": "TEST_VAR=base_value\nBASE_ONLY=base", ".env.world": "TEST_VAR=world_value\nWORLD_ONLY=world") do + # Create CLI command with destination to trigger load_env + Kamal::Cli::Main.new([], { destination: "world" }).send(:load_env) + + assert_equal "world_value", ENV["TEST_VAR"] + assert_equal "base", ENV["BASE_ONLY"] + assert_equal "world", ENV["WORLD_ONLY"] + end + ensure + ENV.delete("TEST_VAR") + ENV.delete("BASE_ONLY") + ENV.delete("WORLD_ONLY") + end + test "remove with confirmation" do run_command("remove", "-y", config_file: "deploy_with_accessories").tap do |output| assert_match /docker container stop traefik/, output diff --git a/test/integration/docker/registry/Dockerfile b/test/integration/docker/registry/Dockerfile index f5eefc339..01bd02459 100644 --- a/test/integration/docker/registry/Dockerfile +++ b/test/integration/docker/registry/Dockerfile @@ -1,4 +1,4 @@ -FROM registry +FROM registry:3 COPY boot.sh . diff --git a/test/integration/docker/registry/boot.sh b/test/integration/docker/registry/boot.sh index 6eb8a518e..fbb339ac4 100755 --- a/test/integration/docker/registry/boot.sh +++ b/test/integration/docker/registry/boot.sh @@ -1,3 +1,3 @@ #!/bin/sh -exec /entrypoint.sh /etc/docker/registry/config.yml +exec /entrypoint.sh /etc/distribution/config.yml