API Env Variables with CI/CD Bitbucket Pipelines

I need to configure my wappler project as API only and deploy it in aws with CI/CD using bitbucket pipelines.

I found how to setup env variables on global section, but I see in code they are in a json file.

how I can have env variables in a .env file, so I can deploy them in aws with bitbucket pipelines.

I need to do this in order to manage multiple environments(development, staging, production) and change .Env file by every environment.

Please let me know how is the expected way to handle this in Wappler.

Thanks

Pretty standard. Add .env in the root of your project. Nodejs backend will pick it up.

1 Like

can you explain this? I mean, If I add the .env file, how it’s going to read it from my env variables set in global?

For example, I have this:

Then, I have filled this env variables here:

how nodejs app will know they must take .env values instead these ones?

also, how app should be build once it’s on server?

You can remove the ones from Server Connect settings as you are not going to use Wappler deployment.

Just use your .env file for your local development machine and set the env for each AWS environment you are planning to use(I guess staging and production).

I think I don’t get it, on wappler, once you change between targets, it’s moving values from .wappler/targets/Development/app/config/config.json to app/config/config.json

how app will know it needs to take .env values instead the ones set in app/config/config.json?

do you have an example about how to do this? I am kind of lost on this.

Damn targets. They just add more confusion than solve problems :joy:

So you mentioned that you want to deploy using CI/CD. That basically means that you don’t need multiple targets.

Just one target called development or local where you build your app.

Once you push your code to your bitbucket remote repo CI/CD takes the lead and deploys your stuff to AWS.

Wappler uses the dotenv package so if it finds at the root a .env file it will load the variables to process.env and that should be enough for your development environment/target.

Then you just need to make sure that your staging and production environments also load the env variables you want for each environment. Each hosting has its own way so make sure to read AWS docs on that.

1 Like

To clarify further, there is no practical use of the ENV tab in server connect settings and the config json from what I know.
Just the .env file is used when running the app locally as well. I deploy via Caprover, so .env is not used on server. Based on how/where you deploy, standard env practices should work.

Thanks a lot, I removed keys from environment and added them as .env all seems to work as expected, thanks for your help!

1 Like

That will be two arrachera :taco: :taco:

Yeah. I am obsessed with mexican food(the real thing).

2 Likes

hahaha yeah, tacos is my favorite food, even if that sounds very cliche, I love them.
you should taste Roast beef tacos with lot of salsa, they’re the best!

2 Likes

Y mucha salsa verde!

2 Likes

hahaha that looks pretty good!

1 Like