Closed ltalirz closed 3 years ago
@josegonzalez This is a first step. Ideally, one would also check the version that is currently checked out and update it (+ redeploy the app) if it is out of sync.
By the way, I could easily add a test in verify.yml
that dokku_clone
s an app - do you have a "fast & small" app in mind that one could use for this purpose?
Does git:report have a flag for showing the current deployed commit?
Heroku's getting started apps seem reasonable, don't know which would be fastest (php? go?): https://github.com/heroku/?q=getting-started&type=&language=
Does git:report have a flag for showing the current deployed commit?
It does have a way of printing the current commit
$ dokku git:report seekpath
=====> seekpath git information
Git deploy branch: master
Git global deploy branch: master
Git keep git dir: false
Git rev env var: GIT_REV
Git sha: 0dd3357
Git last updated at:
ubuntu@dev-dokku:~$ dokku git:report seekpath --git-sha
0dd3357
However, dokku clone
only allows specifying tags or branch names (and I guess users will typically want to use tags), i.e. we would need a way to first translate the tag into the corresponding sha
in order to compare to the output of git:report
.
The alternative would be to simply run the dokku clone
command by default (which should be a no-op if the app is already at the latest version) and report back the results of what happened; relying on its logic instead of trying to implement the logic here inside the ansible role.
This would be analogous to how the ansible git module works, and it seems the most logical approach to me.
We just need to keep in mind that this will be a change in behavior of the ansible role, i.e. when re-running a dokku_clone
task, it will then clone the app also if it is already present.
@josegonzalez What do you think?
Heroku's getting started apps seem reasonable, don't know which would be fastest (php? go?): https://github.com/heroku/?q=getting-started&type=&language=
Thanks. I see that none of these "getting-started" apps seem to have tags, and relying on the master
branch would potentially introduce unreproducible builds into our CI.
On the other hand I guess one can assume that these are pretty stable (?)
P.S. In any case, we can merge this PR already and handle this additional step in a separate one.
simply run the
dokku clone
command by default (which should be a no-op if the app is already at the latest version)
Hm, now that I tested this, I realize that (different from git clone
) this is actually not the case - even when the app repository is up to date, dokku clone
will rebuild the docker image and create a new container.
Should one perhaps add a flag that skips all of this, when the git repository is already up to date?
We could add the last cloned change to the dokku clone:report
output (that command doesn't exist, so I'd need to add it)? A master
clone would potentially be different for fresh runs at different times, but I think if you want idempotent runs, you'd either use an immutable tag (I know, they are mutable) or a commit sha?
We could add the last cloned change to the
dokku clone:report
output (that command doesn't exist, so I'd need to add it)?
Maybe yes?
You would prefer this to adding a flag to dokku clone
that skips deployment if there are no changes on the git level?
A
master
clone would potentially be different for fresh runs at different times, but I think if you want idempotent runs, you'd either use an immutable tag (I know, they are mutable) or a commit sha?
Right, that is how the ansible git module works as well.
And it would definitely be nice to be able to specify a commit sha for dokku clone
(which currently only accepts git branches and tags).
By the way I just noticed that cloning tags also doesn't work for me (weird... I thought I tested it before):
It fails because there is a check for the heads/master
file in the git
module:
$ dokku clone seekpath3 https://github.com/materialscloud-org/tools-seekpath v20.11.0
-----> Creating seekpath3...
...
-----> Creating seekpath3 from https://github.com/materialscloud-org/tools-seekpath v20.11.0
/var/lib/dokku/plugins/available/git/functions: line 172: /home/dokku/seekpath3/refs/heads/master: No such file or directory
Just to show that things work fine without the tag:
$ dokku clone seekpath2 https://github.com/materialscloud-org/tools-seekpath
-----> Creating seekpath2...
...
-----> Creating seekpath2 from https://github.com/materialscloud-org/tools-seekpath master
-----> Cleaning up...
-----> Building seekpath2 from dockerfile...
-----> Setting config vars
DOKKU_DOCKERFILE_PORTS: 80
...
I'm closing this PR until this is resolved and opened https://github.com/crisward/dokku-clone/issues/22 for this.
fix #88
Allow to specify a version when cloning apps (to enable reproducible builds).