My solution, you might need to edit slightly:
Thanks. That will do.
I will wait a couple of days if I can get a Wappler-solution from the team, else implement this.
One question though… I have the same dockerfile that will get deployed for both dev and prod servers… Is there a way to identify the environment by reading the actual ENV variables in the dockerfile? @Apple
Sorry, I didn’t understand the question
You can define ENV variables in Caprover and it’ll use them during build
That’s what my question is. How to do that.
From what I see in the other post, you are just setting up the Wappler ENV binding strings.
Ah, true. I think I experimented with string interpolation at build time but threw it away
The technical term you want to search is Dockerfile string interpolation
E.g.
RUN echo $DB_PASS
You might need an ARG instruction before, like:
ARG DB_PASS
Caprover will pass environment variables as arguments (ARG)
Thanks. Will try.
Bump.
The config file already support $_ENV expressions
@patrick maybe it sems like it didn’tt due to booleans being parsed as strings(i.e. DEBUG).
Given that process.env
only supports strings could you add an explicit casting in the config.js file so when a value is parsed as "true"
or "false"
from $_ENV
it is casted to boolean before merging with the config
object?
You can use the expressions with formatters, $_ENV.DEBUG == "true"
should return a boolean and $ENV.TIMEOUT.toNumber()
should return a number.
For scheduler, setting the value worked. But not for debug.
{
"debug": "{{$_ENV.DEBUG_MODE == 'true'}}",
"cron": "{{$_ENV.RUN_SCHEDULER == 'true'}}",
"secret": "{{$_ENV.SITE_SECRET_KEY}}"
}
Scheduler runs as per the value of the ENV variable. But debug is always false when written like this.
Works. Thanks.
Fixed in Wappler 5.2.2