-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support for pre_compile
and post_compile
steps
#14
Comments
Thank you! Yeah this is on the list of things to consider - though it's possible I'll be dropping support for this in favour of people using the built-in inline buildpack feature instead, since it's not ideal for each language to reimplement custom run support. (For languages where there are built-in hooks, it's perhaps still worth supporting those, but for Python I'll leave this open to track that decision, and if the feature is dropped we'll need to add warning (or error) messages to ease the transition regardless. |
I haven't tried this new way of deployment yet, but I would like to leave a comment on the way I use post_compile today. I have an e-commerce platform made with Django + Frontend application in React. The deployment process has integration with Sentry releases. In Heroku Classic, you do not have access to GIT and repository, just an environment variable that informs which git commit hash of a particular deploy flow has started. The application has 2 independent react applications (one uses old things and another uses new and incompatible things, and we are gradually migrating to the new application) We use
1 - We perform Django's Collectstatic |
pre_compile
and post_compile
steps
For CNBs, the standardised way of running custom commands before/after buildpacks is now using the new built-in inline buildpacks feature, which is documented here: For language ecosystems where there is a standardised convention (for that language) way of running commands, I think it makes sense for the buildpacks for that language to keep supporting those conventions (for example, the Node.js buildpack supporting the However, for language ecosystems like Python where there is no such convention, I don't think it makes sense to preserve the classic Python buildpack's proprietary As such, I think I may not end up adding support for this in the Python CNB. Though I may end up adding some explicit error handling to ease the transition. (Which could for example print an example inline buildpack config to the build log, which users can then copy directly into their |
I understand the motivation here, but Previously I could do something like this: pack build myimage -b heroku/nodejs,heroku/python -B heroku/buildpacks:20 If I'm understanding the inline buildpacks, I now need to add a [_]
schema-version = "0.2"
id = "io.buildpacks.my-app"
[[io.buildpacks.group]]
id = "heroku/nodejs"
version = "1.1.2"
[[io.buildpacks.group]]
id = "heroku/python"
version = "0.4.0"
[[io.buildpacks.group]]
id = "me/post-compile"
[io.buildpacks.group.script]
api = "0.9"
inline = "echo hello" and then I can run: pack build myimage -B heroku/builder:22 Versions seem required in Maybe this is outside of Heroku's scope, but a thought I had was that a separate "run-script" buildpack could be published which executes a script from a predefined location (or location provided by env var)? |
The buildpack I agree that users may get the syntax of the Ref having to create a Whilst the
In addition, As such, I think having a In general though, I much prefer having buildpacks/stacks be configured via code rather than |
Yeah this is another viable solution too. Though perhaps a third option would be to ask for a simpler |
This comment was marked as resolved.
This comment was marked as resolved.
Thanks for the thoughtful write-up @edmorley! I see where you're coming from and the value in following a standard. If good examples are provided, the |
Edit: This bug was fixed upstream by buildpacks/pack#1873.
I agree it is seemingly more friendly at first glance, but it actually does cause quite a few issues that likely do not surface for experienced/diligent users (such as yourself :-)) but often trip beginners up - such as:
In addition, with CNBs we finally have a much better story for running a build locally that matches production in the form of |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I've long used |
Would it be best for someone (me, you, someone) to publish |
The issue here is that IMO one of the big wins of the migration from classic buildpacks to CNBs (for all Heroku languages) is that of switching from proprietary features/concepts to open standards and modern best practices. For example:
For some of these transitions (for example For some other differences between the classic Python buildpack and the CNB, the feature will be dropped and result in an error that explains how to migrate. I haven't decided yet which approach to use for Ultimately "run a custom command before/after one of my buildpacks" is not a Python specific feature - and should be something handled by the upstream CNB project (and already is - though there are likely UX improvements that could be made). If you have suggestions for UX improvements to how the upstream inline buildpack feature work, I'd strongly recommend opening some issues or starting a discussion upstream: Ultimately end users being able to influence the design of buildpack APIs and tooling is another of the advantages of switching to an open standard - so please do take advantage of that! 😄 |
It's not as pretty, but adding a [_]
schema-version = "0.2"
id = "io.buildpacks.my-app"
[[io.buildpacks.group]]
id = "heroku/nodejs"
[[io.buildpacks.group]]
id = "heroku/python"
[[io.buildpacks.group]]
id = "my-app/post-compile"
[io.buildpacks.group.script]
api = "0.9"
inline = "bin/post_compile" If your echo -e "\n\e[1;35m[post_compile]\e[0m" |
Thank you for the example - glad to see that works! Using an inline table allows for reducing the boilerplate a bit more (depending on personal taste for TOML style): [[io.buildpacks.group]]
id = "my-app/post-compile"
script = { api = "0.9", inline = "bin/post_compile" } I'll open a PR against the upstream docs to make them use the inline table approach in the |
@ipmb Hi! I happened to see: In that you say:
I'm not sure the comparison to Node.js build scripts under the However, the same cannot be said for Python, where there is (a) no built-in way to specify command aliases in general (even for use-cases like an app's custom internal "lint" command etc), (b) no common convention for what to call the "build" step or how to run it. The closest one can get to that is tool-proprietary features like Poetry's run alias feature, however, (a) not all package managers/tools support something like that, (b) for those that do, each tool uses a different way of specifying the list of aliases, (c) there isn't a standardised command alias naming convention for the step that should be run "for production builds, after package install" etc, (d) the scaffolding tools and example templates for popular frameworks don't configure/use these aliases (understandably, since there is no single way to support all the tools). Perhaps in the future In the meantime, the CNB inline buildpack feature seems like a pretty good standard to migrate people to, given that with CNBs we now actually have a standard (and not just some adhoc "run" classic buildpacks). (I'd also question the blog post calling it "internals" - buildpacks are part of the public API to users, and However, I definitely want the need to migrate away from |
I hear what you're saying... Node definitely has more of a standard here, but I don't think Python is so far off that you couldn't do something similar. The Node buildpack already supports non-standard Heroku-specific keys to run scripts ( There may be a little debate on it still, but My take is that it would be much more ergonomic for Python developers to define the scripts using Something like this in [tool.heroku-buildpack]
postbuild = "./bin/post-compile" Yes, there is no I can see this is probably going to be an agree-to-disagree situation, just trying to clarify my stance here :) |
Thanks to the metrics added in heroku/heroku-buildpack-python#1597 I now have some numbers. Hook status by percentage of total successful Python builds in the last 60 days:
If there was an existing Python standard (ie a PEP and an upstream spec that worked across multiple tools) for specifying pre/post install commands (like Node.js has), then I would agree with you. However, what you are proposing is still something proprietary that users would still have to discover and learn when using buildpacks for the first time. It being in one TOML file vs another is really the least of the issues when it comes to learning or discoverability (eg if new users haven't read our docs, then they won't know about that config either way). And if anything, they'll now have more they have to learn -- it's likely they'll still need to learn With the
We do absolutely need to show some migration advice for existing users of the Closing this as wontfix in favour of #288. I'm happy to revisit if either an upstream PEP adds pre/post install to the Python |
Just tested out
v0.1.0
and noticed this was missing. It looks like you have some other issues to get it to parity with the legacy buildpack, so just dropping this one in too.Thanks for your work on this!
The text was updated successfully, but these errors were encountered: