From 07a9062e1fcecec8abf97570633bc01c2f5c90c3 Mon Sep 17 00:00:00 2001 From: mauwii Date: Tue, 7 Feb 2023 02:07:40 +0100 Subject: [PATCH] update .dockerignore and scripts --- .dockerignore | 8 ++++---- docker/build.sh | 11 ++++++----- docker/env.sh | 8 +++++++- docker/run.sh | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.dockerignore b/.dockerignore index 429ca125c0..c248f6d8ed 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,13 +11,13 @@ # ignore frontend but whitelist dist invokeai/frontend/** -!invokeai/frontend/dist +!invokeai/frontend/dist/** # ignore invokeai/assets but whitelist invokeai/assets/web -invokeai/assets -!invokeai/assets/web +invokeai/assets/** +!invokeai/assets/web/*.png -# ignore python cache +# ignore python cache and build artifacts **/__pycache__ **/*.py[cod] **/*.egg-info diff --git a/docker/build.sh b/docker/build.sh index 1ad51b387a..1bc233f222 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -8,12 +8,12 @@ set -e # CPU: https://download.pytorch.org/whl/cpu # as found on https://pytorch.org/get-started/locally/ -SCRIPTDIR=$(dirname "$0") +SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") cd "$SCRIPTDIR" || exit 1 source ./env.sh -DOCKERFILE=${INVOKE_DOCKERFILE:-Dockerfile} +DOCKERFILE=${INVOKE_DOCKERFILE:-./Dockerfile} # print the settings echo -e "You are using these values:\n" @@ -21,9 +21,10 @@ echo -e "Dockerfile:\t\t${DOCKERFILE}" echo -e "index-url:\t\t${PIP_EXTRA_INDEX_URL:-none}" echo -e "Volumename:\t\t${VOLUMENAME}" echo -e "Platform:\t\t${PLATFORM}" -echo -e "Registry:\t\t${CONTAINER_REGISTRY}" -echo -e "Repository:\t\t${CONTAINER_REPOSITORY}" +echo -e "Container Registry:\t${CONTAINER_REGISTRY}" +echo -e "Container Repository:\t${CONTAINER_REPOSITORY}" echo -e "Container Tag:\t\t${CONTAINER_TAG}" +echo -e "Container Flavor:\t${CONTAINER_FLAVOR}" echo -e "Container Image:\t${CONTAINER_IMAGE}\n" # Create docker volume @@ -41,5 +42,5 @@ DOCKER_BUILDKIT=1 docker build \ ${CONTAINER_FLAVOR:+--build-arg="CONTAINER_FLAVOR=${CONTAINER_FLAVOR}"} \ ${PIP_EXTRA_INDEX_URL:+--build-arg="PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}"} \ ${PIP_PACKAGE:+--build-arg="PIP_PACKAGE=${PIP_PACKAGE}"} \ - --file="${DOCKERFILE:-./Dockerfile}" \ + --file="${DOCKERFILE}" \ .. diff --git a/docker/env.sh b/docker/env.sh index d6b0699ce5..f6a7a2b206 100644 --- a/docker/env.sh +++ b/docker/env.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash if [[ -z "$PIP_EXTRA_INDEX_URL" ]]; then + # Activate virtual environment if not already activated + if [[ -z $VIRTUAL_ENV ]]; then + [[ -e "$(dirname "${BASH_SOURCE[0]}")/../.venv/bin/activate" ]] \ + && source "$(dirname "${BASH_SOURCE[0]}")/../.venv/bin/activate" + fi # Decide which container flavor to build if not specified if [[ -z "$CONTAINER_FLAVOR" ]] && python -c "import torch" &>/dev/null; then # Check for CUDA and ROCm @@ -26,7 +31,8 @@ fi # Variables shared by build.sh and run.sh REPOSITORY_NAME="${REPOSITORY_NAME-$(basename "$(git rev-parse --show-toplevel)")}" -VOLUMENAME="${VOLUMENAME-"${REPOSITORY_NAME,,}_data"}" +REPOSITORY_NAME="${REPOSITORY_NAME,,}" +VOLUMENAME="${VOLUMENAME-"${REPOSITORY_NAME}_data"}" ARCH="${ARCH-$(uname -m)}" PLATFORM="${PLATFORM-Linux/${ARCH}}" INVOKEAI_BRANCH="${INVOKEAI_BRANCH-$(git branch --show)}" diff --git a/docker/run.sh b/docker/run.sh index f769976b1c..7d3b0990ab 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -4,7 +4,7 @@ set -e # How to use: https://invoke-ai.github.io/InvokeAI/installation/INSTALL_DOCKER/#run-the-container # IMPORTANT: You need to have a token on huggingface.co to be able to download the checkpoints!!! -SCRIPTDIR=$(dirname "$0") +SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") cd "$SCRIPTDIR" || exit 1 source ./env.sh