Open jones1008 opened 11 months ago
Unable to set the port through an environment variable is painful.
The current workaround for this issue is to manually duplicate these values (e.g. $SUPABASE_API_PORT
now needs to be explicitly declared both in your .env
and in config.toml
.
This is an issue because it leaves the config.toml
vulnerable to going out-of-sync. (e.g. a team member updates the value of SUPABASE_API_PORT
in .env
but does not update it in config.toml
).
config.toml
already knows how to interpolate from environment variables. But it fails when the config key expects a integer. If the config key expects a string, everything works fine.
# config.toml
# this works (because `s3_region` expects value of type string)
s3_region = "env(S3_REGION)"
# this does not work (because `port` expects value of type integer)
port = "env(SUPABASE_API_PORT)"
toml: line 7 (last key "api.port"): incompatible types: TOML value has type string; destination has type integer
For config keys that expect type integer, we should attempt to coerce the input into an integer before failing.
It's intuitive; this is the behavior users are going to naturally expect. And I can't think of any downsides to doing this.
Being able to do this with boolean values as well would also solve issues in CI environments as discussed here: https://github.com/supabase/edge-runtime/issues/235
Being able to use config.toml
as a driver for a 12-factor style env approach for the local environment and deploy workflows for 1+ hosted environments would greatly simplify the environment workflow recommended in the docs too: https://supabase.com/docs/guides/cli/managing-environments
I first brought this up in the discussions but I think here is a more fitting space
Is your feature request related to a problem? Please describe. In my
config.toml
I tried to setup my ports to reference environment variables as follows:When trying to run
supabase start
now it throws me the following error:Describe the solution you'd like It seems the
env()
function is only supported for strings inside theconfig.toml
. It would be nice to also be able to configure your ports (type Integer) via environment variablesWe would need a solution that is
.toml
syntax compliant and allows for integer values (and potentially other types). I don't know the implementation of how supabase-cli replaces theenv()
with its variables at runtime (I don't know Go), but maybe we could make something that works like follows:The supabase-cli then could detect that it says
env() as integeer
and remove the whole string (including"
) so we would have only the integer at runtime but still have a valid.toml
syntax.Describe alternatives you've considered I tried to omit the
"
around theenv()
but that is a .toml syntax error:Error message:
Additional context