├── .dockerignore ├── .gitignore ├── Dockerfile ├── Readme.md ├── docker-compose.yml └── run.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | data/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | data/ -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04 2 | LABEL org.opencontainers.image.source https://github.com/Yummiii/sd-webui-forge-docker 3 | WORKDIR /app 4 | RUN apt update && apt upgrade -y 5 | RUN apt install -y wget git python3 python3-venv libgl1 libglib2.0-0 apt-transport-https libgoogle-perftools-dev bc python3-pip 6 | COPY run.sh /app/run.sh 7 | RUN chmod +x /app/run.sh 8 | 9 | RUN useradd -m webui 10 | RUN chown -R webui:webui /app 11 | USER webui 12 | RUN mkdir /app/sd-webui 13 | 14 | ENTRYPOINT ["/app/run.sh"] 15 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | A docker image for [Stable Diffusion WebUI Forge](https://github.com/lllyasviel/stable-diffusion-webui-forge) or the AUTO1111 WebUI 2 | 3 | > [!WARNING] 4 | > This Dockerfile is based on on Cuda 12.4, which requires Nvidia driver >=545. 5 | > In [Ubuntu 22.04](https://github.com/Yummiii/sd-webui-forge-docker/issues/1#issuecomment-2066840527) you can update it by running `ubuntu-drivers install nvidia:545` and a reboot. (Thanks [@casao](https://github.com/Casao)) 6 | 7 | # Docker compose 8 | To run it, you will need the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) 9 | 10 | Create a directory. Inside this directory, create a subdirectory named `data` (if you don't and let docker create it, there might be permission issues) and a file named `docker-compose.yml`. Add the following content to the 'docker-compose.yml' file: 11 | 12 | ```YML 13 | services: 14 | webui: 15 | image: "ghcr.io/yummiii/sd-webui-forge-docker:cuda-12.4.1" 16 | volumes: 17 | - "./data:/app/sd-webui" 18 | ports: 19 | - "7860:7860" 20 | environment: 21 | - "ARGS=--listen --enable-insecure-extension-access" # Insecure extension access is required if you want to install extensions with the listen flag 22 | - "UI=forge" # Specifies the UI that will be downloaded, forge for the forge webui or auto for the AUTOMATIC1111 webui 23 | deploy: 24 | resources: 25 | reservations: 26 | devices: 27 | - driver: nvidia 28 | count: 1 29 | capabilities: [gpu] 30 | ``` 31 | then run it with `docker compose up`. 32 | 33 | You can set which arguments the webui will recive with the `ARGS` environment variable 34 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webui: 3 | image: "ghcr.io/yummiii/sd-webui-forge-docker:latest" 4 | # build: . 5 | volumes: 6 | - "./data:/app/sd-webui" 7 | ports: 8 | - "7860:7860" 9 | environment: 10 | - "ARGS=--listen --enable-insecure-extension-acces" 11 | - "UI=auto" 12 | deploy: 13 | resources: 14 | reservations: 15 | devices: 16 | - driver: nvidia 17 | count: 1 18 | capabilities: [gpu] 19 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Starting Stable Diffusion WebUI" 3 | if [ ! -d "/app/sd-webui" ] || [ ! "$(ls -A "/app/sd-webui")" ]; then 4 | echo "Files not found, cloning..." 5 | 6 | if [ "$UI" = "auto" ]; then 7 | echo "Using AUTOMATIC1111" 8 | git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git /app/sd-webui 9 | cd /app/sd-webui 10 | git checkout dev 11 | fi 12 | 13 | if [ "$UI" = "forge" ]; then 14 | echo "Using Forge" 15 | git clone https://github.com/lllyasviel/stable-diffusion-webui-forge.git /app/sd-webui 16 | cd /app/sd-webui 17 | fi 18 | 19 | chmod +x /app/sd-webui/webui.sh 20 | 21 | #i don't really know if this is the best way to do this 22 | python3 -m venv venv 23 | source ./venv/bin/activate 24 | pip install insightface 25 | deactivate 26 | 27 | exec /app/sd-webui/webui.sh $ARGS 28 | else 29 | echo "Files found, starting..." 30 | cd /app/sd-webui 31 | git pull 32 | exec /app/sd-webui/webui.sh $ARGS 33 | fi 34 | --------------------------------------------------------------------------------