diff --git a/Dockerfile b/Dockerfile index a0a209e1..b1f4a2bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,9 +48,6 @@ RUN echo $VERSION > VERSION # Set paths for when running in a container ENV POSTAL_CONFIG_FILE_PATH=/config/postal.yml -ENV POSTAL_SIGNING_KEY_PATH=/config/signing.key -ENV SMTP_SERVER_TLS_CERTIFICATE_PATH=/config/smtp.cert -ENV SMTP_SERVER_TLS_PRIVATE_KEY_PATH=/config/smtp.key # Set the CMD ENTRYPOINT [ "/docker-entrypoint.sh" ] diff --git a/Gemfile b/Gemfile index 46eca03a..c3efa379 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ gem "hashie" gem "highline", require: false gem "kaminari" gem "klogger-logger" -gem "konfig-config", "~> 2.0" +gem "konfig-config", "~> 3.0" gem "mail" gem "moonrope" gem "mysql2" diff --git a/Gemfile.lock b/Gemfile.lock index 172a5225..c6b997b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -149,7 +149,7 @@ GEM concurrent-ruby (>= 1.0, < 2.0) json rouge (>= 3.30, < 5.0) - konfig-config (2.1.1) + konfig-config (3.0.0) hashie loofah (2.22.0) crass (~> 1.0.2) @@ -353,7 +353,7 @@ DEPENDENCIES jquery-rails kaminari klogger-logger - konfig-config (~> 2.0) + konfig-config (~> 3.0) mail moonrope mysql2 diff --git a/lib/postal/config_schema.rb b/lib/postal/config_schema.rb index 42a661a4..45a55086 100644 --- a/lib/postal/config_schema.rb +++ b/lib/postal/config_schema.rb @@ -68,7 +68,8 @@ module Postal string :signing_key_path do description "Path to the private key used for signing" - default "config/postal/signing.key" + default "$config-file-root/signing.key" + transform { |v| Postal.substitute_config_file_root(v) } end string :smtp_relays do @@ -253,12 +254,14 @@ module Postal string :tls_certificate_path do description "The path to the SMTP server's TLS certificate" - default "config/postal/smtp.cert" + default "$config-file-root/smtp.cert" + transform { |v| Postal.substitute_config_file_root(v) } end string :tls_private_key_path do description "The path to the SMTP server's TLS private key" - default "config/postal/smtp.key" + default "$config-file-root/smtp.key" + transform { |v| Postal.substitute_config_file_root(v) } end string :tls_ciphers do @@ -502,4 +505,14 @@ module Postal end end + class << self + + def substitute_config_file_root(string) + return if string.nil? + + string.gsub(/\$config-file-root/i, File.dirname(Postal.config_file_path)) + end + + end + end diff --git a/spec/lib/postal/legacy_config_source_spec.rb b/spec/lib/postal/legacy_config_source_spec.rb index a3b69550..0032a3ba 100644 --- a/spec/lib/postal/legacy_config_source_spec.rb +++ b/spec/lib/postal/legacy_config_source_spec.rb @@ -17,7 +17,9 @@ module Postal # by the schema itself. Otherwise, we might see a value returned that # looks correct but is actually the default rather than the value from # config file. - allow_any_instance_of(Konfig::SchemaAttribute).to receive(:default).and_return(nil) + allow_any_instance_of(Konfig::SchemaAttribute).to receive(:default) do |a| + a.array? ? [] : nil + end end let(:source) { described_class.new(SOURCE_CONFIG) }