File size: 10,216 Bytes
17a16a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b856fd
17a16a3
 
aba19e6
 
17a16a3
 
 
 
 
aba19e6
 
 
 
 
 
 
17a16a3
 
 
 
 
 
 
 
 
 
aba19e6
 
17a16a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aba19e6
 
17a16a3
aba19e6
17a16a3
aba19e6
17a16a3
 
 
aba19e6
 
 
17a16a3
 
 
aba19e6
17a16a3
e66157a
 
 
 
248df97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17a16a3
 
007c1f5
17a16a3
 
 
 
aba19e6
cd31a8c
9b6f6dd
17a16a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04

ENV DEBIAN_FRONTEND noninteractive
ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_NO_CACHE_DIR=1

# OS setup
RUN apt-get update -y \
    && apt-get upgrade -y \
    && apt-get install -y \
        libgl1 \
        libglib2.0-0 \
        curl \
        vim \
        wget \
        git \
        git-lfs \
        tzdata \
        bash \
        ca-certificates \
        libreadline8 \
        bzip2 \
        psmisc \
        procps \
        netbase \
        openssh-client \
        libsqlite3-dev \
        python3-pip \
        python3-venv \
        python-is-python3 \
        build-essential \
        libssl-dev \
        libffi-dev \
        aria2 \
    \
    && pip3 install --upgrade pip \
    \
    && git lfs install \
    \
    && apt-get clean autoclean \
    && apt-get autoremove --yes \
    && rm -rf /var/lib/apt/lists/*

# OS timezone setting (UTC)
RUN echo "UTC" > /etc/timezone
ENV TZ=UTC

# Poetry for Python packages
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local/poetry python3 - --yes \
    && ln -s /usr/local/poetry/bin/poetry /usr/bin/poetry \
    \
    && poetry config virtualenvs.create false \
    && poetry config virtualenvs.in-project false

# Create non-root user
ENV ENV="/etc/profile"
RUN adduser --disabled-password --gecos '' user && \
    mkdir -p /app && \
    chown -R user:user /app && \
    printf "\n. /etc/profile\n" >> /home/user/.profile \
    printf "\n. /etc/profile\n" >> /home/user/.bashrc

# Sets up virtualenv for dependencies
ENV VIRTUAL_ENV="/opt/venv"
ENV VIRTUAL_ENV_DISABLE_PROMPT=1
ENV POETRY_ACTIVE=1
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN echo "export PATH=$PATH" >> /home/user/.bashrc \
    && python3 -m venv $VIRTUAL_ENV \
    && /opt/venv/bin/pip install --upgrade --no-cache-dir pip \
    && chown -R user:user /opt/venv

# Run as non-root user
USER user
WORKDIR /app

# Installation of basic Python dependencies specified in pyproject.toml
COPY --chown=user:user pyproject.toml poetry.lock /app/
RUN poetry install

# AUTOMATIC1111' WebUI
RUN git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui /app/stable-diffusion-webui \
    && (cd /app/stable-diffusion-webui && git checkout 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8)

# Deforum extension
#RUN git clone https://github.com/deforum-art/deforum-for-automatic1111-webui /app/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui \
#    && (cd /app/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui && git checkout b60d999202f0fd2b386150d0938c43e639db8643)

# Images Browser WebUI extension
RUN git clone https://github.com/yfszzx/stable-diffusion-webui-images-browser /app/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser \
    && (cd /app/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser && git checkout a42c7a30181636a05815e62426d5eff4d3340529)

# Locon extension (Obsolete - Use Lycrois)
#RUN git clone https://github.com/KohakuBlueleaf/a1111-sd-webui-locon /app/stable-diffusion-webui/extensions/a1111-sd-webui-locon \
#    && (cd /app/stable-diffusion-webui/extensions/a1111-sd-webui-locon && git checkout afe70b0f77f2d1cc691f297074cc049913711662)

# Lycoris extension
RUN git clone https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris /app/stable-diffusion-webui/extensions/a1111-sd-webui-lycoris \
    && (cd /app/stable-diffusion-webui/extensions/a1111-sd-webui-lycoris && git checkout b0d24ca645b6a5cb9752169691a1c6385c6fe6ae)

# Local Latent Upscaler extension
RUN git clone https://github.com/hnmr293/sd-webui-llul /app/stable-diffusion-webui/extensions/sd-webui-llul \
    && (cd /app/stable-diffusion-webui/extensions/sd-webui-llul && git checkout b20337ae1091ea65fdaf7108a2eaac13fed078d5)

# Aspect Ratios extension
RUN git clone https://github.com/alemelis/sd-webui-ar /app/stable-diffusion-webui/extensions/sd-webui-ar \
    && (cd /app/stable-diffusion-webui/extensions/sd-webui-ar && git checkout ce0a645ca2ad949573cacc7f5cd14ac13e83e2c9)

# Stable Hoarde extension
RUN git clone https://github.com/natanjunges/stable-diffusion-webui-stable-horde /app/stable-diffusion-webui/extensions/stable-diffusion-webui-stable-horde \
    && (cd /app/stable-diffusion-webui/extensions/stable-diffusion-webui-stable-horde && git checkout 00248b89bfab7ba465f104324a5d0708ad37341f)

# Smart Process extension
#RUN git clone https://github.com/d8ahazard/sd_smartprocess /app/stable-diffusion-webui/extensions/sd_smartprocess \
#    && (cd /app/stable-diffusion-webui/extensions/sd_smartprocess && git checkout 41fb35ef712e01829f1d1ab53a78f6ec45cba1df)


# Panorama extension
RUN git clone https://github.com/GeorgLegato/sd-webui-panorama-viewer /app/stable-diffusion-webui/extensions/sd-webui-panorama-viewer \
    && (cd /app/stable-diffusion-webui/extensions/sd-webui-panorama-viewer && git checkout 6879f2e00f4e21abffe66cd2f35e1a50efc4aba8)

# Style Pile extension
RUN git clone https://github.com/some9000/StylePile /app/stable-diffusion-webui/extensions/StylePile \
    && (cd /app/stable-diffusion-webui/extensions/StylePile && git checkout 206b3d06bebb75df1a4b5439e35c432668ea7574)

# Anti Burn extension
RUN git clone https://github.com/klimaleksus/stable-diffusion-webui-anti-burn /app/stable-diffusion-webui/extensions/stable-diffusion-webui-anti-burn \
    && (cd /app/stable-diffusion-webui/extensions/stable-diffusion-webui-anti-burn && git checkout 4d678f1f1120415fe4cb9f77484252bc82af03b2)

# Super Merger extension
#RUN git clone https://github.com/hako-mikan/sd-webui-supermerger /app/stable-diffusion-webui/extensions/sd-webui-supermerger \
#    && (cd /app/stable-diffusion-webui/extensions/sd-webui-supermerger && git checkout ba775c8941b51f59785834db54ec947be3213626)

# Cutoff Extension
RUN git clone https://github.com/hnmr293/sd-webui-cutoff /app/stable-diffusion-webui/extensions/sd-webui-cutoff \
    && (cd /app/stable-diffusion-webui/extensions/sd-webui-cutoff && git checkout 3a073e9c4525c21b72ae4645125768457c9c98e1)

# Dynamic Prompts extension
RUN git clone https://github.com/adieyal/sd-dynamic-prompts /app/stable-diffusion-webui/extensions/sd-dynamic-prompts \
    && (cd /app/stable-diffusion-webui/extensions/sd-dynamic-prompts && git checkout d34bdc17c5582569d16732b5176a215108d2fd86)

COPY wildcards/ /app/stable-diffusion-webui/sd-dynamic-prompts/wildcards/

# CiviTAI BETTER Browser WebUI extension
RUN git clone https://github.com/butaixianran/Stable-Diffusion-Webui-Civitai-Helper /app/stable-diffusion-webui/extensions/Stable-Diffusion-Webui-Civitai-Helper \
    && (cd /app/stable-diffusion-webui/extensions/Stable-Diffusion-Webui-Civitai-Helper && git checkout 920ca3267f789a72e3225c99f069bf0be0db795d)

# CiviTAI WebUI extension
RUN git clone https://github.com/civitai/sd_civitai_extension /app/stable-diffusion-webui/extensions/sd_civitai_extension \
    && (cd /app/stable-diffusion-webui/extensions/sd_civitai_extension && git checkout 7ab4e9f384221500e1873405b12ae965d241e048)

# Booru Tag Autocomplete extension
RUN git clone https://github.com/DominikDoom/a1111-sd-webui-tagcomplete /app/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete \
    && (cd /app/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete && git checkout 1cb4fc8f2572545418fe988edd8815a20e6b0e28)

# Batchlinks Downloader extension
RUN git clone https://github.com/etherealxx/batchlinks-webui /app/stable-diffusion-webui/extensions/batchlinks-webui \
    && (cd /app/stable-diffusion-webui/extensions/batchlinks-webui && git checkout d44bbb5e2a043f2eed80c3945c0f2c676e41d0e5)

# Fast PNG Info extension
RUN git clone https://github.com/NoCrypt/sd-fast-pnginfo /app/stable-diffusion-webui/extensions/sd-fast-pnginfo \
    && (cd /app/stable-diffusion-webui/extensions/sd-fast-pnginfo && git checkout b6647cd57fd5930f4355dee253833a459d2b39fe)

# Filer extension
RUN git clone https://github.com/aka7774/sd_filer /app/stable-diffusion-webui/extensions/sd_filer \
    && (cd /app/stable-diffusion-webui/extensions/sd_filer && git checkout ff7d76930ced048a4e5e73ca964551d679463da7)

# Additional Networks WebUI extension
RUN git clone https://github.com/kohya-ss/sd-webui-additional-networks /app/stable-diffusion-webui/extensions/sd-webui-additional-networks \
    && (cd /app/stable-diffusion-webui/extensions/sd-webui-additional-networks && git checkout 86300421b0ff35ab9d670874e836b7f65b806430) \
    && mkdir -p /app/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/LoRA

# ControlNet WebUI extension
RUN git clone https://github.com/Mikubill/sd-webui-controlnet /app/stable-diffusion-webui/extensions/sd-webui-controlnet \
    && (cd /app/stable-diffusion-webui/extensions/sd-webui-controlnet && git checkout e78d486ce0e5cb9adc52549370d71e0433bf2111) \
    && mkdir -p /app/stable-diffusion-webui/models/ControlNet


# Prepare WebUI environment
WORKDIR /app/stable-diffusion-webui
RUN /opt/venv/bin/python launch.py --exit --skip-torch-cuda-test --xformers

# Patch WebUI
RUN sed -i -e 's/                show_progress=False,/                show_progress=True,/g' modules/ui.py
RUN sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' webui.py
RUN sed -i -e 's/ outputs=\[/queue=False, &/g' modules/ui.py
RUN sed -i -e 's/               queue=False,  /                /g' modules/ui.py

# Copy startup scripts
COPY --chown=user:user run.py on_start.sh config.json ui-config.json shared-config.json shared-ui-config.json header_patch.py /app/stable-diffusion-webui/
COPY embeddings/ /app/stable-diffusion-webui/embeddings/
COPY styles.csv /app/stable-diffusion-webui/
RUN chmod +x on_start.sh

EXPOSE 7860

CMD ["/opt/venv/bin/python", "run.py", "--listen", "--enable-insecure-extension-access", "--ui-config-file", "ui-config.json", "--ui-settings-file", "config.json", "--disable-console-progressbars", "--cors-allow-origins", "huggingface.co,hf.space", "--no-progressbar-hiding", "--enable-console-prompts", "--no-download-sd-model", "--api", "--skip-version-check", "--lora-dir", "/app/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/LoRA", "--embeddings-dir", "/app/stable-diffusion-webui/embeddings"]