stable-diffusion-webui-docker icon indicating copy to clipboard operation
stable-diffusion-webui-docker copied to clipboard

[upgrade] Getting rid of unnecesary git clone of other repositories

Open DevilaN opened this issue 3 years ago • 5 comments

Currently service "download" and other services are using sequence of commands: git clone REPOSITORY_URL && cd REPO_DIR && git reset --hard COMMIT_SHA This unnecesary downloads entire repository history only to change it's state to specific commit.

It would be better not to download entire repository, but zip file from specific commit instead. Download link format is https://github.com/{username}/{projectname}/archive/{sha}.zip - then there is only a matter of unzipping and renaming directory.

DevilaN avatar Oct 14 '22 06:10 DevilaN

that is a great idea!

would you like to contribute?

AbdBarho avatar Oct 14 '22 06:10 AbdBarho

in the case of downloads using git, the depth flag exists to make shallow copies: --depth <depth> create a shallow clone of that depth

EDIT: Usage example would then be: mkdir -p repositories/CodeFormer && cd repositories/CodeFormer && git init && git remote add origin https://github.com/sczhou/CodeFormer && git fetch origin c5b4593074ba6214284d6acd5f1719b6c5d739af --depth=1 && git reset --hard c5b4593074ba6214284d6acd5f1719b6c5d739af

karpfediem avatar Oct 14 '22 07:10 karpfediem

@AbdBarho sure, but I am running only AUTOMATIC1111 version. Is that ok, to improve only it's Dockerfile or I have to do rework of other ones (I am not sure whether I've got enough disk space to build all images).

Also those changes will surely bust docker cache forcing users to rebuild entire image almost from scratch, so it would be better to merge it later with some bigger changes also involving cache bust, as for now it is small gain only, but gain nonetheless.

DevilaN avatar Oct 14 '22 07:10 DevilaN

@karpfediem that is also neat, maybe verbose, but still neat! is it faster than cloning the entire repo?

@DevilaN I would not worry too much about re-download, the git repositories themselves are rather small (with the exception of taming-transformers), the change in build time would be like + 2min, which is tolerable.

As you said, we can bundle that with a version update that will require a re-build anyway, and we are good to go. Don't stress about it if you can't, I could also implement it after finishing a prototypical implementation of #128

AbdBarho avatar Oct 14 '22 08:10 AbdBarho

@karpfediem that is also neat, maybe verbose, but still neat! is it faster than cloning the entire repo?

Yes, it will only download that specific commit with git fetch.

I'd argue against archive downloads since they are very much github specific, not that i've seen any other repositories being used though to be fair :sweat_smile:

karpfediem avatar Oct 14 '22 08:10 karpfediem

Remove .git directory afterwards. It is not necessary and takes half of space inside directory.

DevilaN avatar Oct 26 '22 20:10 DevilaN