Skip to content
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

feat: build and push container image for ghcr.io, update docker.md, and other related fixes #2805

Merged
merged 19 commits into from
May 22, 2024

Conversation

xynydev
Copy link
Contributor

@xynydev xynydev commented Apr 24, 2024

I had some issues with the container and wanted to contrib the fixes back upstream. This has been tested to work on Fedora 39 and in GitHub Actions. Publishing an image on ghcr.io has no extra cost to you as the maintainer, but will make the life of users who prefer containers much easier.

See commits for more details. I'm also happy to answer questions.

@mashb1t
Copy link
Collaborator

mashb1t commented Apr 24, 2024

Hey @xynydev, thank you very much for your effort, much appreciated!
The thing is:
The initial Docker MR already included external registry publishing, but only @lllyasviel can add secrets to this repository, and as he hasn't responded since we've added Docker support we'd need him to set Secrets up in the first place...
So we're currently stuck here.

@mashb1t mashb1t added Size M medium change, isolated, testing with care documentation Improvements or additions to documentation labels Apr 25, 2024
@xynydev
Copy link
Contributor Author

xynydev commented Apr 26, 2024

Hey @mashb1t, this PR doesn't require repository secrets, because it pushes to the GitHub Container Repository (ghcr), which every repository with GitHub Actions has access to by default, using the GitHub token the workflow is run with.

.github/workflows/build_container.yml Outdated Show resolved Hide resolved
.github/workflows/build_container.yml Outdated Show resolved Hide resolved
.github/workflows/build_container.yml Outdated Show resolved Hide resolved
.github/workflows/build_container.yml Outdated Show resolved Hide resolved
entrypoint.sh Outdated Show resolved Hide resolved
docker.md Outdated Show resolved Hide resolved
@mashb1t mashb1t added this to the 2.4.0 milestone May 21, 2024
@mashb1t
Copy link
Collaborator

mashb1t commented May 21, 2024

Hey @xynydev, I've actually never worked with Github actions to ghcr.io before, so thanks a lot for the explanation.
The goal is only to build an image on releases tagged with versions (semver conform) and I'll have to do the switch from X.X.X to vX.X.X scheme to better distinguish version tags from other ones.
Please double-check the changes.

xynydev and others added 6 commits May 22, 2024 15:37
Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>
…pt2)

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>
Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>
Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>
Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>
Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>
@xynydev
Copy link
Contributor Author

xynydev commented May 22, 2024

The goal is only to build an image on releases tagged with versions (semver conform) and I'll have to do the switch from X.X.X to vX.X.X scheme to better distinguish version tags from other ones.
Please double-check the changes.

Sounds great. I went ahead and merged your changes. I haven't used the semver option in the docker metadata action, but your suggestion looks alright. I'll see if I can do testing in my repo to validate that it works.

@xynydev
Copy link
Contributor Author

xynydev commented May 22, 2024

Aight, it worked:
https://github.com/xynydev/Fooocus-fork/actions/runs/9194578288/job/25288353110
https://github.com/xynydev/Fooocus-fork/pkgs/container/fooocus-fork

The tag is 2.3.1 not v2.3.1, though. It might be possible to override that somehow, but everything works well enough now I guess.

Note that the current on: push: condition will only create a new container image when a new tag is created with a new commit in it. This would probably mean that the previous versions wouldn't get container images, only the next one. Also, if anyone has a reason to use an older image, they will get the one that was built that one time, without any fixes that might have been made upstream or in Fooocus' Dockerfile.

@mashb1t
Copy link
Collaborator

mashb1t commented May 22, 2024

@xynydev thanks for testing, much appreciated!
Tagging in docker with 2.3.1 is expected, git tag has to be v2.3.1 though.

Also, if anyone has a reason to use an older image, they will get the one that was built that one time, without any fixes that might have been made upstream or in Fooocus' Dockerfile.

This is also expected.
Older images are not necessarily planned to be built, first one is the upcoming 2.4.0.
Do you know if a tag on an existing commit will also trigger the pipeline? (this would be the preferred behavior)

@xynydev
Copy link
Contributor Author

xynydev commented May 22, 2024

From my testing, I'm not sure. I first created a tag on an existing commit and nothing happened. I then made a meaningles commit, pushed it, tagged it locally, and pushed the tag, and then it was triggered.

mashb1t added a commit to mashb1t/Fooocus that referenced this pull request May 22, 2024
@mashb1t
Copy link
Collaborator

mashb1t commented May 22, 2024

@xynydev just tested, the tag has to be on a branch where this change is already included, see https://github.com/mashb1t/Fooocus/actions/runs/9196855992/job/25296038248
Tagging and building older versions is consequently not possible, but also not needed.

@mashb1t
Copy link
Collaborator

mashb1t commented May 22, 2024

I assume this is a personal issue but I'm getting this error with driver 555.85:
RuntimeError: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 500: named symbol not found

May i ask which driver you're using?
EDIT nvm, works with driver 552.44. Docker may need to add support for the latest driver.

@mashb1t mashb1t changed the base branch from main to develop May 22, 2024 22:19
@mashb1t mashb1t merged commit 4da5a68 into lllyasviel:develop May 22, 2024
@xynydev xynydev deleted the container-updates branch May 23, 2024 13:27
csokun pushed a commit to csokun/Fooocus that referenced this pull request Jun 16, 2024
…nd other related fixes (lllyasviel#2805)

* chore: update cuda version in container

* fix: use symlink to fix error libcuda.so: cannot open shared object file:

* fix: update docker entrypoint to use entry_with_update.py

* feat: add container build & push workflow

* fix: container action run conditions

* fix: container action versions

* fix: container action versions v2

* fix: docker action registry login and metadata

* docs: adjust docker documentation based on latest changes, add docs for podman and docker

* chore: replace image name env var with github.event.repository.name

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* chore: replace image name env var with github.event.repository.name (pt2)

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* fix: switch to semver versioning

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* fix: build only on versioned tags

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* fix: don't update in entrypoint

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* fix: remove dash in "docker-compose"

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* feat: sync pytorch for docker with version used in prepare_environment

* feat: update cuda to 12.4.1

* fix: correctly clone checked out version in builds, not always main

* refactor: remove irrelevant version in docker-compose.yml

---------

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>
Co-authored-by: Manuel Schmid <dev@mash1t.de>
csokun pushed a commit to csokun/Fooocus that referenced this pull request Jul 17, 2024
…nd other related fixes (lllyasviel#2805)

* chore: update cuda version in container

* fix: use symlink to fix error libcuda.so: cannot open shared object file:

* fix: update docker entrypoint to use entry_with_update.py

* feat: add container build & push workflow

* fix: container action run conditions

* fix: container action versions

* fix: container action versions v2

* fix: docker action registry login and metadata

* docs: adjust docker documentation based on latest changes, add docs for podman and docker

* chore: replace image name env var with github.event.repository.name

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* chore: replace image name env var with github.event.repository.name (pt2)

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* fix: switch to semver versioning

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* fix: build only on versioned tags

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* fix: don't update in entrypoint

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* fix: remove dash in "docker-compose"

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>

* feat: sync pytorch for docker with version used in prepare_environment

* feat: update cuda to 12.4.1

* fix: correctly clone checked out version in builds, not always main

* refactor: remove irrelevant version in docker-compose.yml

---------

Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com>
Co-authored-by: Manuel Schmid <dev@mash1t.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation Size M medium change, isolated, testing with care
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants