Dockerfile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # syntax=docker/dockerfile:1
  2. FROM python:3.10-slim
  3. SHELL ["/bin/bash", "-ceuxo", "pipefail"]
  4. ENV DEBIAN_FRONTEND=noninteractive PIP_EXISTS_ACTION=w PIP_PREFER_BINARY=1 PIP_NO_CACHE_DIR=1
  5. RUN pip install torch==1.12.0+cu116 --extra-index-url https://download.pytorch.org/whl/cu116
  6. RUN apt-get update && apt-get install git -y && apt-get clean
  7. RUN git clone https://github.com/invoke-ai/InvokeAI.git /stable-diffusion
  8. WORKDIR /stable-diffusion
  9. RUN <<EOF
  10. git reset --hard 5c31feb3a1096d437c94b6e1c3224eb7a7224a85
  11. git config --global http.postBuffer 1048576000
  12. pip install -r binary_installer/py3.10-linux-x86_64-cuda-reqs.txt
  13. EOF
  14. # patch match:
  15. # https://github.com/invoke-ai/InvokeAI/blob/main/docs/installation/INSTALL_PATCHMATCH.md
  16. RUN <<EOF
  17. apt-get update
  18. # apt-get install build-essential python3-opencv libopencv-dev -y
  19. apt-get install make g++ libopencv-dev -y
  20. apt-get clean
  21. cd /usr/lib/x86_64-linux-gnu/pkgconfig/
  22. ln -sf opencv4.pc opencv.pc
  23. EOF
  24. ARG BRANCH=main SHA=38cd968130e386d188bdef68f9fbfbbbfabb2da0
  25. RUN <<EOF
  26. git fetch
  27. git reset --hard
  28. git checkout ${BRANCH}
  29. git reset --hard ${SHA}
  30. pip install -r binary_installer/py3.10-linux-x86_64-cuda-reqs.txt
  31. EOF
  32. RUN pip install --force-reinstall opencv-python-headless && python3 -c "from patchmatch import patch_match"
  33. COPY . /docker/
  34. RUN <<EOF
  35. python3 /docker/info.py /stable-diffusion/frontend/dist/index.html
  36. touch ~/.invokeai
  37. EOF
  38. ENV ROOT=/stable-diffusion PYTHONPATH="${PYTHONPATH}:${ROOT}" PRELOAD=false CLI_ARGS=""
  39. EXPOSE 7860
  40. ENTRYPOINT ["/docker/entrypoint.sh"]
  41. CMD python3 -u scripts/invoke.py --web --host 0.0.0.0 --port 7860 --config /docker/models.yaml --root_dir ${ROOT} --outdir /output/invoke ${CLI_ARGS}