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 b6af0a3809ea869fb180633f9affcae4b199ffcf) # 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) # 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 e9f3d622b5a98650008a685ea23b27eb810da35a) \ && 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"]