Skip to content

Commit 4f9aa18

Browse files
committed
improve the Makefile for local use
1 parent 4cb8205 commit 4f9aa18

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

docker-build/Makefile

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,55 @@
11
# Copyright (c) 2022 Eugene Brodsky (https://github.com/ebr)
22

3-
# Directory in the container where the INVOKEAI_ROOT will be mounted
3+
# Directory in the container where the INVOKEAI_ROOT (runtime dir) will be mounted
44
INVOKEAI_ROOT=/mnt/invokeai
5-
# Host directory to contain the model cache. Will be mounted at INVOKEAI_ROOT path in the container
6-
INVOKEAI_CACHEDIR=${HOME}/invokeai
5+
# Host directory to contain the runtime dir. Will be mounted at INVOKEAI_ROOT path in the container
6+
HOST_MOUNT_PATH=${HOME}/invokeai
77

88
DOCKER_BUILDKIT=1
99
IMAGE=local/invokeai:latest
1010

1111
USER=$(shell id -u)
1212
GROUP=$(shell id -g)
1313

14-
# All downloaded models and config will end up in ${INVOKEAI_CACHEDIR}.
15-
# Contents can be moved to a persistent storage and used to rehydrate the cache on another host
14+
# All downloaded models, config, etc will end up in ${HOST_MOUNT_PATH} on the host.
15+
# This is consistent with the expected non-Docker behaviour.
16+
# Contents can be moved to a persistent storage and used to prime the cache on another host.
1617

1718
build:
1819
docker build -t local/invokeai:latest -f Dockerfile.cloud ..
1920

20-
# Copy only the content of config dir first, such that the configuration
21-
# script can run with the expected config dir already populated.
22-
# Then, run the configuration script.
2321
configure:
24-
docker run --rm -it \
25-
-v ${INVOKEAI_CACHEDIR}/configs:/mnt/configs \
26-
--entrypoint bash ${IMAGE} \
27-
-c "cp -r ./configs/* /mnt/configs/"
2822
docker run --rm -it --runtime=nvidia --gpus=all \
29-
-v ${INVOKEAI_CACHEDIR}:${INVOKEAI_ROOT} \
30-
-v ${INVOKEAI_CACHEDIR}/.cache:/root/.cache \
31-
${IMAGE} \
32-
-c "scripts/configure_invokeai.py --root ${INVOKEAI_ROOT}"
33-
sudo chown -R ${USER}:${GROUP} ${INVOKEAI_CACHEDIR}
23+
-v ${HOST_MOUNT_PATH}:${INVOKEAI_ROOT} \
24+
-v ${HOST_MOUNT_PATH}/.cache:/root/.cache \
25+
-e INVOKEAI_ROOT=${INVOKEAI_ROOT} \
26+
--entrypoint bash \
27+
${IMAGE} -c "scripts/configure_invokeai.py"
28+
sudo chown -R ${USER}:${GROUP} ${HOST_MOUNT_PATH}
3429

35-
# Run the container with the cache mounted and the web server exposed on port 9090
30+
# Run the container with the runtime dir mounted and the web server exposed on port 9090
3631
web:
3732
docker run --rm -it --runtime=nvidia --gpus=all \
38-
-v ${INVOKEAI_CACHEDIR}:${INVOKEAI_ROOT} \
39-
-v ${INVOKEAI_CACHEDIR}/.cache:/root/.cache \
33+
-v ${HOST_MOUNT_PATH}:${INVOKEAI_ROOT} \
34+
-v ${HOST_MOUNT_PATH}/.cache:/root/.cache \
35+
-e INVOKEAI_ROOT=${INVOKEAI_ROOT} \
4036
--entrypoint bash -p9090:9090 ${IMAGE} \
4137
-c "scripts/invoke.py --web --host 0.0.0.0 --root ${INVOKEAI_ROOT}"
4238

39+
# Run the cli with the runtime dir mounted
4340
cli:
4441
docker run --rm -it --runtime=nvidia --gpus=all \
45-
-v ${INVOKEAI_CACHEDIR}:${INVOKEAI_ROOT} \
46-
-v ${INVOKEAI_CACHEDIR}/.cache:/root/.cache \
42+
-v ${HOST_MOUNT_PATH}:${INVOKEAI_ROOT} \
43+
-v ${HOST_MOUNT_PATH}/.cache:/root/.cache \
44+
-e INVOKEAI_ROOT=${INVOKEAI_ROOT} \
4745
--entrypoint bash ${IMAGE} \
4846
-c "scripts/invoke.py --root ${INVOKEAI_ROOT}"
4947

5048
# Run the container with the cache mounted and open a bash shell instead of the Invoke CLI or webserver
5149
shell:
5250
docker run --rm -it --runtime=nvidia --gpus=all \
53-
-v ${INVOKEAI_CACHEDIR}:${INVOKEAI_ROOT} \
54-
-v ${INVOKEAI_CACHEDIR}/.cache:/root/.cache \
51+
-v ${HOST_MOUNT_PATH}:${INVOKEAI_ROOT} \
52+
-v ${HOST_MOUNT_PATH}/.cache:/root/.cache \
5553
-e INVOKEAI_ROOT=${INVOKEAI_ROOT} \
5654
--entrypoint bash ${IMAGE} --
5755

0 commit comments

Comments
 (0)