Skip to content

Commit

Permalink
fix: don't override paths in dockerfile
Browse files Browse the repository at this point in the history
This allows for these paths to continue to be set in the config file or environment variable while still maintaining the default of having the default paths in the same directory as the postal config file.
  • Loading branch information
adamcooke committed Mar 8, 2024
1 parent 22dcd49 commit 9399e32
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -353,7 +353,7 @@ DEPENDENCIES
jquery-rails
kaminari
klogger-logger
konfig-config (~> 2.0)
konfig-config (~> 3.0)
mail
moonrope
mysql2
Expand Down
19 changes: 16 additions & 3 deletions lib/postal/config_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
4 changes: 3 additions & 1 deletion spec/lib/postal/legacy_config_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit 9399e32

Please sign in to comment.