Skip to content

Commit

Permalink
Add dockerhub CUDA builds
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Aug 15, 2024
1 parent 1559489 commit cda8333
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 34 deletions.
64 changes: 46 additions & 18 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
matrix:
build:
# Undeclared release tag finds latest from GitHub tags
- {latest: "true", tag: "v2.4.3", python: "3.10", pytorch: "2.3.0"}
- {latest: "false", tag: "v2.5.5", python: "3.10", pytorch: "2.4.0"}
steps:
-
name: Free Space
Expand All @@ -33,7 +33,9 @@ jobs:
-
name: Env Setter
run: |
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
REPO=${GITHUB_REPOSITORY,,}
echo "REPO_NAMESPACE=${REPO%%/*}" >> ${GITHUB_ENV}
echo "REPO_NAME=${REPO#*/}" >> ${GITHUB_ENV}
-
name: Checkout
uses: actions/checkout@v3
Expand All @@ -43,17 +45,24 @@ jobs:
reponame="$(basename ${GITHUB_REPOSITORY})"
target="${HOME}/work/${reponame}/${reponame}/build/COPY*"
chmod -R ug+rwX ${target}
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set tags
run: |
img_path="ghcr.io/${{ env.PACKAGE_NAME }}"
img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}"
img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-cpu"
if [[ -z '${{ matrix.build.tag }}' ]]; then
FOOOCUS_TAG="$(curl -s https://api.github.com/repos/lllyasviel/Fooocus/tags | jq -r '.[0].name')"
else
Expand All @@ -66,9 +75,9 @@ jobs:
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
TAGS="${img_path}:${base_tag}-${FOOOCUS_TAG}, ${img_path}:${base_tag}, ${img_path}:latest-cpu"
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_TAG}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-cpu"
else
TAGS="${img_path}:${base_tag}-${FOOOCUS_TAG}"
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_TAG}"
fi
echo "TAGS=${TAGS}" >> ${GITHUB_ENV}
-
Expand All @@ -93,7 +102,7 @@ jobs:
matrix:
build:
# Undeclared release tag finds latest from GitHub tags
- {latest: "true", tag: "v2.4.3", python: "3.10", pytorch: "2.3.0", cuda: "12.1.1-base"}
- {latest: "false", tag: "v2.5.5", python: "3.10", pytorch: "2.4.0", cuda: "12.1.1-base"}

steps:
-
Expand All @@ -110,7 +119,9 @@ jobs:
-
name: Env Setter
run: |
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
REPO=${GITHUB_REPOSITORY,,}
echo "REPO_NAMESPACE=${REPO%%/*}" >> ${GITHUB_ENV}
echo "REPO_NAME=${REPO#*/}" >> ${GITHUB_ENV}
-
name: Checkout
uses: actions/checkout@v3
Expand All @@ -120,17 +131,24 @@ jobs:
reponame="$(basename ${GITHUB_REPOSITORY})"
target="${HOME}/work/${reponame}/${reponame}/build/COPY*"
chmod -R ug+rwX ${target}
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set tags
run: |
img_path="ghcr.io/${{ env.PACKAGE_NAME }}"
img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}"
img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-cuda"
if [[ -z '${{ matrix.build.tag }}' ]]; then
FOOOCUS_TAG="$(curl -s https://api.github.com/repos/lllyasviel/Fooocus/tags | jq -r '.[0].name')"
Expand All @@ -144,9 +162,10 @@ jobs:
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
TAGS="${img_path}:${base_tag}-${FOOOCUS_TAG}, ${img_path}:${base_tag}, ${img_path}:latest, ${img_path}:latest-jupyter, ${img_path}:latest-cuda"
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_TAG}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest, ${img_path}:latest-cuda"
TAGS="${TAGS}, ${img_path_dhub}:${FOOOCUS_TAG}, ${img_path_dhub}:latest"
else
TAGS="${img_path}:${base_tag}-${FOOOCUS_TAG}"
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_TAG}, ${img_path_dhub}:${FOOOCUS_TAG}"
fi
echo "TAGS=${TAGS}" >> ${GITHUB_ENV}
-
Expand All @@ -169,7 +188,7 @@ jobs:
fail-fast: false
matrix:
build:
- {latest: "true", tag: "v2.4.3", python: "3.10", pytorch: "2.3.0", rocm: "6.0-core"}
- {latest: "false", tag: "v2.5.5", python: "3.10", pytorch: "2.3.0", rocm: "6.0-core"}
steps:
-
name: Free Space
Expand All @@ -185,7 +204,9 @@ jobs:
-
name: Env Setter
run: |
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
REPO=${GITHUB_REPOSITORY,,}
echo "REPO_NAMESPACE=${REPO%%/*}" >> ${GITHUB_ENV}
echo "REPO_NAME=${REPO#*/}" >> ${GITHUB_ENV}
-
name: Checkout
uses: actions/checkout@v3
Expand All @@ -195,17 +216,24 @@ jobs:
reponame="$(basename ${GITHUB_REPOSITORY})"
target="${HOME}/work/${reponame}/${reponame}/build/COPY*"
chmod -R ug+rwX ${target}
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set tags
run: |
img_path="ghcr.io/${{ env.PACKAGE_NAME }}"
img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}"
img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-rocm"
if [[ -z '${{ matrix.build.tag }}' ]]; then
FOOOCUS_TAG="$(curl -s https://api.github.com/repos/lllyasviel/Fooocus/tags | jq -r '.[0].name')"
Expand All @@ -219,9 +247,9 @@ jobs:
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
TAGS="${img_path}:${base_tag}-${FOOOCUS_TAG}, ${img_path}:${base_tag}, ${img_path}:latest-rocm"
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_TAG}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-rocm"
else
TAGS="${img_path}:${base_tag}-${FOOOCUS_TAG}"
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_TAG}"
fi
echo "TAGS=${TAGS}" >> ${GITHUB_ENV}
-
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Tags follow these patterns:

