Dockerfile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # syntax=docker/dockerfile:1
  2. FROM alpine/git:2.36.2 as download
  3. RUN git clone https://github.com/CompVis/stable-diffusion.git repositories/stable-diffusion && cd repositories/stable-diffusion && git reset --hard 69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc
  4. RUN git clone https://github.com/sczhou/CodeFormer.git repositories/CodeFormer && cd repositories/CodeFormer && git reset --hard c5b4593074ba6214284d6acd5f1719b6c5d739af
  5. RUN git clone https://github.com/salesforce/BLIP.git repositories/BLIP && cd repositories/BLIP && git reset --hard 48211a1594f1321b00f14c9f7a5b4813144b2fb9
  6. # RUN git clone https://github.com/Hafiidz/latent-diffusion.git repositories/latent-diffusion && cd repositories/latent-diffusion && git reset --hard abf33e7002d59d9085081bce93ec798dcabd49af
  7. RUN <<EOF
  8. # because taming-transformers is huge
  9. git config --global http.postBuffer 1048576000
  10. git clone https://github.com/CompVis/taming-transformers.git repositories/taming-transformers
  11. cd repositories/taming-transformers
  12. git reset --hard 24268930bf1dce879235a7fddd0b2355b84d7ea6
  13. rm -rf data assets
  14. EOF
  15. RUN git clone https://github.com/crowsonkb/k-diffusion.git repositories/k-diffusion && cd repositories/k-diffusion && git reset --hard f4e99857772fc3a126ba886aadf795a332774878
  16. FROM python:3.10-slim
  17. SHELL ["/bin/bash", "-ceuxo", "pipefail"]
  18. ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 PIP_NO_CACHE_DIR=1
  19. RUN pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
  20. RUN apt-get update && apt install fonts-dejavu-core rsync git -y && apt-get clean
  21. RUN <<EOF
  22. git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
  23. cd stable-diffusion-webui
  24. git reset --hard 1eb588cbf19924333b88beaa1ac0041904966640
  25. pip install -r requirements_versions.txt
  26. EOF
  27. ENV ROOT=/stable-diffusion-webui \
  28. WORKDIR=/stable-diffusion-webui/repositories/stable-diffusion
  29. COPY --from=download /git/ ${ROOT}
  30. RUN pip install --prefer-binary --no-cache-dir -r ${ROOT}/repositories/CodeFormer/requirements.txt
  31. # Note: don't update the sha of previous versions because the install will take forever
  32. # instead, update the repo state in a later step
  33. ARG SHA=6a9ea5b41cf92cd9e980349bb5034439f4e7a58b
  34. RUN <<EOF
  35. cd stable-diffusion-webui
  36. git pull --rebase
  37. git reset --hard ${SHA}
  38. pip install --prefer-binary --no-cache-dir -r requirements_versions.txt
  39. EOF
  40. RUN pip install --prefer-binary --no-cache-dir opencv-python-headless \
  41. git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 \
  42. git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \
  43. pyngrok
  44. #xformers
  45. COPY . /docker
  46. RUN <<EOF
  47. chmod +x /docker/mount.sh && python3 /docker/info.py ${ROOT}/modules/ui.py
  48. EOF
  49. ENV CLI_ARGS=""
  50. WORKDIR ${WORKDIR}
  51. EXPOSE 7860
  52. # run, -u to not buffer stdout / stderr
  53. CMD /docker/mount.sh && \
  54. python3 -u ../../webui.py --listen --port 7860 --hide-ui-dir-config --ckpt-dir ${ROOT}/models/Stable-diffusion ${CLI_ARGS}