From 0ccfa3dba9ac2cbbb7746e1e6a427177edcc5576 Mon Sep 17 00:00:00 2001 From: oc013 <101832295+oc013@users.noreply.github.com> Date: Wed, 24 Aug 2022 09:51:56 -0400 Subject: [PATCH] Create docker-compose for ui and ai --- Dockerfile | 15 +++++++++++++++ docker-compose.yml | 28 ++++++++++++++++++++++++++++ index.html | 3 ++- main.py | 2 +- requirements.txt | 3 +++ server.sh | 0 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 requirements.txt mode change 100644 => 100755 server.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..8d834a32 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.9 + +RUN mkdir /app +WORKDIR /app + +RUN apt update + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 8000 + +ENTRYPOINT ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..844a6373 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3.3' + +services: + stability-ai: + container_name: sd + ports: + - '5000:5000' + image: 'r8.im/stability-ai/stable-diffusion@sha256:06eb78b36068500c616a7f33c15e6fa40404f8e14b5bfad57ebe0c7fe0f6bdf1' + deploy: + resources: + reservations: + devices: + - capabilities: [gpu] + + stable-diffusion-ui: + container_name: sd-ui + ports: + - '8000:8000' + build: + context: . + dockerfile: Dockerfile + volumes: + - .:/app + depends_on: + - stability-ai + +networks: + default: \ No newline at end of file diff --git a/index.html b/index.html index 836a2e9f..6ada84f2 100644 --- a/index.html +++ b/index.html @@ -92,6 +92,7 @@ function setStatus(statusType, msg, msgType) { function playSound() { const audio = new Audio('/ding.mp3') + audio.volume = 0.2 audio.play() } @@ -171,7 +172,7 @@ async function makeImage() { console.log('request error', e) setStatus('request', 'error', 'error') } - + btn.innerHTML = 'Make Image' btn.disabled = false; diff --git a/main.py b/main.py index 68d2b809..182c78cb 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ from pydantic import BaseModel import requests -LOCAL_SERVER_URL = 'http://localhost:5000' +LOCAL_SERVER_URL = 'http://stability-ai:5000' PREDICT_URL = LOCAL_SERVER_URL + '/predictions' app = FastAPI() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..6d9c7c3f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +requests +fastapi==0.80.0 +uvicorn==0.18.2 diff --git a/server.sh b/server.sh old mode 100644 new mode 100755