-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Allow BUILD_ID to be set using generateBuildId
(minor)
#3873
Allow BUILD_ID to be set using generateBuildId
(minor)
#3873
Conversation
@craigmcnamara thanks for this. I think it's better to get this via |
I'm happy to rework this. Thanks for the feedback. |
server/build/index.js
Outdated
@@ -8,7 +8,7 @@ import md5File from 'md5-file/promise' | |||
|
|||
export default async function build (dir, conf = null) { | |||
const config = getConfig(dir, conf) | |||
const buildId = uuid.v4() | |||
const buildId = process.env.BUILD_ID || uuid.v4() |
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.
Lets do it like this:
let buildId
if(typeof config.generateBuildId === 'function') {
buildId = await config.generateBuildId() // `await` so that it can be an async function
} else {
buildId = uuid.v4()
}
This will allow the user to generate the buildId in whatever way they like, because you can do something async to get the buildId, like reading from the filesystem or fetching from some api.
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.
Lets also add an integration test for this case.
This makes multi server deploys with Capistrano possible.
75a9ddc
to
29b7fcf
Compare
(I work with @craigmcnamara) I have updated the PR as suggested. I couldn't find a comparable test that asserts config behaviour, so was unable to write a test that asserts this works. All I know is it doesn't crash, which isn't really enough, I admit. That said, now that I'm more familiar with this code, it seems odd to me that the default implementation is not stable. Is it unreasonable to default to generating an ID by hashing the contents of the project directory? There seem to be some quite small existing libraries that tackle this concern. |
enable customising the build id via config
29b7fcf
to
d95a232
Compare
it would be very much desired to get build_id based on contents of source (everything in current directory) this will make docker builds more predictable, this becomes an issue when used with CDN |
We’d like to see this completed and merged to for deployment purposes. Rather than relying on sticky sessions. Our first thought was using build_id from the git hash. |
…onsistent-build-ids # Conflicts: # server/build/index.js # server/config.js
Made some improvements, going to merge when the tests pass. |
generateBuildId
(minor)
Fixes #786
This makes multi server deploys with Capistrano possible.
I couldn't see a place to add tests for a thing like this, but I'm happy to if you point the way.