Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow importing extra config #3906

Merged
merged 4 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ All notable changes to this project will be documented in this file.
- Add 'browser_versions.csv' to CSV export
- Add `CLICKHOUSE_MAX_BUFFER_SIZE_BYTES` env var which defaults to `100000` (100KB)
- Add alternative SMTP adapter plausible/analytics#3654
- Add `EXTRA_CONFIG_PATH` env var to specify extra Elixir config plausible/analytics#3906

### Removed
- Removed the nested custom event property breakdown UI when filtering by a goal in Goal Conversions
Expand Down
6 changes: 4 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ defmodule Plausible.MixProject do
releases: [
plausible: [
include_executables_for: [:unix],
applications: [plausible: :permanent],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the default applications

steps: [:assemble, :tar]
Copy link
Contributor Author

@ruslandoga ruslandoga Mar 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are copying all rel/ files directly, the tar archive ends up being unused.

config_providers: [
{Config.Reader,
path: {:system, "RELEASE_ROOT", "/import_extra_config.exs"}, imports: []}
]
]
],
dialyzer: [
Expand Down
8 changes: 8 additions & 0 deletions rel/overlays/import_extra_config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Config
import Plausible.ConfigHelpers

config_dir = System.get_env("CONFIG_DIR", "/run/secrets")

if extra_config_path = get_var_from_path_or_env(config_dir, "EXTRA_CONIFG_PATH") do
import_config extra_config_path
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This intermediate config file is needed as runtime.exs is forbidden from importing other configs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://hexdocs.pm/mix/Mix.Tasks.Release.html#module-runtime-configuration

It MUST NOT import any other configuration file via import_config

end