From af9c20d3b9f359af5d7544a4ecd7e7ac78e0dfe5 Mon Sep 17 00:00:00 2001 From: Derek Paschal Date: Wed, 15 Feb 2023 09:11:02 -0600 Subject: [PATCH] Ddded entrypoint.sh that will clone repo. Repo is cloned into /sd if .git directory does not already exist there. Also updated the name of the container image to match what I want to use --- Dockerfile | 12 +++++++----- docker-compose.yml | 11 ++++++----- entrypoint.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index ef1e7f77..023ede99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ FROM python:3.10 -WORKDIR /sd +WORKDIR / + +RUN apt update \ + && apt install -y wget git htop python3-opencv rsync + +COPY ./entrypoint.sh . EXPOSE 7860 -RUN apt update \ - && apt install -y wget git htop - -CMD [ "./webui.sh", "-f" ] \ No newline at end of file +CMD [ "./entrypoint.sh" ] diff --git a/docker-compose.yml b/docker-compose.yml index 869530c4..4590e006 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,14 @@ version: '3.4' services: - sd-docker: - container_name: sd-docker - image: git.exile.place/derek/sd-docker:latest + auto-sd-docker: + container_name: auto-sd-docker + image: git.exile.place/derek/auto-sd-docker:latest restart: "no" ports: - "7860:7860" volumes: - - ./:/sd + - ./sd:/sd + - "/path/to/models:/sd/models/Stable-diffusion" deploy: resources: reservations: @@ -16,7 +17,7 @@ services: device_ids: ['0'] capabilities: [gpu] healthcheck: - test: "wget --no-verbose --tries=1 --spider http://sd-docker:7860 || exit 1" + test: "wget --no-verbose --tries=1 --spider http://auto-sd-docker:7860 || exit 1" interval: 2m timeout: 30s retries: 5 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..16984770 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +####################################################### +# This is the entrypoint script for the app container # +####################################################### + +# Determine if repo is already cloned +if [[ -d /sd/.git && -f /sd/webui.sh ]] +then + # repo already cloned + echo "Repo already cloned." +else + # clone the repo + echo "Repo missing, cloning now." + git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git /repo_temp + rsync -a /repo_temp/ /sd/ + rm -rf /repo_temp +fi + +cd /sd + +# --listen is always required while running inside a container +if [[ ! $COMMANDLINE_ARGS =~ "--listen" ]] +then + # this could still be overwritten by webui-user.sh + COMMANDLINE_ARGS="--listen ${COMMANDLINE_ARGS}" +fi + +# Start webui.sh, -f flag allows running as root +./webui.sh -f