I have Forge setup to control an EC2 instance on AWS.
I have Forge connected to my Github.
When I try to deploy my app I am getting a "cannot deploy" error and when I look at the build logs its failing on a database query.
I have added my DB env variables to the Forge Env variables file and saved it. I can reload it and the variables are there. However shortly after I start a deploy the env file becomes empty again and I keep getting the deploy failing because it cannot connect to the database,
Clear the deploy script from any commands that connect to the database.
After deploying and installing dependencies access your .env file from Forge and add you variables. Then go to the commands page and run your database commands.
Lastly, put back your database commands in your deployment script.
So... a bit more progress and it seems that the real problem is that I can't connect to my database even though the env variables are there and correct. I haven't set a domain yet so I'm accessing the site via the IP address.
@Mick79 Go you the database tab, copy the name ( the default is forge). And the password of that DB should've sent to you via email first time you created the server. If you can't find it. Just set a new password to the forge database or create a new one.
@MohamedTammam So this is where I think the forge documentation falls down...
Anyway, my issue is I am using a pre-existing database and just setting those connection variables in the environment variables field. This seems to be working fine now but the site is a bit slower than it was in heroku.
my server and my database are both in us-east but... I feel like I'm not doing something I should be doing.
Hi Mick,
If you execute the "config:cache" command during deployment process, you should be sure that you are only calling the env function from within your configuration files. Once the configuration has been cached, the .env file will not be loaded and all calls to the env function will return null.