-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add infinite image browser container
- Loading branch information
Showing
5 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# base image to use | ||
ARG BASE_IMAGE=python:3.10-bookworm | ||
# settings for apt and pip (inheritable by all images) | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
ARG DEBIAN_PRIORITY=critical | ||
ARG PIP_PREFER_BINARY=1 | ||
|
||
# Build the base image. | ||
FROM ${BASE_IMAGE} as browser | ||
|
||
# Set shell | ||
SHELL ["/bin/bash", "-ceuxo", "pipefail"] | ||
|
||
# Inherit args from global | ||
ARG DEBIAN_FRONTEND | ||
ARG DEBIAN_PRIORITY | ||
ARG PIP_PREFER_BINARY | ||
|
||
# Silence pip root user warnings | ||
ENV PIP_ROOT_USER_ACTION=ignore | ||
ENV _PIP_LOCATIONS_NO_WARN_ON_MISMATCH=1 | ||
|
||
# create app/data directories | ||
RUN mkdir -p /app/browser /data /output | ||
# set workdir | ||
WORKDIR /app/browser | ||
|
||
# clone repo and clean up git dir (to reduce image size) | ||
ARG BROWSER_REPO=https://github.com/zanllp/sd-webui-infinite-image-browsing.git | ||
ARG BROWSER_REF=main | ||
RUN git clone --depth=1 --single-branch --branch="${BROWSER_REF}" "${BROWSER_REPO}" /app/browser \ | ||
&& rm -fr /app/browser/.git | ||
|
||
# install Python dependencies | ||
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \ | ||
python -m pip install -U pip setuptools wheel \ | ||
&& python -m pip install -r requirements.txt | ||
|
||
# hotpatch the path to the sqlite db file so it's in /data | ||
RUN sed -iE 's|iib\.db|/data/iib.sqlite|g' /app/browser/scripts/iib/db/datamodel.py \ | ||
&& grep -q '/data/iib.sqlite' /app/browser/scripts/iib/db/datamodel.py \ | ||
|| (echo "Failed to hotpatch the sqlite db path!" && exit 1) | ||
|
||
# copy in entrypoint script and set permissions | ||
COPY --chown=root:root entrypoint.sh /app/entrypoint.sh | ||
RUN chmod 755 /app/entrypoint.sh | ||
|
||
# copy in default config | ||
COPY --chown=root:root config.json /app/config.default.json | ||
|
||
# set entrypoint | ||
ENTRYPOINT ["/app/entrypoint.sh"] | ||
CMD [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"outdir_samples": "", | ||
"outdir_txt2img_samples": "/output/txt2img", | ||
"outdir_img2img_samples": "/output/img2img", | ||
"outdir_extras_samples": "/output/extras", | ||
"outdir_txt2img_grids": "/output/txt2img-grids", | ||
"outdir_img2img_grids": "/output/img2img-grids", | ||
"outdir_save": "/output/saved", | ||
"outdir_grids": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
REPO_DIR=${REPO_DIR:-'/app/browser'} | ||
IMAGES_DIR=${IMAGES_DIR:-'/output'} | ||
BROWSER_PORT=${BROWSER_PORT-} | ||
|
||
# make sure we're in the repo dir | ||
cd ${REPO_DIR} | ||
|
||
# fixed flags (needed for docker) | ||
IIB_FLAGS='--host=0.0.0.0' | ||
|
||
WEBUI_CONFIG_PATH=${WEBUI_CONFIG_PATH:-'/data/config/auto/config.json'} | ||
if [[ ! -f ${WEBUI_CONFIG_PATH} ]]; then | ||
echo \ | ||
"------------------------------------------------------------------------" \ | ||
" No config file found at ${WEBUI_CONFIG_PATH}, using default config. " \ | ||
" !!! Defaults assume your webui output dir is mounted at /outputs !!! " \ | ||
"------------------------------------------------------------------------" | ||
WEBUI_CONFIG_PATH="/app/config.default.json" | ||
fi | ||
|
||
# if we have any args, and the first arg is not a flag, assume args are a command and exec it | ||
if [[ $# -gt 0 ]] && [[ ! $1 =~ ^- ]]; then | ||
echo "Command detected (first arg is not a flag), will not start server!" | ||
echo "exec'ing command: $@" | ||
exec "$@" | ||
fi | ||
|
||
# make temp dir and set env (thumbnail storage) | ||
mkdir -p /data/.cache/iib | ||
export TMPDIR=/data/.cache/iib | ||
|
||
# add port flag if set | ||
if [[ -n ${BROWSER_PORT} ]]; then | ||
IIB_FLAGS="${IIB_FLAGS} --port=${BROWSER_PORT}" | ||
fi | ||
|
||
# check if the mounted /data volume has an IIB installation and pass the flag to use it | ||
if [[ -d '/data/config/auto/extensions/sd-webui-infinite-image-browsing' ]]; then | ||
echo 'Found IIB installation in mounted /data volume, enabling DB sharing mode' | ||
IIB_FLAGS="${IIB_FLAGS} --sd_webui_dir=/data/config/auto" | ||
fi | ||
|
||
echo "Starting webui server with args: $@ --host=0.0.0.0" | ||
exec python -u app.py --sd_webui_config=${WEBUI_CONFIG_PATH} "$@" ${IIB_FLAGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters