Stop treating RAILS_MASTER_KEY as special
This commit is contained in:
13
README.md
13
README.md
@@ -15,12 +15,15 @@ servers:
|
||||
registry:
|
||||
username: registry-user-name
|
||||
password: <%= ENV.fetch("MRSK_REGISTRY_PASSWORD") %>
|
||||
env:
|
||||
secret:
|
||||
- RAILS_MASTER_KEY
|
||||
```
|
||||
|
||||
Now you're ready to deploy a multi-arch image to the servers:
|
||||
|
||||
```
|
||||
MRSK_REGISTRY_PASSWORD=pw mrsk deploy
|
||||
RAILS_MASTER_KEY=123 MRSK_REGISTRY_PASSWORD=pw mrsk deploy
|
||||
```
|
||||
|
||||
This will:
|
||||
@@ -265,14 +268,6 @@ ARG RUBY_VERSION
|
||||
FROM ruby:$RUBY_VERSION-slim as base
|
||||
```
|
||||
|
||||
### Using without RAILS_MASTER_KEY
|
||||
|
||||
If you're using MRSK with older Rails apps that predate RAILS_MASTER_KEY, or with a non-Rails app, you can skip the default usage and reference:
|
||||
|
||||
```yaml
|
||||
skip_master_key: true
|
||||
```
|
||||
|
||||
### Using accessories for database, cache, search services
|
||||
|
||||
You can manage your accessory services via MRSK as well. The services will build off public images, and will not be automatically updated when you deploy:
|
||||
|
||||
@@ -6,7 +6,6 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
"-d",
|
||||
"--restart unless-stopped",
|
||||
"--name", service_with_version,
|
||||
*rails_master_key_arg,
|
||||
*role.env_args,
|
||||
*config.volume_args,
|
||||
*role.label_args,
|
||||
@@ -56,7 +55,6 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
docker :run,
|
||||
("-it" if interactive),
|
||||
"--rm",
|
||||
*rails_master_key_arg,
|
||||
*config.env_args,
|
||||
*config.volume_args,
|
||||
config.absolute_image,
|
||||
@@ -130,12 +128,4 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
def service_filter
|
||||
[ "--filter", "label=service=#{config.service}" ]
|
||||
end
|
||||
|
||||
def rails_master_key_arg
|
||||
if master_key = config.master_key
|
||||
[ "-e", redact("RAILS_MASTER_KEY=#{master_key}") ]
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -110,12 +110,6 @@ class Mrsk::Configuration
|
||||
{ user: ssh_user, auth_methods: [ "publickey" ] }
|
||||
end
|
||||
|
||||
def master_key
|
||||
unless raw_config.skip_master_key
|
||||
ENV["RAILS_MASTER_KEY"] || File.read(Pathname.new(File.expand_path("config/master.key")))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def valid?
|
||||
ensure_required_keys_present && ensure_env_available
|
||||
|
||||
@@ -4,7 +4,7 @@ class CommandsAppTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
ENV["RAILS_MASTER_KEY"] = "456"
|
||||
|
||||
@config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ] }
|
||||
@config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ], env: { "secret" => [ "RAILS_MASTER_KEY" ] } }
|
||||
@app = Mrsk::Commands::App.new Mrsk::Configuration.new(@config).tap { |c| c.version = "999" }
|
||||
end
|
||||
|
||||
@@ -26,13 +26,6 @@ class CommandsAppTest < ActiveSupport::TestCase
|
||||
@app.run.join(" ")
|
||||
end
|
||||
|
||||
test "run without master key" do
|
||||
ENV["RAILS_MASTER_KEY"] = nil
|
||||
@app = Mrsk::Commands::App.new Mrsk::Configuration.new(@config.tap { |c| c[:skip_master_key] = true })
|
||||
|
||||
assert @app.run.exclude?("RAILS_MASTER_KEY=456")
|
||||
end
|
||||
|
||||
test "start" do
|
||||
assert_equal \
|
||||
"docker start app-999",
|
||||
|
||||
@@ -143,15 +143,6 @@ class ConfigurationTest < ActiveSupport::TestCase
|
||||
assert_equal "app", @config.ssh_options[:user]
|
||||
end
|
||||
|
||||
test "master key" do
|
||||
assert_equal "456", @config.master_key
|
||||
end
|
||||
|
||||
test "skip master key" do
|
||||
config = Mrsk::Configuration.new(@deploy.tap { |c| c[:skip_master_key] = true })
|
||||
assert_nil @config.master_key
|
||||
end
|
||||
|
||||
test "volume_args" do
|
||||
assert_equal ["--volume", "/local/path:/container/path"], @config.volume_args
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user