Stale build cache leads to outdated dependencies after scalingo rebuild
0 reputation · 05 Apr 2020, 14:30 UTC
0 reputation · 05 Apr 2020, 14:30 UTC
Goal: guarantee that every Scalingo deploy uses only the current source code and dependencies, without any stale build‑cache artifacts affecting the resulting Docker image.
Uncertainty: while the `scalingo rebuild` command is documented to discard the cached layer, the platform’s build‑cache behavior may vary between free and paid plans, and environment variables such as DATABASE_URL that are injected at container start‑up could influence which layers are considered reusable.
Questions: Does `scalingo rebuild` reliably produce a clean build on both free and paid Scalingo plans? Are there circumstances under which cached layers persist despite a rebuild command? How can a user confirm that no stale cache was used without relying on build‑log inspection?
35275 reputation · 05 Apr 2020, 19:30 UTC
To guarantee that every Scalingo deploy uses only current source code and dependencies, use the scalingo rebuild command. This command explicitly instructs the platform to discard cached build layers and re-execute the buildpack process from scratch.
The scalingo rebuild command is designed to be reliable across both free and paid plans. While plan tiers may differ in build speed or resource allocation, the logic for cache invalidation remains consistent: it forces the buildpack to re-evaluate dependency manifests (such as package.json, Gemfile, or requirements.txt) rather than reusing a previously computed layer.
If dependencies still appear outdated after a rebuild, the issue is likely not the Scalingo build cache, but rather one of the following:
latest or wide version ranges (e.g., ^1.0.0) in your manifest. If the upstream registry has not updated the package, the buildpack will pull the same version again, mimicking a cached state.package-lock.json) is committed to the repository, the buildpack will prioritize the versions locked there over the ranges defined in the manifest.Note on Environment Variables: Variables like DATABASE_URL are typically injected at container start-up (runtime) and do not influence build-time layer caching.
To confirm a fresh build occurred without inspecting logs, use these methods:
scalingo ssh
# For Node.js:
npm list --depth=0
# For Ruby:
bundle list
scalingo ssh.Are you using a lockfile (e.g., yarn.lock, Gemfile.lock) in your repository? If so, the rebuild will strictly adhere to that file, which may be the source of the "stale" versions.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.