- `:latest-cpu` → `:v2-cpu-22.04`

Browse [here](https://github.com/ai-dock/fooocus/pkgs/container/fooocus) for an image suitable for your target environment.
Browse [ghcr.io](https://github.com/ai-dock/fooocus/pkgs/container/fooocus) for an image suitable for your target environment. You can also find [CUDA](https://hub.docker.com/r/aidockorg/fooocus-cuda) images at DockerHub.

Supported Python versions: `3.10`

Expand All @@ -47,7 +47,7 @@ Supported Platforms: `NVIDIA CUDA`, `AMD ROCm`, `CPU`
| -------------------------- | ----------- |
| `AUTO_UPDATE` | Update Fooocus on startup (default `false`) |
| `FOOOCUS_BRANCH` | Fooocus branch/commit hash for auto update. (default `master`) |
| `FOOOCUS_FLAGS` | Startup flags. eg. `--preset realistic` |
| `FOOOCUS_ARGS` | Startup arguments. eg. `--preset realistic` |
| `FOOOCUS_PORT_HOST` | Web UI port (default `7865`) |
| `FOOOCUS_URL` | Override `$DIRECT_ADDRESS:port` with URL for Web UI |

Expand All @@ -59,7 +59,13 @@ See the base environment variables [here](https://github.com/ai-dock/base-image/
| ---------------- | ----------------------------------------- |
| `fooocus` | Fooocus and dependencies |

This environment will be activated on shell login.
The `fooocus` environment will be activated on shell login.

If you have a storage volume mounted at `$WORKSPACE`, you may wish to persist your environment for future use after destroying the container. To do this you can run:

```
venv-sync fooocus && sudo supervisorctl restart fooocus
```

~~See the base micromamba environments [here](https://github.com/ai-dock/base-image/wiki/1.0-Included-Software#installed-micromamba-environments).~~

Expand All @@ -70,11 +76,11 @@ The following services will be launched alongside the [default services](https:/

### Fooocus

The service will launch on port `7865` unless you have specified an override with `FOOOCUS_PORT`.
The service will launch on port `7865` unless you have specified an override with `FOOOCUS_PORT_HOST`.

If variable `AUTO_UPDATE=true`, Fooocus will be updated to the latest version on container start. You can pin the version to a branch or commit hash by setting the `FOOOCUS_BRANCH` variable.

You can set startup flags by using variable `FOOOCUS_FLAGS`.
You can set startup flags by using variable `FOOOCUS_ARGS`.

To manage this service you can use `supervisorctl [start|stop|restart] fooocus`.

Expand All @@ -86,9 +92,9 @@ To manage this service you can use `supervisorctl [start|stop|restart] fooocus`.

**Vast.​ai**

- [A1111 WebUI:latest-cuda](https://link.ai-dock.org/template-vast-fooocus)
- [Fooocus:latest-cuda](https://link.ai-dock.org/template-vast-fooocus)

- [A1111 WebUI:latest-rocm](https://link.ai-dock.org/template-vast-fooocus-rocm)
- [Fooocus:latest-rocm](https://link.ai-dock.org/template-vast-fooocus-rocm)

---

Expand Down
6 changes: 3 additions & 3 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# For build automation - Allows building from any ai-dock base image
# Use a *cuda*base* image as default because pytorch brings the libs
ARG IMAGE_BASE="ghcr.io/ai-dock/python:3.10-cuda-12.1.1-base-22.04"
ARG IMAGE_BASE="ghcr.io/ai-dock/python:3.10-v2-cuda-12.1.1-base-22.04"
FROM ${IMAGE_BASE}

LABEL org.opencontainers.image.source https://github.com/ai-dock/fooocus
Expand All @@ -12,12 +12,12 @@ ENV FOOOCUS_VENV_PYTHON=$FOOOCUS_VENV/bin/python
ENV FOOOCUS_VENV_PIP=$FOOOCUS_VENV/bin/pip

ENV IMAGE_SLUG="fooocus"
ENV OPT_SYNC=fooocus
ENV OPT_SYNC=Fooocus

# Prepare environment
ARG PYTHON_VERSION="3.10"
ENV PYTHON_VERSION="${PYTHON_VERSION}"
ARG PYTORCH_VERSION="2.2.2"
ARG PYTORCH_VERSION="2.4.0"
ENV PYTORCH_VERSION="${PYTORCH_VERSION}"
COPY --chown=0:1111 ./COPY_ROOT_0/ /
ARG IMAGE_BASE
Expand Down
16 changes: 14 additions & 2 deletions config/provisioning/default.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
# This file will be sourced in init.sh
# This file will be run by init.sh
# Namespace functions with provisioning_

# https://github.com/ai-dock/fooocus/main/config/provisioning/default.sh

# Default for Fooocus is do nothing!

### Edit the following arrays to suit your workflow - values must be quoted and separated by newlines or spaces.

DISK_GB_REQUIRED=30
Expand Down Expand Up @@ -86,7 +88,17 @@ function provisioning_print_end() {

# Download from $1 URL to $2 file path
function provisioning_download() {
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
if [[ -n $HF_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then
auth_token="$HF_TOKEN"
elif
[[ -n $CIVITAI_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?civitai\.com(/|$|\?) ]]; then
auth_token="$CIVITAI_TOKEN"
fi
if [[ -n $auth_token ]];then
wget --header="Authorization: Bearer $auth_token" -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
else
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
fi
}

provisioning_start
9 changes: 5 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ services:
context: ./build
args:
PYTHON_VERSION: ${PYTHON_VERSION:-3.10}
PYTORCH_VERSION: ${PYTORCH_VERSION:-2.3.0}
PYTORCH_VERSION: ${PYTORCH_VERSION:-2.4.0}
FOOOCUS_TAG: ${FOOOCUS_TAG:-}
IMAGE_BASE: ${IMAGE_BASE:-ghcr.io/ai-dock/python:${PYTHON_VERSION:-3.10}-cuda-12.1.1-base-22.04}
IMAGE_BASE: ${IMAGE_BASE:-ghcr.io/ai-dock/python:${PYTHON_VERSION:-3.10}-v2-cuda-12.1.1-base-22.04}
tags:
- "ghcr.io/ai-dock/fooocus:${IMAGE_TAG:-cuda-12.1.1-base-22.04}"
- "ghcr.io/ai-dock/fooocus:${IMAGE_TAG:-v2-cuda-12.1.1-base-22.04}"

image: ghcr.io/ai-dock/fooocus:${IMAGE_TAG:-cuda-12.1.1-base-22.04}
image: ghcr.io/ai-dock/fooocus:${IMAGE_TAG:-v2-cuda-12.1.1-base-22.04}

devices:
- "/dev/dri:/dev/dri"
Expand Down Expand Up @@ -52,6 +52,7 @@ services:
- CF_TUNNEL_TOKEN=${CF_TUNNEL_TOKEN:-}
- CF_QUICK_TUNNELS=${CF_QUICK_TUNNELS:-true}
- WEB_ENABLE_AUTH=${WEB_ENABLE_AUTH:-true}
- WEB_ENABLE_HTTPS=${WEB_ENABLE_HTTPS:-false}
- WEB_USER=${WEB_USER:-user}
- WEB_PASSWORD=${WEB_PASSWORD:-password}
- SSH_PORT_HOST=${SSH_PORT_HOST:-2222}
Expand Down

0 comments on commit cda8333

Please sign in to comment.