From ea6777aa7c55ecbb1c49cee6a47b0a7339fad0fe Mon Sep 17 00:00:00 2001 From: bytebone <18621898+bytebone@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:52:03 +0200 Subject: [PATCH 1/4] added docker files --- .dockerignore | 34 ++++++++++++++++++++++++++++++++++ Dockerfile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ compose.yaml | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 compose.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..5b3d79a8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,34 @@ +# Include any files or directories that you don't want to be copied to your +# container here (e.g., local build artifacts, temporary files, etc.). +# +# For more help, visit the .dockerignore file reference guide at +# https://docs.docker.com/go/build-context-dockerignore/ + +**/.DS_Store +**/__pycache__ +**/.venv +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a9ed99c4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,50 @@ +# syntax=docker/dockerfile:1 + +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Dockerfile reference guide at +# https://docs.docker.com/go/dockerfile-reference/ + +# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7 + +ARG PYTHON_VERSION=3 +FROM python:${PYTHON_VERSION}-slim as base + +# Prevents Python from writing pyc files. +ENV PYTHONDONTWRITEBYTECODE=1 + +# Keeps Python from buffering stdout and stderr to avoid situations where +# the application crashes without emitting any logs due to buffering. +ENV PYTHONUNBUFFERED=1 + +WORKDIR /app + +# Create a non-privileged user that the app will run under. +# See https://docs.docker.com/go/dockerfile-user-best-practices/ +ARG UID=10001 +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/home/appuser" \ + --shell "/sbin/nologin" \ + --uid "${UID}" \ + appuser + +# Copy the source code into the container. +COPY src/ src/ + +# Download dependencies as a separate step to take advantage of Docker's caching. +# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. +# Leverage a bind mount to requirements.txt to avoid having to copy them into +# into this layer. +RUN --mount=type=cache,target=/root/.cache/pip \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + python -m pip install -e ".[test]" --extra-index-url https://download.pytorch.org/whl/cu121 + +# Switch to the non-privileged user to run the application. +USER appuser + +# Expose the port that the application listens on. +EXPOSE 8000 + +# Run the application. +CMD invoke-train-ui --host 0.0.0.0 --port 8000 diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..a761a589 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,33 @@ +services: + server: + build: + context: . + ports: + - 8000:8000 + volumes: + - ./sample_data:/app/sample_data + - ./output:/app/output + - ./data:/home/appuser + networks: + - internal + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + + tensorboard: + build: + context: . + ports: + - 8002:8001 + volumes: + - ./output:/app/output + networks: + - internal + command: tensorboard --logdir output/ --bind_all --port 8001 + +networks: + internal: \ No newline at end of file From 01e9449fc45fbe117ff35baa62c753c9ac66f7f8 Mon Sep 17 00:00:00 2001 From: astro <18621898+bytebone@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:55:08 +0200 Subject: [PATCH 2/4] fixed minor errors --- compose.yaml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/compose.yaml b/compose.yaml index a761a589..be465201 100644 --- a/compose.yaml +++ b/compose.yaml @@ -8,8 +8,6 @@ services: - ./sample_data:/app/sample_data - ./output:/app/output - ./data:/home/appuser - networks: - - internal deploy: resources: reservations: @@ -22,12 +20,7 @@ services: build: context: . ports: - - 8002:8001 + - 8001:8001 volumes: - ./output:/app/output - networks: - - internal command: tensorboard --logdir output/ --bind_all --port 8001 - -networks: - internal: \ No newline at end of file From ea68815cfdf1b368710abfb740188108daf4f9c5 Mon Sep 17 00:00:00 2001 From: bytebone <18621898+bytebone@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:12:24 +0200 Subject: [PATCH 3/4] final corrections for docker compose --- compose.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compose.yaml b/compose.yaml index be465201..8b186f48 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,5 +1,6 @@ services: server: + image: invokeai-training build: context: . ports: @@ -17,6 +18,7 @@ services: capabilities: [gpu] tensorboard: + image: invokeai-training build: context: . ports: From 3618cde186665378c422a2ce50da3b4b1f9b5999 Mon Sep 17 00:00:00 2001 From: bytebone <18621898+bytebone@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:50:12 +0200 Subject: [PATCH 4/4] adjusted namings to align with invokeai --- .gitignore | 3 +++ .dockerignore => docker/.dockerignore | 0 Dockerfile => docker/Dockerfile | 0 compose.yaml => docker/compose.yaml | 13 ++++++++----- 4 files changed, 11 insertions(+), 5 deletions(-) rename .dockerignore => docker/.dockerignore (100%) rename Dockerfile => docker/Dockerfile (100%) rename compose.yaml => docker/compose.yaml (63%) diff --git a/.gitignore b/.gitignore index 52c2e482..a47f56de 100644 --- a/.gitignore +++ b/.gitignore @@ -169,3 +169,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +docker/output/ +docker/data/ diff --git a/.dockerignore b/docker/.dockerignore similarity index 100% rename from .dockerignore rename to docker/.dockerignore diff --git a/Dockerfile b/docker/Dockerfile similarity index 100% rename from Dockerfile rename to docker/Dockerfile diff --git a/compose.yaml b/docker/compose.yaml similarity index 63% rename from compose.yaml rename to docker/compose.yaml index 8b186f48..7909e999 100644 --- a/compose.yaml +++ b/docker/compose.yaml @@ -1,12 +1,14 @@ +name: invoke-training services: server: - image: invokeai-training + image: "local/invokeai-training:latest" build: - context: . + context: .. + dockerfile: docker/Dockerfile ports: - 8000:8000 volumes: - - ./sample_data:/app/sample_data + - ../sample_data:/app/sample_data - ./output:/app/output - ./data:/home/appuser deploy: @@ -18,9 +20,10 @@ services: capabilities: [gpu] tensorboard: - image: invokeai-training + image: "local/invokeai-training:latest" build: - context: . + context: .. + dockerfile: docker/Dockerfile ports: - 8001:8001 volumes: