Make PASSKIT_ env variables not mandatory
Making PASSKIT_... variables mandatory makes Docker flow very strange:
RUN RAILS_ENV=production \
NODE_ENV=production \
PASSKIT_WEB_SERVICE_HOST=https://example.com \
PASSKIT_CERTIFICATE_KEY=NOT_USED_NON_BLANK \
PASSKIT_PRIVATE_P12_CERTIFICATE=NOT_USED_NON_BLANK \
PASSKIT_APPLE_INTERMEDIATE_CERTIFICATE=NOT_USED_NON_BLANK \
PASSKIT_APPLE_TEAM_IDENTIFIER=NOT_USED_NON_BLANK \
PASSKIT_PASS_TYPE_IDENTIFIER=NOT_USED_NON_BLANK \
bundle exec rails assets:precompile
Because those variables should not exists and/or be injected into Dockerfile. But, just because they are mandatory, assets:precompile crashes with error. However, on practice, they are not used at all by assets compilation.
As well a bit similar situation is with say db:migrate, which may crash in envs w/o such vars (again some simple one-off containers w/o full env).
I guess any other type of solution may be ok (later "normal" run errors, log warnigns, etc), but not the crash of the rails app if env is missing. I mean no any other gem in my memory seems to have such behaviour.
Thanks.
Yes, I agree. Maybe you have a bit of time to help and start from https://github.com/coorasse/passkit/pull/5 ? This would solve the issue I believe
As a quick 'n' dirty work around which seems to work on first inspection in Rails 8:
rails credentials:edit
Add:
passkit:
web_service_host: "https://your-host.com"
certificate_key: "your-key"
private_p12_certificate: "your-cert"
apple_intermediate_certificate: "your-intermediate-cert"
apple_team_identifier: "your-team-id"
pass_type_identifier: "your-pass-type-id"
dashboard_username: "dashboard-username"
dashboard_password: "dashboard-password"
Then add this to the top of config/initializers/passkit.rb
Rails.application.credentials.passkit&.each do |key, value|
ENV["PASSKIT_#{key.upcase}"] = value.to_s
end
I managed to migrate at least so far... I'll report back if anything goes awry.