Xqua commited on
Commit
f703876
1 Parent(s): f0d7ab4
Files changed (1) hide show
  1. Dockerfile +94 -0
Dockerfile ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM alpine/git:2.36.2 as download
2
+
3
+ COPY clone.sh /clone.sh
4
+
5
+
6
+ RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf \
7
+ && rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif
8
+
9
+ RUN . /clone.sh CodeFormer https://github.com/sczhou/CodeFormer.git c5b4593074ba6214284d6acd5f1719b6c5d739af \
10
+ && rm -rf assets inputs
11
+
12
+ RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 48211a1594f1321b00f14c9f7a5b4813144b2fb9
13
+ RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git ab527a9a6d347f364e3d185ba6d714e22d80cb3c
14
+ RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2cf03aaf6e704197fd0dae7c7f96aa59cf1b11c9
15
+ RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 45c443b316737a4ab6e40413d7794a7f5657c19f
16
+
17
+
18
+ FROM alpine:3.17 as xformers
19
+ RUN apk add --no-cache aria2
20
+ RUN aria2c -x 5 --dir / --out wheel.whl 'https://github.com/AbdBarho/stable-diffusion-webui-docker/releases/download/6.0.0/xformers-0.0.21.dev544-cp310-cp310-manylinux2014_x86_64-pytorch201.whl'
21
+
22
+
23
+ FROM python:3.10.9-slim
24
+
25
+ ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
26
+
27
+ RUN --mount=type=cache,target=/var/cache/apt \
28
+ apt-get update && \
29
+ # we need those
30
+ apt-get install -y fonts-dejavu-core rsync git jq moreutils aria2 \
31
+ # extensions needs those
32
+ ffmpeg libglfw3-dev libgles2-mesa-dev pkg-config libcairo2 libcairo2-dev build-essential
33
+
34
+
35
+ RUN --mount=type=cache,target=/cache --mount=type=cache,target=/root/.cache/pip \
36
+ aria2c -x 5 --dir /cache --out torch-2.0.1-cp310-cp310-linux_x86_64.whl -c \
37
+ https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-linux_x86_64.whl && \
38
+ pip install /cache/torch-2.0.1-cp310-cp310-linux_x86_64.whl torchvision --index-url https://download.pytorch.org/whl/cu118
39
+
40
+
41
+ RUN --mount=type=cache,target=/root/.cache/pip \
42
+ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \
43
+ cd stable-diffusion-webui && \
44
+ git reset --hard 5ef669de080814067961f28357256e8fe27544f4 && \
45
+ pip install -r requirements_versions.txt
46
+
47
+ RUN --mount=type=cache,target=/root/.cache/pip \
48
+ --mount=type=bind,from=xformers,source=/wheel.whl,target=/xformers-0.0.21.dev544-cp310-cp310-manylinux2014_x86_64.whl \
49
+ pip install /xformers-0.0.21.dev544-cp310-cp310-manylinux2014_x86_64.whl
50
+
51
+ ENV ROOT=/stable-diffusion-webui
52
+
53
+
54
+ COPY --from=download /repositories/ ${ROOT}/repositories/
55
+ RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/clip_interrogator/data/* ${ROOT}/interrogate
56
+ RUN --mount=type=cache,target=/root/.cache/pip \
57
+ pip install -r ${ROOT}/repositories/CodeFormer/requirements.txt
58
+
59
+ RUN --mount=type=cache,target=/root/.cache/pip \
60
+ pip install pyngrok \
61
+ git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 \
62
+ git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \
63
+ git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b
64
+
65
+
66
+ # Note: don't update the sha of previous versions because the install will take forever
67
+ # instead, update the repo state in a later step
68
+
69
+ # TODO: either remove if fixed in A1111 (unlikely) or move to the top with other apt stuff
70
+ RUN apt-get -y install libgoogle-perftools-dev && apt-get clean
71
+ ENV LD_PRELOAD=libtcmalloc.so
72
+
73
+ ARG SHA=5ef669de080814067961f28357256e8fe27544f4
74
+ RUN --mount=type=cache,target=/root/.cache/pip \
75
+ cd stable-diffusion-webui && \
76
+ git fetch && \
77
+ git reset --hard ${SHA} && \
78
+ pip install -r requirements_versions.txt
79
+
80
+ COPY . /docker
81
+
82
+ RUN \
83
+ python3 /docker/info.py ${ROOT}/modules/ui.py && \
84
+ mv ${ROOT}/style.css ${ROOT}/user.css && \
85
+ # one of the ugliest hacks I ever wrote \
86
+ sed -i 's/in_app_dir = .*/in_app_dir = True/g' /usr/local/lib/python3.10/site-packages/gradio/routes.py && \
87
+ git config --global --add safe.directory '*'
88
+
89
+ WORKDIR ${ROOT}
90
+ ENV NVIDIA_VISIBLE_DEVICES=all
91
+ ENV CLI_ARGS=""
92
+ EXPOSE 7860
93
+ ENTRYPOINT ["/docker/entrypoint.sh"]
94
+ CMD python -u webui.py --listen --port 7860 --no-half-vae --allow-code --xformers --enable-insecure-extension-access