mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-07-21 21:01:24 +08:00
Docker
This commit is contained in:
parent
4d3f4c90a0
commit
6b3673affe
@ -339,6 +339,9 @@ The name "Forge" is inspired by "Minecraft Forge". This project aims to become t
|
||||
> [!Tip]
|
||||
> For **Linux** and **macOS**, refer to [Wiki](https://github.com/Haoming02/sd-webui-forge-classic/wiki/Unix)
|
||||
|
||||
> [!Tip]
|
||||
> For **Docker** (`Nvidia`), refer to [Docker](docker/)
|
||||
|
||||
<br>
|
||||
|
||||
> [!Tip]
|
||||
|
||||
6
docker/.dockerignore
Normal file
6
docker/.dockerignore
Normal file
@ -0,0 +1,6 @@
|
||||
__pycache__
|
||||
.DS_Store
|
||||
data
|
||||
*.log
|
||||
*.pyc
|
||||
*.pyo
|
||||
77
docker/Dockerfile
Normal file
77
docker/Dockerfile
Normal file
@ -0,0 +1,77 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Forge Neo | NVIDIA GPU
|
||||
|
||||
ARG CUDA_VERSION=12.6.3
|
||||
|
||||
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu22.04
|
||||
|
||||
# See: https://download.pytorch.org/whl/
|
||||
ARG TORCH_INDEX=cu126
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
UV_PYTHON_DOWNLOADS=automatic \
|
||||
UV_NO_CACHE=1 \
|
||||
TORCH_INDEX_URL=https://download.pytorch.org/whl/${TORCH_INDEX}
|
||||
|
||||
# uv binary
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
|
||||
|
||||
# Dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
curl \
|
||||
ffmpeg \
|
||||
git \
|
||||
libgl1 \
|
||||
libglib2.0-0 \
|
||||
libgomp1 \
|
||||
libtcmalloc-minimal4 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Non-Root User (UID 99 / GID 100 = nobody:users)
|
||||
RUN groupadd -g 100 users 2>/dev/null || true \
|
||||
&& useradd -u 99 -g 100 -d /home/forge -m -s /bin/bash forge
|
||||
|
||||
WORKDIR /home/forge/sd-webui
|
||||
|
||||
# Clone at build time
|
||||
RUN git clone --branch neo --depth 1 --filter blob:none \
|
||||
https://github.com/Haoming02/sd-webui-forge-classic.git . \
|
||||
&& chown -R 99:100 /home/forge
|
||||
|
||||
USER forge
|
||||
|
||||
# Python 3.13 Virtual ENVironment
|
||||
RUN uv venv venv --python 3.13 --seed
|
||||
|
||||
ENV VIRTUAL_ENV="/home/forge/sd-webui/venv" \
|
||||
PATH="/home/forge/sd-webui/venv/bin:$PATH" \
|
||||
PYTHON="/home/forge/sd-webui/venv/bin/python3.13"
|
||||
|
||||
# PyTorch Pre-Install
|
||||
RUN uv pip install torch torchvision \
|
||||
--index-url "https://download.pytorch.org/whl/${TORCH_INDEX}"
|
||||
|
||||
# Persistent Data Directories
|
||||
RUN mkdir -p \
|
||||
models/Stable-diffusion \
|
||||
models/VAE \
|
||||
models/Lora \
|
||||
models/ControlNet \
|
||||
extensions \
|
||||
config \
|
||||
output
|
||||
|
||||
# Runtime
|
||||
COPY --chown=99:100 entrypoint.sh /home/forge/sd-webui/entrypoint.sh
|
||||
RUN chmod +x /home/forge/sd-webui/entrypoint.sh
|
||||
|
||||
EXPOSE 7860
|
||||
|
||||
# extra time for prepare_environment() to run on first start
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=300s --retries=15 \
|
||||
CMD curl -f http://localhost:7860/ || exit 1
|
||||
|
||||
ENTRYPOINT ["/home/forge/sd-webui/entrypoint.sh"]
|
||||
92
docker/README.md
Normal file
92
docker/README.md
Normal file
@ -0,0 +1,92 @@
|
||||
<h2 align="center">Stable Diffusion WebUI Forge - Neo (Docker)</h2>
|
||||
|
||||
> [!Warning]
|
||||
> Requires an **NVIDIA** GPU<br>
|
||||
> Ensure driver is up to date (`560+` required)
|
||||
|
||||
<hr>
|
||||
|
||||
## Unraid Deployment
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Container Path</th>
|
||||
<th>Purpose</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>/home/forge/sd-webui/models</code>
|
||||
</td>
|
||||
<td>Checkpoint, Text Encoder, VAE, LoRA, ControlNet</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>/home/forge/sd-webui/output</code>
|
||||
</td>
|
||||
<td>Generated Images</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>/home/forge/sd-webui/extensions</code>
|
||||
</td>
|
||||
<td>User-Installed Extensions</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>/home/forge/sd-webui/config</code>
|
||||
</td>
|
||||
<td>User Settings</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
- The container runs as **UID 99** / **GID 100** (`nobody:users`) to match Unraid's default share permissions
|
||||
|
||||
<hr>
|
||||
|
||||
## Building Locally
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Haoming02/sd-webui-forge-classic sd-webui-forge-neo --branch neo
|
||||
cd sd-webui-forge-neo/docker
|
||||
docker build -t forge-neo-local .
|
||||
```
|
||||
|
||||
<hr>
|
||||
|
||||
## Pre-Built Image
|
||||
|
||||
> a non-official pre-built image is maintained on Docker Hub by [@oromis995](https://github.com/oromis995):
|
||||
|
||||
```bash
|
||||
docker pull oromis995/sd-forge-neo:latest
|
||||
```
|
||||
|
||||
<hr>
|
||||
|
||||
## Image Details
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Base</td>
|
||||
<td><code>nvidia/cuda:12.6.3-runtime-ubuntu22.04</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Python</td>
|
||||
<td><code>3.13</code> via <b>uv</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PyTorch</td>
|
||||
<td>Latest (<code>cu126</code>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>User</td>
|
||||
<td><code>forge</code> (UID 99 / GID 100)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Port</td>
|
||||
<td>7860</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
> [!Note]
|
||||
> On the first run, `prepare_environment()` will install requirements and dependencies. This may take a few minutes
|
||||
24
docker/entrypoint.sh
Normal file
24
docker/entrypoint.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# TCMalloc reduces memory fragmentation under large model workloads
|
||||
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4
|
||||
|
||||
# Read COMMANDLINE_ARGS then unset it
|
||||
RAW_ARGS="${COMMANDLINE_ARGS:-}"
|
||||
unset COMMANDLINE_ARGS
|
||||
|
||||
EXTRA_ARGS=()
|
||||
if [[ -n "$RAW_ARGS" ]]; then
|
||||
read -ra EXTRA_ARGS <<< "$RAW_ARGS"
|
||||
fi
|
||||
|
||||
# Symlink settings files into the config bind-mount so they persist across container recreations
|
||||
for f in config.json ui-config.json styles.csv user.css; do
|
||||
ln -sf /home/forge/sd-webui/config/$f /home/forge/sd-webui/$f
|
||||
done
|
||||
|
||||
exec python /home/forge/sd-webui/launch.py \
|
||||
--listen \
|
||||
"${EXTRA_ARGS[@]}" \
|
||||
"$@"
|
||||
Loading…
Reference in New Issue
Block a user