From 555c26b7ce435001bc86684c7e6f314e88c6ed01 Mon Sep 17 00:00:00 2001 From: AJ Walter Date: Sun, 16 Apr 2023 03:32:03 -0500 Subject: [PATCH] Make Dockerfiles OCI compliant (#408) ## Justification Closes issue #352 This update makes the Dockerfiles OCI compliant, making it easier to use Buildah or other image building techniques that require it ## Implementation This changes a few things, listed below: * auto: Download container is switched to alpine. The `git` container specified the `/git` directory as a volume. As such, all the files under `/git` would be lost after each script invoke. Alpine is used later in the build process anyway, so it shouldn't be any extra cost to switch to it * auto: "New" clone.sh script is copied into the container, which is basically just the previous clone script that was embedded in the Dockerfile. * all: `< --- services/AUTOMATIC1111/Dockerfile | 52 +++++++++++++------------------ services/AUTOMATIC1111/clone.sh | 11 +++++++ services/invoke/Dockerfile | 47 +++++++++++++--------------- services/sygil/Dockerfile | 42 +++++++++++-------------- 4 files changed, 71 insertions(+), 81 deletions(-) create mode 100644 services/AUTOMATIC1111/clone.sh diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111/Dockerfile index b2d44d8..a610d0c 100644 --- a/services/AUTOMATIC1111/Dockerfile +++ b/services/AUTOMATIC1111/Dockerfile @@ -1,14 +1,6 @@ -# syntax=docker/dockerfile:1 - FROM alpine/git:2.36.2 as download -SHELL ["/bin/sh", "-ceuxo", "pipefail"] - -RUN < /clone.sh -mkdir -p repositories/"$1" && cd repositories/"$1" && git init && git remote add origin "$2" && git fetch origin "$3" --depth=1 && git reset --hard "$3" && rm -rf .git -EOE -EOF +COPY clone.sh /clone.sh RUN . /clone.sh taming-transformers https://github.com/CompVis/taming-transformers.git 24268930bf1dce879235a7fddd0b2355b84d7ea6 \ && rm -rf data assets **/*.ipynb @@ -30,21 +22,19 @@ RUN aria2c -x 5 --dir / --out wheel.whl 'https://github.com/AbdBarho/stable-diff FROM python:3.10.9-slim -SHELL ["/bin/bash", "-ceuxo", "pipefail"] - ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 -RUN PIP_NO_CACHE_DIR=1 pip install torch==1.13.1+cu117 torchvision --extra-index-url https://download.pytorch.org/whl/cu117 +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install torch==1.13.1+cu117 torchvision --extra-index-url https://download.pytorch.org/whl/cu117 RUN apt-get update && apt install fonts-dejavu-core rsync git jq moreutils -y && apt-get clean -RUN --mount=type=cache,target=/root/.cache/pip < req.txt -pip install -r req.txt -rm req.txt -EOF +RUN --mount=type=cache,target=/root/.cache/pip \ + git reset --hard f232068ab89bd80e4f5f3133dcdb62ea78f1d0f7 && \ + git config --global http.postBuffer 1048576000 && \ + egrep -v '^-e .' environments-and-requirements/requirements-lin-cuda.txt > req.txt && \ + pip install -r req.txt && \ + rm req.txt # patch match: # https://github.com/invoke-ai/InvokeAI/blob/main/docs/installation/INSTALL_PATCHMATCH.md -RUN <=4.24' # add info COPY . /docker/ -RUN <