feat: build and push container image for ghcr.io, update docker.md, and other related fixes (#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>
This commit is contained in:
parent
302bfdf855
commit
4da5a68c10
|
|
@ -1 +1,54 @@
|
||||||
.idea
|
__pycache__
|
||||||
|
*.ckpt
|
||||||
|
*.safetensors
|
||||||
|
*.pth
|
||||||
|
*.pt
|
||||||
|
*.bin
|
||||||
|
*.patch
|
||||||
|
*.backup
|
||||||
|
*.corrupted
|
||||||
|
*.partial
|
||||||
|
*.onnx
|
||||||
|
sorted_styles.json
|
||||||
|
/input
|
||||||
|
/cache
|
||||||
|
/language/default.json
|
||||||
|
/test_imgs
|
||||||
|
config.txt
|
||||||
|
config_modification_tutorial.txt
|
||||||
|
user_path_config.txt
|
||||||
|
user_path_config-deprecated.txt
|
||||||
|
/modules/*.png
|
||||||
|
/repositories
|
||||||
|
/fooocus_env
|
||||||
|
/venv
|
||||||
|
/tmp
|
||||||
|
/ui-config.json
|
||||||
|
/outputs
|
||||||
|
/config.json
|
||||||
|
/log
|
||||||
|
/webui.settings.bat
|
||||||
|
/embeddings
|
||||||
|
/styles.csv
|
||||||
|
/params.txt
|
||||||
|
/styles.csv.bak
|
||||||
|
/webui-user.bat
|
||||||
|
/webui-user.sh
|
||||||
|
/interrogate
|
||||||
|
/user.css
|
||||||
|
/.idea
|
||||||
|
/notification.ogg
|
||||||
|
/notification.mp3
|
||||||
|
/SwinIR
|
||||||
|
/textual_inversion
|
||||||
|
.vscode
|
||||||
|
/extensions
|
||||||
|
/test/stdout.txt
|
||||||
|
/test/stderr.txt
|
||||||
|
/cache.json*
|
||||||
|
/config_states/
|
||||||
|
/node_modules
|
||||||
|
/package-lock.json
|
||||||
|
/.coverage*
|
||||||
|
/auth.json
|
||||||
|
.DS_Store
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
name: Create and publish a container image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
FROM nvidia/cuda:12.3.1-base-ubuntu22.04
|
FROM nvidia/cuda:12.4.1-base-ubuntu22.04
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
ENV CMDARGS --listen
|
ENV CMDARGS --listen
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ RUN chown -R user:user /content
|
||||||
WORKDIR /content
|
WORKDIR /content
|
||||||
USER user
|
USER user
|
||||||
|
|
||||||
RUN git clone https://github.com/lllyasviel/Fooocus /content/app
|
COPY . /content/app
|
||||||
RUN mv /content/app/models /content/app/models.org
|
RUN mv /content/app/models /content/app/models.org
|
||||||
|
|
||||||
CMD [ "sh", "-c", "/content/entrypoint.sh ${CMDARGS}" ]
|
CMD [ "sh", "-c", "/content/entrypoint.sh ${CMDARGS}" ]
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
version: '3.9'
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
fooocus-data:
|
fooocus-data:
|
||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build: .
|
build: .
|
||||||
image: fooocus
|
image: ghcr.io/lllyasviel/fooocus
|
||||||
ports:
|
ports:
|
||||||
- "7865:7865"
|
- "7865:7865"
|
||||||
environment:
|
environment:
|
||||||
|
|
|
||||||
82
docker.md
82
docker.md
|
|
@ -1,35 +1,99 @@
|
||||||
# Fooocus on Docker
|
# Fooocus on Docker
|
||||||
|
|
||||||
The docker image is based on NVIDIA CUDA 12.3 and PyTorch 2.0, see [Dockerfile](Dockerfile) and [requirements_docker.txt](requirements_docker.txt) for details.
|
The docker image is based on NVIDIA CUDA 12.4 and PyTorch 2.1, see [Dockerfile](Dockerfile) and [requirements_docker.txt](requirements_docker.txt) for details.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- A computer with specs good enough to run Fooocus, and proprietary Nvidia drivers
|
||||||
|
- Docker, Docker Compose, or Podman
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
**This is just an easy way for testing. Please find more information in the [notes](#notes).**
|
**More information in the [notes](#notes).**
|
||||||
|
|
||||||
|
### Running with Docker Compose
|
||||||
|
|
||||||
1. Clone this repository
|
1. Clone this repository
|
||||||
2. Build the image with `docker compose build`
|
2. Run the docker container with `docker compose up`.
|
||||||
3. Run the docker container with `docker compose up`. Building the image takes some time.
|
|
||||||
|
### Running with Docker
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker run -p 7865:7865 -v fooocus-data:/content/data -it \
|
||||||
|
--gpus all \
|
||||||
|
-e CMDARGS=--listen \
|
||||||
|
-e DATADIR=/content/data \
|
||||||
|
-e config_path=/content/data/config.txt \
|
||||||
|
-e config_example_path=/content/data/config_modification_tutorial.txt \
|
||||||
|
-e path_checkpoints=/content/data/models/checkpoints/ \
|
||||||
|
-e path_loras=/content/data/models/loras/ \
|
||||||
|
-e path_embeddings=/content/data/models/embeddings/ \
|
||||||
|
-e path_vae_approx=/content/data/models/vae_approx/ \
|
||||||
|
-e path_upscale_models=/content/data/models/upscale_models/ \
|
||||||
|
-e path_inpaint=/content/data/models/inpaint/ \
|
||||||
|
-e path_controlnet=/content/data/models/controlnet/ \
|
||||||
|
-e path_clip_vision=/content/data/models/clip_vision/ \
|
||||||
|
-e path_fooocus_expansion=/content/data/models/prompt_expansion/fooocus_expansion/ \
|
||||||
|
-e path_outputs=/content/app/outputs/ \
|
||||||
|
ghcr.io/lllyasviel/fooocus
|
||||||
|
```
|
||||||
|
### Running with Podman
|
||||||
|
|
||||||
|
```sh
|
||||||
|
podman run -p 7865:7865 -v fooocus-data:/content/data -it \
|
||||||
|
--security-opt=no-new-privileges --cap-drop=ALL --security-opt label=type:nvidia_container_t --device=nvidia.com/gpu=all \
|
||||||
|
-e CMDARGS=--listen \
|
||||||
|
-e DATADIR=/content/data \
|
||||||
|
-e config_path=/content/data/config.txt \
|
||||||
|
-e config_example_path=/content/data/config_modification_tutorial.txt \
|
||||||
|
-e path_checkpoints=/content/data/models/checkpoints/ \
|
||||||
|
-e path_loras=/content/data/models/loras/ \
|
||||||
|
-e path_embeddings=/content/data/models/embeddings/ \
|
||||||
|
-e path_vae_approx=/content/data/models/vae_approx/ \
|
||||||
|
-e path_upscale_models=/content/data/models/upscale_models/ \
|
||||||
|
-e path_inpaint=/content/data/models/inpaint/ \
|
||||||
|
-e path_controlnet=/content/data/models/controlnet/ \
|
||||||
|
-e path_clip_vision=/content/data/models/clip_vision/ \
|
||||||
|
-e path_fooocus_expansion=/content/data/models/prompt_expansion/fooocus_expansion/ \
|
||||||
|
-e path_outputs=/content/app/outputs/ \
|
||||||
|
ghcr.io/lllyasviel/fooocus
|
||||||
|
```
|
||||||
|
|
||||||
When you see the message `Use the app with http://0.0.0.0:7865/` in the console, you can access the URL in your browser.
|
When you see the message `Use the app with http://0.0.0.0:7865/` in the console, you can access the URL in your browser.
|
||||||
|
|
||||||
Your models and outputs are stored in the `fooocus-data` volume, which, depending on OS, is stored in `/var/lib/docker/volumes`.
|
Your models and outputs are stored in the `fooocus-data` volume, which, depending on OS, is stored in `/var/lib/docker/volumes/` (or `~/.local/share/containers/storage/volumes/` when using `podman`).
|
||||||
|
|
||||||
|
## Building the container locally
|
||||||
|
|
||||||
|
Clone the repository first, and open a terminal in the folder.
|
||||||
|
|
||||||
|
Build with `docker`:
|
||||||
|
```sh
|
||||||
|
docker build . -t fooocus
|
||||||
|
```
|
||||||
|
|
||||||
|
Build with `podman`:
|
||||||
|
```sh
|
||||||
|
podman build . -t fooocus
|
||||||
|
```
|
||||||
|
|
||||||
## Details
|
## Details
|
||||||
|
|
||||||
### Update the container manually
|
### Update the container manually (`docker compose`)
|
||||||
|
|
||||||
When you are using `docker compose up` continuously, the container is not updated to the latest version of Fooocus automatically.
|
When you are using `docker compose up` continuously, the container is not updated to the latest version of Fooocus automatically.
|
||||||
Run `git pull` before executing `docker compose build --no-cache` to build an image with the latest Fooocus version.
|
Run `git pull` before executing `docker compose build --no-cache` to build an image with the latest Fooocus version.
|
||||||
You can then start it with `docker compose up`
|
You can then start it with `docker compose up`
|
||||||
|
|
||||||
### Import models, outputs
|
### Import models, outputs
|
||||||
If you want to import files from models or the outputs folder, you can uncomment the following settings in the [docker-compose.yml](docker-compose.yml):
|
|
||||||
|
If you want to import files from models or the outputs folder, you can add the following bind mounts in the [docker-compose.yml](docker-compose.yml) or your preferred method of running the container:
|
||||||
```
|
```
|
||||||
#- ./models:/import/models # Once you import files, you don't need to mount again.
|
#- ./models:/import/models # Once you import files, you don't need to mount again.
|
||||||
#- ./outputs:/import/outputs # Once you import files, you don't need to mount again.
|
#- ./outputs:/import/outputs # Once you import files, you don't need to mount again.
|
||||||
```
|
```
|
||||||
After running `docker compose up`, your files will be copied into `/content/data/models` and `/content/data/outputs`
|
After running the container, your files will be copied into `/content/data/models` and `/content/data/outputs`
|
||||||
Since `/content/data` is a persistent volume folder, your files will be persisted even when you re-run `docker compose up --build` without above volume settings.
|
Since `/content/data` is a persistent volume folder, your files will be persisted even when you re-run the container without the above mounts.
|
||||||
|
|
||||||
|
|
||||||
### Paths inside the container
|
### Paths inside the container
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,2 @@
|
||||||
torch==2.0.1
|
torch==2.1.0
|
||||||
torchvision==0.15.2
|
torchvision==0.16.0
|
||||||
torchaudio==2.0.2
|
|
||||||
torchtext==0.15.2
|
|
||||||
torchdata==0.6.1
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue