[
  {
    "path": ".devscripts/chmod.sh",
    "content": "#!/bin/bash\n\nset -Eeuo pipefail\n\nfind services -name \"*.sh\" -exec git update-index --chmod=+x {} \\;\nfind .devscripts -name \"*.sh\" -exec git update-index --chmod=+x {} \\;\n"
  },
  {
    "path": ".devscripts/migratev1tov2.sh",
    "content": "mkdir -p data/.cache data/StableDiffusion data/Codeformer data/GFPGAN data/ESRGAN data/BSRGAN data/RealESRGAN data/SwinIR data/LDSR data/embeddings\n\ncp -vf cache/models/model.ckpt data/StableDiffusion/model.ckpt\n\ncp -vf cache/models/LDSR.ckpt data/LDSR/model.ckpt\ncp -vf cache/models/LDSR.yaml data/LDSR/project.yaml\n\ncp -vf cache/models/RealESRGAN_x4plus.pth data/RealESRGAN/\ncp -vf cache/models/RealESRGAN_x4plus_anime_6B.pth data/RealESRGAN/\n\ncp -vrf cache/torch data/.cache/\n\nmkdir -p data/.cache/huggingface/transformers/\ncp -vrf cache/transformers/* data/.cache/huggingface/transformers/\n\ncp -v cache/custom-models/* data/StableDiffusion/\n\nmkdir -p data/.cache/clip/\ncp -vf cache/weights/ViT-L-14.pt data/.cache/clip/\n\ncp -vf cache/weights/codeformer.pth data/Codeformer/codeformer-v0.1.0.pth\n\ncp -vf cache/weights/detection_Resnet50_Final.pth data/.cache/\ncp -vf cache/weights/parsing_parsenet.pth data/.cache/\n\ncp -v embeddings/* data/embeddings/\n\necho this script was created 10/2022\necho Dont forget to run: docker compose --profile download up --build\necho the cache and embeddings folders can be deleted, but its not necessary.\n"
  },
  {
    "path": ".devscripts/migratev3tov4.sh",
    "content": "#!/bin/bash\n\nset -Eeuo pipefail\n\necho \"Moving everything in output to output/old...\"\nmv output old\nmkdir output\nmv old/.gitignore output\nmv old output\n"
  },
  {
    "path": ".devscripts/migratev7tov8.sh",
    "content": "#!/bin/bash\n\nset -Eeuo pipefail\n\necho \"Renaming...\"\n\n# compatible with default auto-names\nmv -v ./data/StableDiffusion ./data/Stable-diffusion\nmv -v ./data/Deepdanbooru ./data/torch_deepdanbooru\n\n# casing problem on windows\nmv -v ./data/Hypernetworks ./data/hypernetworks1\nmv -v ./data/hypernetworks1 ./data/hypernetworks\n\nmv -v ./data/MiDaS ./data/midas1\nmv -v ./data/midas1 ./data/midas\n\n\necho \"Moving folders...\"\n\nmkdir -pv ./final\n\nmv -v ./data/config ./final/config\nmv -v ./data/.cache ./final/.cache\nmv -v ./data/embeddings ./final/embeddings\nmv -v ./data ./final/models\n\nmv -v ./final ./data\n"
  },
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nend_of_line = lf\nindent_style = space\nindent_size = 2\ncharset = utf-8\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug.md",
    "content": "---\nname: Bug\nabout: Report a bug\ntitle: \"\"\nlabels: bug\nassignees: \"\"\n---\n\n<!--  PLEASE FILL THIS OUT, IT WILL MAKE BOTH OF OUR LIVES EASIER -->\n\n**Has this issue been opened before?**\n\n- [ ] It is not in the [FAQ](https://github.com/AbdBarho/stable-diffusion-webui-docker/wiki/FAQ), I checked.\n- [ ] It is not in the [issues](https://github.com/AbdBarho/stable-diffusion-webui-docker/issues?q=), I searched.\n\n**Describe the bug**\n\n<!--  tried to run the app, my cat exploded -->\n\n**Which UI**\n\nauto or auto-cpu or invoke or comfy?\n\n**Hardware / Software**\n\n- OS: [e.g. Windows 10 / Ubuntu 22.04]\n- OS version: <!--  on windows, use the command `winver` to find out, on ubuntu `lsb_release -d`  -->\n- WSL version (if applicable): <!-- get using `wsl -l -v` -->\n- Docker Version: <!--  get using `docker version` -->\n- Docker compose version: <!--  get using `docker compose version` -->\n- Repo version: <!-- tag, commit sha, or \"from master\" -->\n- RAM:\n- GPU/VRAM:\n\n**Steps to Reproduce**\n\n1. Go to '...'\n2. Click on '....'\n3. Scroll down to '....'\n4. See error\n\n**Additional context**\nAny other context about the problem here. If applicable, add screenshots to help explain your problem.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "content": "blank_issues_enabled: false\ncontact_links:\n  - name: Feature request? Questions regarding some extension?\n    url: https://github.com/AbdBarho/stable-diffusion-webui-docker/discussions\n    about: Please use the discussions tab\n"
  },
  {
    "path": ".github/pull_request_template.md",
    "content": "<!--\nHave you created an issue before opening a merge request???\nhttps://github.com/AbdBarho/stable-diffusion-webui-docker#contributing\nPlease create one so we can discuss it, I don't want your effort to go to waste.\n-->\n\nCloses issue #\n\n### Update versions\n\n- auto: https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/\n- invoke: https://github.com/invoke-ai/InvokeAI/commit/\n- comfy: https://github.com/comfyanonymous/ComfyUI/commit/\n"
  },
  {
    "path": ".github/workflows/docker.yml",
    "content": "name: Build Images\n\non:\n  push:\n    branches: master\n  pull_request:\n      paths:\n        - docker-compose.yml\n        - services\n\njobs:\n  build:\n    strategy:\n      matrix:\n        profile:\n          - auto\n          - comfy\n          - download\n    runs-on: ubuntu-latest\n    name: ${{ matrix.profile }}\n    steps:\n      - uses: actions/checkout@v3\n      - run: docker compose --profile ${{ matrix.profile }} build --progress plain\n"
  },
  {
    "path": ".github/workflows/stale.yml",
    "content": "name: 'Close stale issues and PRs'\non:\n  schedule:\n    - cron: '0 0 * * *'\n\njobs:\n  stale:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/stale@v6\n        with:\n          only-labels: awaiting-response\n          stale-issue-message: This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.\n          stale-pr-message: This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.\n          close-issue-message: This issue was closed because it has been stalled for 7 days with no activity.\n          close-pr-message: This PR was closed because it has been stalled for 7 days with no activity.\n          days-before-issue-stale: 14\n          days-before-pr-stale: 14\n          days-before-issue-close: 7\n          days-before-pr-close: 7\n"
  },
  {
    "path": ".gitignore",
    "content": "/.devcontainer\n/docker-compose.override.yml\n\n# VSCode specific\n*.code-workspace\n/.vscode\n"
  },
  {
    "path": "LICENSE",
    "content": "License\n\nCopyright (c) 2022\n\nSection I\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nThe person obtaining a copy of the Software meets the Use-based restrictions\nas referenced in Section II paragraph 1.\n\nThe person obtaining a copy of the Software accepts that the Model or\nDerivatives of the Model (as defined in the \"CreativeML Open RAIL-M\" license\naccompanying this License) are subject to Section II paragraph 1.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nSection II\n\n1. Use-based restrictions. The restrictions set forth in Attachment A are\nconsidered Use-based restrictions. Therefore the person obtaining a copy of the\nSoftware cannot use the Software for the specified restricted uses. The person\nobtaining a copy of the Software may use the Software only for lawful purposes.\n\n2. Except as set forth herein, the authors or copyright holders claim no rights\nin the results of operating the Software. The person obtaining a copy of the\nSoftware is accountable for the results of operating the Software and its\nsubsequent uses.\n\n3. If any provision of this License is held to be invalid, illegal or\nunenforceable, the remaining provisions shall be unaffected thereby and\nremain valid as if such provision had not been set forth herein.\n\nEND OF TERMS AND CONDITIONS\n\n\n\n\n\nAttachment A\n\nUse Restrictions\n\nThe person obtaining a copy of the Software agrees not to use the Software:\n- In any way that violates any applicable national, federal, state, local\nor international law or regulation;\n- For the purpose of exploiting, harming or attempting to exploit or harm\nminors in any way;\n- To generate or disseminate verifiably false information and/or content\nwith the purpose of harming others;\n- To generate or disseminate personal identifiable information that can\nbe used to harm an individual;\n- To defame, disparage or otherwise harass others;\n- For fully automated decision making that adversely impacts an\nindividual’s legal rights or otherwise creates or modifies a binding,\nenforceable obligation;\n- For any use intended to or which has the effect of discriminating\nagainst or harming individuals or groups based on online or offline\nsocial behavior or known or predicted personal or personality\ncharacteristics;\n- To exploit any of the vulnerabilities of a specific group of persons\nbased on their age, social, physical or mental characteristics, in order\nto materially distort the behavior of a person pertaining to that group\nin a manner that causes or is likely to cause that person or another\nperson physical or psychological harm;\n- For any use intended to or which has the effect of discriminating\nagainst individuals or groups based on legally protected characteristics\nor categories;\n- To provide medical advice and medical results interpretation;\n- To generate or disseminate information for the purpose to be used for\nadministration of justice, law enforcement, immigration or asylum\nprocesses, such as predicting an individual will commit fraud/crime\ncommitment (e.g. by text profiling, drawing causal relationships between\nassertions made in documents, indiscriminate and arbitrarily-targeted\nuse).\n"
  },
  {
    "path": "README.md",
    "content": "# Stable Diffusion WebUI Docker\n\nRun Stable Diffusion on your machine with a nice UI without any hassle!\n\n## Setup & Usage\n\nVisit the wiki for [Setup](https://github.com/AbdBarho/stable-diffusion-webui-docker/wiki/Setup) and [Usage](https://github.com/AbdBarho/stable-diffusion-webui-docker/wiki/Usage) instructions, checkout the [FAQ](https://github.com/AbdBarho/stable-diffusion-webui-docker/wiki/FAQ) page if you face any problems, or create a new issue!\n\n## Features\n\nThis repository provides multiple UIs for you to play around with stable diffusion:\n\n### [AUTOMATIC1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui)\n\n[Full feature list here](https://github.com/AUTOMATIC1111/stable-diffusion-webui-feature-showcase), Screenshots:\n\n| Text to image                                                                                              | Image to image                                                                                             | Extras                                                                                                     |\n| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |\n| ![](https://user-images.githubusercontent.com/24505302/189541954-46afd772-d0c8-4005-874c-e2eca40c02f2.jpg) | ![](https://user-images.githubusercontent.com/24505302/189541956-5b528de7-1b5d-479f-a1db-d3f5a53afc59.jpg) | ![](https://user-images.githubusercontent.com/24505302/189541957-cf78b352-a071-486d-8889-f26952779a61.jpg) |\n\n### [ComfyUI](https://github.com/comfyanonymous/ComfyUI)\n\n[Full feature list here](https://github.com/comfyanonymous/ComfyUI#features), Screenshot:\n\n| Workflow                                                                         |\n| -------------------------------------------------------------------------------- |\n| ![](https://github.com/comfyanonymous/ComfyUI/raw/master/comfyui_screenshot.png) |\n\n## Contributing\n\nContributions are welcome! **Create a discussion first of what the problem is and what you want to contribute (before you implement anything)**\n\n## Disclaimer\n\nThe authors of this project are not responsible for any content generated using this interface.\n\nThis license of this software forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please read [the license](./LICENSE).\n\n## Thanks\n\nSpecial thanks to everyone behind these awesome projects, without them, none of this would have been possible:\n\n- [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)\n- [InvokeAI](https://github.com/invoke-ai/InvokeAI)\n- [ComfyUI](https://github.com/comfyanonymous/ComfyUI)\n- [CompVis/stable-diffusion](https://github.com/CompVis/stable-diffusion)\n- [Sygil-webui](https://github.com/Sygil-Dev/sygil-webui)\n- and many many more.\n"
  },
  {
    "path": "data/.gitignore",
    "content": "/.cache\n/config\n/embeddings\n/models\n"
  },
  {
    "path": "docker-compose.yml",
    "content": "x-base_service: &base_service\n    ports:\n      - \"${WEBUI_PORT:-7860}:7860\"\n    volumes:\n      - &v1 ./data:/data\n      - &v2 ./output:/output\n    stop_signal: SIGKILL\n    tty: true\n    deploy:\n      resources:\n        reservations:\n          devices:\n              - driver: nvidia\n                device_ids: ['0']\n                capabilities: [compute, utility]\n\nname: webui-docker\n\nservices:\n  download:\n    build: ./services/download/\n    profiles: [\"download\"]\n    volumes:\n      - *v1\n\n  auto: &automatic\n    <<: *base_service\n    profiles: [\"auto\"]\n    build: ./services/AUTOMATIC1111\n    image: sd-auto:78\n    environment:\n      - CLI_ARGS=--allow-code --medvram --xformers --enable-insecure-extension-access --api\n\n  auto-cpu:\n    <<: *automatic\n    profiles: [\"auto-cpu\"]\n    deploy: {}\n    environment:\n      - CLI_ARGS=--no-half --precision full --allow-code --enable-insecure-extension-access --api\n\n  comfy: &comfy\n    <<: *base_service\n    profiles: [\"comfy\"]\n    build: ./services/comfy/\n    image: sd-comfy:7\n    environment:\n      - CLI_ARGS=\n\n\n  comfy-cpu:\n    <<: *comfy\n    profiles: [\"comfy-cpu\"]\n    deploy: {}\n    environment:\n      - CLI_ARGS=--cpu\n"
  },
  {
    "path": "output/.gitignore",
    "content": "/*\n!/.gitignore"
  },
  {
    "path": "services/AUTOMATIC1111/Dockerfile",
    "content": "FROM alpine/git:2.36.2 as download\n\nCOPY clone.sh /clone.sh\n\nRUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git 6f7db241d2f8ba7457bac5ca9753331f0c266917\n\nRUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf \\\n  && rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif\n\nRUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 48211a1594f1321b00f14c9f7a5b4813144b2fb9\nRUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git ab527a9a6d347f364e3d185ba6d714e22d80cb3c\nRUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2cf03aaf6e704197fd0dae7c7f96aa59cf1b11c9\nRUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 45c443b316737a4ab6e40413d7794a7f5657c19f\nRUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets 6f7db241d2f8ba7457bac5ca9753331f0c266917\n\n\nFROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime\n\nENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1\n\nRUN --mount=type=cache,target=/var/cache/apt \\\n  apt-get update && \\\n  # we need those\n  apt-get install -y fonts-dejavu-core rsync git jq moreutils aria2 \\\n  # extensions needs those\n  ffmpeg libglfw3-dev libgles2-mesa-dev pkg-config libcairo2 libcairo2-dev build-essential\n\n\nWORKDIR /\nRUN --mount=type=cache,target=/root/.cache/pip \\\n  git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \\\n  cd stable-diffusion-webui && \\\n  git reset --hard v1.9.4 && \\\n  pip install -r requirements_versions.txt\n\n\nENV ROOT=/stable-diffusion-webui\n\nCOPY --from=download /repositories/ ${ROOT}/repositories/\nRUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/clip_interrogator/data/* ${ROOT}/interrogate\n\nRUN --mount=type=cache,target=/root/.cache/pip \\\n  pip install pyngrok xformers==0.0.26.post1 \\\n  git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 \\\n  git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \\\n  git+https://github.com/mlfoundations/open_clip.git@v2.20.0\n\n# there seems to be a memory leak (or maybe just memory not being freed fast enough) that is fixed by this version of malloc\n# maybe move this up to the dependencies list.\nRUN apt-get -y install libgoogle-perftools-dev && apt-get clean\nENV LD_PRELOAD=libtcmalloc.so\n\nCOPY . /docker\n\nRUN \\\n  # mv ${ROOT}/style.css ${ROOT}/user.css && \\\n  # one of the ugliest hacks I ever wrote \\\n  sed -i 's/in_app_dir = .*/in_app_dir = True/g' /opt/conda/lib/python3.10/site-packages/gradio/routes.py && \\\n  git config --global --add safe.directory '*'\n\nWORKDIR ${ROOT}\nENV NVIDIA_VISIBLE_DEVICES=all\nENV CLI_ARGS=\"\"\nEXPOSE 7860\nENTRYPOINT [\"/docker/entrypoint.sh\"]\nCMD python -u webui.py --listen --port 7860 ${CLI_ARGS}\n"
  },
  {
    "path": "services/AUTOMATIC1111/clone.sh",
    "content": "#!/bin/bash\n\nset -Eeuox pipefail\n\nmkdir -p /repositories/\"$1\"\ncd /repositories/\"$1\"\ngit init\ngit remote add origin \"$2\"\ngit fetch origin \"$3\" --depth=1\ngit reset --hard \"$3\"\nrm -rf .git\n"
  },
  {
    "path": "services/AUTOMATIC1111/config.py",
    "content": "#!/usr/bin/env python3\n\n\"\"\"Checks and sets default values for config.json before starting the container.\"\"\"\n\nimport json\nimport re\nimport os.path\nimport sys\n\nDEFAULT_FILEPATH = '/data/config/auto/config.json'\n\nDEFAULT_OUTDIRS = {\n  \"outdir_samples\": \"\",\n  \"outdir_txt2img_samples\": \"/output/txt2img\",\n  \"outdir_img2img_samples\": \"/output/img2img\",\n  \"outdir_extras_samples\": \"/output/extras\",\n  \"outdir_grids\": \"\",\n  \"outdir_txt2img_grids\": \"/output/txt2img-grids\",\n  \"outdir_img2img_grids\": \"/output/img2img-grids\",\n  \"outdir_save\": \"/output/saved\",\n  \"outdir_init_images\": \"/output/init-images\",\n}\nRE_VALID_OUTDIR = re.compile(r\"(^/output(/\\.?[\\w\\-\\_]+)+/?$)|(^\\s?$)\")\n\nDEFAULT_OTHER = {\n  \"font\": \"DejaVuSans.ttf\",\n}\n\ndef dict_to_json_file(target_file: str, data: dict):\n  \"\"\"Write dictionary to specified json file\"\"\"\n\n  with open(target_file, 'w') as f:\n    json.dump(data, f)\n\ndef json_file_to_dict(config_file: str) -> dict|None:\n   \"\"\"Load json file into a dictionary. Return None if file does not exist.\"\"\"\n\n   if os.path.isfile(config_file):\n    with open(config_file, 'r') as f:\n      return json.load(f)\n   else:\n      return None\n\ndef replace_if_invalid(value: str, replacement: str, pattern: str|re.Pattern[str]) -> str:\n  \"\"\"Returns original value if valid, fallback value if invalid\"\"\"\n\n  if re.match(pattern, value):\n    return value\n  else:\n    return replacement\n\ndef check_and_replace_config(config_file: str, target_file: str = None):\n  \"\"\"Checks given file for invalid values. Replaces those with fallback values (default: overwrites file).\"\"\"\n\n  # Get current user config, or empty if file does not exists\n  data = json_file_to_dict(config_file) or {}\n\n  # Check and fix output directories\n  for k, def_val in DEFAULT_OUTDIRS.items():\n    if k not in data:\n      data[k] = def_val\n    else:\n      data[k] = replace_if_invalid(value=data[k], replacement=def_val, pattern=RE_VALID_OUTDIR)\n\n  # Check and fix other default settings\n  for k, def_val in DEFAULT_OTHER.items():\n    if k not in data:\n      data[k] = def_val\n\n  # Write results to file\n  dict_to_json_file(target_file or config_file, data)\n\nif __name__ == '__main__':\n  if len(sys.argv) > 1:\n    check_and_replace_config(*sys.argv[1:])\n  else:\n    check_and_replace_config(DEFAULT_FILEPATH)\n\n"
  },
  {
    "path": "services/AUTOMATIC1111/entrypoint.sh",
    "content": "#!/bin/bash\n\nset -Eeuo pipefail\n\n# TODO: move all mkdir -p ?\nmkdir -p /data/config/auto/scripts/\n# mount scripts individually\n\necho $ROOT\nls -lha $ROOT\n\nfind \"${ROOT}/scripts/\" -maxdepth 1 -type l -delete\ncp -vrfTs /data/config/auto/scripts/ \"${ROOT}/scripts/\"\n\n# Set up config file\npython /docker/config.py /data/config/auto/config.json\n\nif [ ! -f /data/config/auto/ui-config.json ]; then\n  echo '{}' >/data/config/auto/ui-config.json\nfi\n\nif [ ! -f /data/config/auto/styles.csv ]; then\n  touch /data/config/auto/styles.csv\nfi\n\n# copy models from original models folder\nmkdir -p /data/models/VAE-approx/ /data/models/karlo/\n\nrsync -a --info=NAME ${ROOT}/models/VAE-approx/ /data/models/VAE-approx/\nrsync -a --info=NAME ${ROOT}/models/karlo/ /data/models/karlo/\n\ndeclare -A MOUNTS\n\nMOUNTS[\"/root/.cache\"]=\"/data/.cache\"\nMOUNTS[\"${ROOT}/models\"]=\"/data/models\"\n\nMOUNTS[\"${ROOT}/embeddings\"]=\"/data/embeddings\"\nMOUNTS[\"${ROOT}/config.json\"]=\"/data/config/auto/config.json\"\nMOUNTS[\"${ROOT}/ui-config.json\"]=\"/data/config/auto/ui-config.json\"\nMOUNTS[\"${ROOT}/styles.csv\"]=\"/data/config/auto/styles.csv\"\nMOUNTS[\"${ROOT}/extensions\"]=\"/data/config/auto/extensions\"\nMOUNTS[\"${ROOT}/config_states\"]=\"/data/config/auto/config_states\"\n\n# extra hacks\nMOUNTS[\"${ROOT}/repositories/CodeFormer/weights/facelib\"]=\"/data/.cache\"\n\nfor to_path in \"${!MOUNTS[@]}\"; do\n  set -Eeuo pipefail\n  from_path=\"${MOUNTS[${to_path}]}\"\n  rm -rf \"${to_path}\"\n  if [ ! -f \"$from_path\" ]; then\n    mkdir -vp \"$from_path\"\n  fi\n  mkdir -vp \"$(dirname \"${to_path}\")\"\n  ln -sT \"${from_path}\" \"${to_path}\"\n  echo Mounted $(basename \"${from_path}\")\ndone\n\necho \"Installing extension dependencies (if any)\"\n\n# because we build our container as root:\nchown -R root ~/.cache/\nchmod 766 ~/.cache/\n\nshopt -s nullglob\n# For install.py, please refer to https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Developing-extensions#installpy\nlist=(./extensions/*/install.py)\nfor installscript in \"${list[@]}\"; do\n  EXTNAME=$(echo $installscript | cut -d '/' -f 3)\n  # Skip installing dependencies if extension is disabled in config\n  if $(jq -e \".disabled_extensions|any(. == \\\"$EXTNAME\\\")\" config.json); then\n    echo \"Skipping disabled extension ($EXTNAME)\"\n    continue\n  fi\n  PYTHONPATH=${ROOT} python \"$installscript\"\ndone\n\nif [ -f \"/data/config/auto/startup.sh\" ]; then\n  pushd ${ROOT}\n  echo \"Running startup script\"\n  . /data/config/auto/startup.sh\n  popd\nfi\n\nexec \"$@\"\n"
  },
  {
    "path": "services/comfy/Dockerfile",
    "content": "FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime\n\nENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1\n\nRUN apt-get update && apt-get install -y git && apt-get clean\n\nENV ROOT=/stable-diffusion\nRUN --mount=type=cache,target=/root/.cache/pip \\\n  git clone https://github.com/comfyanonymous/ComfyUI.git ${ROOT} && \\\n  cd ${ROOT} && \\\n  git checkout master && \\\n  git reset --hard 276f8fce9f5a80b500947fb5745a4dde9e84622d && \\\n  pip install -r requirements.txt\n\nWORKDIR ${ROOT}\nCOPY . /docker/\nRUN chmod u+x /docker/entrypoint.sh && cp /docker/extra_model_paths.yaml ${ROOT}\n\nENV NVIDIA_VISIBLE_DEVICES=all PYTHONPATH=\"${PYTHONPATH}:${PWD}\" CLI_ARGS=\"\"\nEXPOSE 7860\nENTRYPOINT [\"/docker/entrypoint.sh\"]\nCMD python -u main.py --listen --port 7860 ${CLI_ARGS}\n"
  },
  {
    "path": "services/comfy/entrypoint.sh",
    "content": "#!/bin/bash\n\nset -Eeuo pipefail\n\nmkdir -vp /data/config/comfy/custom_nodes\n\ndeclare -A MOUNTS\n\nMOUNTS[\"/root/.cache\"]=\"/data/.cache\"\nMOUNTS[\"${ROOT}/input\"]=\"/data/config/comfy/input\"\nMOUNTS[\"${ROOT}/output\"]=\"/output/comfy\"\n\nfor to_path in \"${!MOUNTS[@]}\"; do\n  set -Eeuo pipefail\n  from_path=\"${MOUNTS[${to_path}]}\"\n  rm -rf \"${to_path}\"\n  if [ ! -f \"$from_path\" ]; then\n    mkdir -vp \"$from_path\"\n  fi\n  mkdir -vp \"$(dirname \"${to_path}\")\"\n  ln -sT \"${from_path}\" \"${to_path}\"\n  echo Mounted $(basename \"${from_path}\")\ndone\n\nif [ -f \"/data/config/comfy/startup.sh\" ]; then\n  pushd ${ROOT}\n  . /data/config/comfy/startup.sh\n  popd\nfi\n\nexec \"$@\"\n"
  },
  {
    "path": "services/comfy/extra_model_paths.yaml",
    "content": "a111:\n  base_path: /data\n\n  checkpoints: models/Stable-diffusion\n  configs: models/Stable-diffusion\n  vae: models/VAE\n  loras: models/Lora\n  upscale_models: |\n    models/RealESRGAN\n    models/ESRGAN\n    models/SwinIR\n    models/GFPGAN\n  hypernetworks: models/hypernetworks\n  controlnet: models/ControlNet\n  gligen: models/GLIGEN\n  clip: models/CLIPEncoder\n  embeddings: embeddings\n\n  custom_nodes: config/comfy/custom_nodes\n\n  # TODO: I am unsure about these, need more testing\n  # style_models: config/comfy/style_models\n  # t2i_adapter: config/comfy/t2i_adapter\n  # clip_vision: config/comfy/clip_vision\n  # diffusers: config/comfy/diffusers\n"
  },
  {
    "path": "services/download/Dockerfile",
    "content": "FROM bash:alpine3.19\n\nRUN apk update && apk add parallel aria2\nCOPY . /docker\nRUN chmod +x /docker/download.sh\nENTRYPOINT [\"/docker/download.sh\"]\n"
  },
  {
    "path": "services/download/checksums.sha256",
    "content": "cc6cb27103417325ff94f52b7a5d2dde45a7515b25c255d8e396c90014281516  /data/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt\nc6bbc15e3224e6973459ba78de4998b80b50112b0ae5b5c67113d56b4e366b19  /data/models/Stable-diffusion/sd-v1-5-inpainting.ckpt\nc6a580b13a5bc05a5e16e4dbb80608ff2ec251a162311590c1f34c013d7f3dab  /data/models/VAE/vae-ft-mse-840000-ema-pruned.ckpt\ne2cd4703ab14f4d01fd1383a8a8b266f9a5833dacee8e6a79d3bf21a1b6be5ad  /data/models/GFPGAN/GFPGANv1.4.pth\n4fa0d38905f75ac06eb49a7951b426670021be3018265fd191d2125df9d682f1  /data/models/RealESRGAN/RealESRGAN_x4plus.pth\nf872d837d3c90ed2e05227bed711af5671a6fd1c9f7d7e91c911a61f155e99da  /data/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.pth\nc209caecac2f97b4bb8f4d726b70ac2ac9b35904b7fc99801e1f5e61f9210c13  /data/models/LDSR/model.ckpt\n9d6ad53c5dafeb07200fb712db14b813b527edd262bc80ea136777bdb41be2ba  /data/models/LDSR/project.yaml\n"
  },
  {
    "path": "services/download/download.sh",
    "content": "#!/usr/bin/env bash\n\nset -Eeuo pipefail\n\n# TODO: maybe just use the .gitignore file to create all of these\nmkdir -vp /data/.cache \\\n  /data/embeddings \\\n  /data/config/ \\\n  /data/models/ \\\n  /data/models/Stable-diffusion \\\n  /data/models/GFPGAN \\\n  /data/models/RealESRGAN \\\n  /data/models/LDSR \\\n  /data/models/VAE\n\necho \"Downloading, this might take a while...\"\n\naria2c -x 10 --disable-ipv6 --input-file /docker/links.txt --dir /data/models --continue\n\necho \"Checking SHAs...\"\n\nparallel --will-cite -a /docker/checksums.sha256 \"echo -n {} | sha256sum -c\"\n\ncat <<EOF\nBy using this software, you agree to the following licenses:\nhttps://github.com/AbdBarho/stable-diffusion-webui-docker/blob/master/LICENSE\nhttps://github.com/CompVis/stable-diffusion/blob/main/LICENSE\nhttps://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/LICENSE.txt\nhttps://github.com/invoke-ai/InvokeAI/blob/main/LICENSE\nAnd licenses of all UIs, third party libraries, and extensions.\nEOF\n"
  },
  {
    "path": "services/download/links.txt",
    "content": "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt\n  out=Stable-diffusion/v1-5-pruned-emaonly.ckpt\nhttps://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.ckpt\n  out=VAE/vae-ft-mse-840000-ema-pruned.ckpt\nhttps://huggingface.co/runwayml/stable-diffusion-inpainting/resolve/main/sd-v1-5-inpainting.ckpt\n  out=Stable-diffusion/sd-v1-5-inpainting.ckpt\nhttps://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth\n  out=GFPGAN/GFPGANv1.4.pth\nhttps://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth\n  out=RealESRGAN/RealESRGAN_x4plus.pth\nhttps://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth\n  out=RealESRGAN/RealESRGAN_x4plus_anime_6B.pth\nhttps://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1\n  out=LDSR/project.yaml\nhttps://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1\n  out=LDSR/model.ckpt\n"
  }
]