-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
96 lines (78 loc) · 3.23 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=on \
SHELL=/bin/bash
RUN mkdir -p /sd-models
# Add SDXL models and VAE
# These need to already have been downloaded:
# wget https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/realisticVisionV51_v51VAE.safetensors
COPY realisticVisionV51_v51VAE.safetensors /sd-models/realisticVisionV51_v51VAE.safetensors
# Create and use the Python venv
RUN python3 -m venv /venv
# Clone the git repo of Stable Diffusion WebUI Forge and set version
ARG FORGE_COMMIT
RUN git clone https://github.com/lllyasviel/stable-diffusion-webui-forge.git && \
cd /stable-diffusion-webui-forge
# Install the dependencies for Stable Diffusion WebUI Forge
ARG INDEX_URL
ARG TORCH_VERSION
ARG XFORMERS_VERSION
WORKDIR /stable-diffusion-webui-forge
ENV TORCH_INDEX_URL=${INDEX_URL}
ENV TORCH_COMMAND="pip install torch==${TORCH_VERSION} torchvision --index-url ${TORCH_INDEX_URL}"
ENV XFORMERS_PACKAGE="xformers==${XFORMERS_VERSION} --index-url ${TORCH_INDEX_URL}"
RUN source /venv/bin/activate && \
${TORCH_COMMAND} && \
pip3 install -r requirements_versions.txt && \
pip3 install ${XFORMERS_PACKAGE} && \
deactivate
# Install the dependencies for the built-in extensions
RUN source /venv/bin/activate && \
pip3 install -r extensions-builtin/sd_forge_controlnet/requirements.txt && \
pip3 install -r extensions-builtin/forge_legacy_preprocessors/requirements.txt && \
pip3 install insightface && \
pip3 uninstall -y onnxruntime && \
pip3 install onnxruntime-gpu && \
pip3 install protobuf==3.20.0 && \
deactivate
COPY forge/cache-sd-model.py ./
RUN source /venv/bin/activate && \
python3 -c "from launch import prepare_environment; prepare_environment()" --skip-torch-cuda-test && \
deactivate
# Cache the Stable Diffusion Models
# SDXL models result in OOM kills with 8GB system memory, need 30GB+ to cache these
#RUN source /venv/bin/activate && \
# python3 cache-sd-model.py --no-half-vae --no-half --xformers --use-cpu=all --ckpt /sd-models/realisticVisionV51_v51VAE.safetensors && \
# deactivate
# Copy Stable Diffusion WebUI Forge config files
COPY forge/relauncher.py forge/webui-user.sh forge/config.json forge/ui-config.json /stable-diffusion-webui-forge/
# ADD SDXL styles.csv
ADD https://raw.githubusercontent.com/Douleb/SDXL-750-Styles-GPT4-/main/styles.csv /stable-diffusion-webui/styles.csv
# Install CivitAI Model Downloader
ARG CIVITAI_DOWNLOADER_VERSION
RUN git clone https://github.com/ashleykleynhans/civitai-downloader.git && \
cd civitai-downloader && \
git checkout tags/${CIVITAI_DOWNLOADER_VERSION} && \
cp download.py /usr/local/bin/download-model && \
chmod +x /usr/local/bin/download-model && \
cd .. && \
rm -rf civitai-downloader
# Remove existing SSH host keys
RUN rm -f /etc/ssh/ssh_host_*
# NGINX Proxy
COPY nginx/nginx.conf /etc/nginx/nginx.conf
# Set template version
ARG RELEASE
ENV TEMPLATE_VERSION=${RELEASE}
# Set the venv path
ARG VENV_PATH
ENV VENV_PATH=${VENV_PATH}
# Copy the scripts
WORKDIR /
COPY --chmod=755 scripts/* ./
# Start the container
SHELL ["/bin/bash", "--login", "-c"]
CMD [ "/start.sh" ]