-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Making heroku-postgresql addon optional #1056
Conversation
37df587
to
225c525
Compare
…se does not read from env vars
225c525
to
eb187da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thank you for the PR :-)
I agree there may be occasions where one might not want the DB to be created. Though I have a few questions about your use case...
We create dev environment heroku apps on demand. It can be confusing to the devs when they see the default heroku DB being created.
What do you mean by "on demand"? Automatic review apps? Or do you mean you create non-heroku DBs by hand?
We might not need any databases for some databases.
(I'm presuming this meant "for some Django apps"?)
The current implementation only creates a DB if there is a Django manage.py
, though agree there may be cases where a DB is not required.
I took a look at what the Ruby buildpack does, and it only creates a DB iff using Rails and a postgres adapter gem is installed. Perhaps that's what we should do here instead of having it be opt-out like the current PR implementation?
Also if we did keep the opt-out, I think I prefer an env var - which means we'd need to use an approach similar to Ruby where the release metadata is actually generated during bin/compile
(where the ENV_DIR is available) and then loaded back off disk in bin/release
.
We'll also need to test this functionality :-)
Also, for your use-case is the DB still a Postgres DB or something else? |
Hi there!
We have dev environments that can be created via terraform, with that, we can create environments with various apps on various platforms on demand. We use Non-heroku DBs for some of our applications, e.g. RDS
Yes! Typo XD
We also have applications that don't use any DB at all.
I think keeping the opt-out might be better than opt-in, because the idea is, the buildpack would still work exactly the same as before(Unless opt-out of course). I also prefer env vars, but I tested different approaches, none of them seem to have worked. I tried to use ENV_DIR, and it didn't seem to be available. I also tried using |
Thank you for the extra details :-)
It does matter, since one of the solutions mentioned in #1056 (review) was to copy the Ruby buildpack and make the DB addition conditional on what packages were installed. ie: If the
Yeah The workaround is to have I've also started a discussion with the other language owners to see if they have any suggestions based on what the other languages do :-) |
But what if we do have psycopg2 installed, but we want to use an RDS postgres? In this case, the postgres addon will still be added automatically, and it still won't be ideal. It'd be nice if we can opt-out of the default addon by an env var.
I saw in
Would we be able to copy the entirety of
Thank you! 😸 I will let you know if I think of anything as well. |
There are a few scenarios here:
Scenario 1 and 2 are covered by the current implementation, since it checks for We could add an "opt out" implementation (either using file or env var), which would additionally solve scenarios 3-5, however users would need to know about opt-out and actually do it, whereas it would be better for this to work out of the box if possible. As such an alternative would be to have the default behaviour be to check for both That's not to say (3) is less important or necessarily something we should ignore, but this is the first time someone has asked about it (that I can find) since the auto DB feature was added in 2012 - so it was useful to know whether yours was this case or one of the others. Out of curiosity, how are the credentials set for the DB on these apps? Via
The detect, compile and release scripts are run in turn, and each is passed certain parameters. The release script is not passed the parameter that maps to env dir, so whilst it's theoretically on disk, the path isn't known. See:
This wouldn't be recommended, since it would leak secrets into the slug (or cache). The method I mentioned is the way this would need to be implemented (and is the way the Ruby buildpack does it). |
I did try populating
That would certainly be ideal, but how do we read, or know is DATABASE_URL is set? |
This is expected. I was meaning we'd still need to make changes to the buildpack, but that instead of using the custom
By checking for the presence of
Since this is restructuring the buildpack rather than just a one line change, I'd totally understand if you'd prefer me to make the change. Though this would need to go into my backlog and be prioritised accordingly, so I wouldn't be able to get to this immediately. |
I like the option of checking |
@BNMetrics Hi! I've filed two issues for tackling different parts of this topic:
I've also synced both of them to our internal work tracker, so they appear in the overall backlog. Do you have a sense of if you'd like to update this PR to address #1068 soon? If not, it might be best to close this PR out (since it's not ready for merge) and move the discussion to the issues pending either a new PR from the community, or the internal work items being prioritised in the backlog. |
Closing this out for now. Let's track potential solutions for the two different parts to this in the GitHub issues linked above. |
Use Cases:
Why is it important:
heroku-postgresql
addon part will only be included if there is a file stampno_default_addons
in theBUILD_DIR