-
Notifications
You must be signed in to change notification settings - Fork 6
feat: decouple tag, name, and version #46
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
Conversation
9ff5d06 to
7d7c66b
Compare
|
This decouples the name of the cluster from the version and image it is running. The
# run a specific docker repo and tag on the customdev context
d2 cluster up customdev --repo amcgee/dhis2-core --tag dev-latest
# => http://localhost:8080/customdev
# set the DHIS2 version to use to find the right DB version dump
d2 cluster up dev --ver=dev --seed
# => http://localhost:8080/dev
# use defaults from `~/.config/d2` config
cat ~/.config/d2/config.js
module.exports = {
cluster: {
dockerComposeRepository: 'https://github.com/varl/dhis2-backend/archive/master.tar.gz',
demoDatabaseURL: 'https://github.com/dhis2/dhis2-demo-db/blob/master/sierra-leone/{version}/dhis2-db-sierra-leone.sql.gz?raw=true',
tag: 'dev-latest-alpine',
repo: 'dhis2/core',
ver: 'dev',
}
}
d2 cluster up mydev
# => http://localhost:8080/mydevStill a work in progress. |
|
Depends on https://github.com/varl/dhis2-backend as there are some |
|
New config file: module.exports = {
cluster: {
dockerComposeRepository: 'https://github.com/varl/dhis2-backend/archive/master.tar.gz',
demoDatabaseURL: 'https://github.com/dhis2/dhis2-demo-db/blob/master/sierra-leone/{version}/dhis2-db-sierra-leone.sql.gz?raw=true',
tag: '{version}-latest-alpine',
repo: 'dhis2/core',
}
}This works, too:
Spins up amcgee/dhis2-core:dev-alpine with a 2.32 database and deploys it on if If the So |
|
One thing to look out for is that the default config for the entire cli lives in cli-helpers-engine. |
|
|
|
This works now. :) |
|
@amcgee This does not aim to add the API proposed in #45, nor add the single-port gateway, but do the groundwork to decouple some assumptions about Docker repo/tag, DHIS2 versions, context, etc. Requires this line to be changed: https://github.com/amcgee/dhis2-backend/blob/master/docker-compose.yml#L4 to: And either a Would be nice to be able to define the default configuration for the |
|
Doesn't really matter, but you could change this: const resolvedVersion = ver ? ver : name
const resolvedTag = tag
? tag
: cluster.tag.replace(/{version}/g, resolvedVersion)
const resolvedRepo = repo ? repo : cluster.repo
const resolvedPort = port ? port : cluster.portto this const resolvedVersion = ver || name
const resolvedTag = tag || cluster.tag.replace(/{version}/g, resolvedVersion)
const resolvedRepo = repo || cluster.repo
const resolvedPort = port || cluster.portReads a bit nicer, but I don't care, so totally up to you |
|
@varl very nice! I agree it would be awesome to support per-module config defaults. I'll look into adding that to the engine. In the meantime maybe it's best to just define the defaults in-line here, following on what @Mohammer5 suggested - |
|
Is there a reason to configure |
|
Thanks for the input, cleaned it up a bit. 👍 There's more to do but with the So the responsibility of the Those defaults can be reused for the default values for e.g. port, so there is a single place to change them if need be. |
amcgee
left a comment
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.
Nice, looks great !! Will test Monday
|
One heads up here; this does not support hosting the context from I can add a Update8c4b70a offers this feature. |
|
8c4b70a adds a
It's possible to set |
|
@amcgee I'm pretty much content with this now, ready for review. |
|
This line: https://github.com/dhis2/cli/pull/46/files#diff-daa1df464973ea1a08c2c122f6a38b65R3 Depends on the outcome of what the image pushed to hub.docker.com/r/dhis2/core is, which will be decided by: https://github.com/dhis2/dhis2-core/pull/3326/files#diff-48b252da11ed2edeae1188be3f75660eR32 Related: dhis2/dhis2-core#3326 |
|
This brings up the question if we should merge That is if this PR is the way to move forward for now. |
amcgee
left a comment
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.
I think this looks great and nearly there! I made a couple comments, specifically about defaulting to a root context. The image pattern as-is actually works just fine, but not for released versions. If we expect 2.32-latest in place of 2.32 it would work for both.
|
This is now compatible with |
|
Found an edge case we might want to deal with or call a "known issue": The last To solve this the right way we'll need to keep state about all named containers and their parameters. We probably want to do that anyway, but I'm OK with calling that a future enhancement. |
amcgee
left a comment
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.
Tested and this seems to work well - if we're OK having the above known issue I'm happy with this change! @varl recommend a squash-merge ;-)
Ah, shoot. I forgot about this. I ran into the same problem, put it on the back burner and subsequently forgot about it. I was thinking about wanting to be able to e.g. configure my clusters in the config file: And that it should interact with the cache for un-configured values, which were passed at the time of the first |
Yeah, I think so. |
# [1.1.0](v1.0.5...v1.1.0) (2019-05-23) ### Features * decouple tag, name, and version ([#46](#46)) ([28e88e4](28e88e4))
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
In preparation for #45 this PR experiments with the consequences of decoupling the version, tag, and name of a cluster.