From 96e4a4ae03f5f5c41e508f77251a9604e8a57d21 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 26 Aug 2022 21:04:55 +0530 Subject: [PATCH] Switch to port 9000, and post a redirection notice at port 8000. This avoids a port conflicts since port 8000 is often used by other servers, and hopefully avoids a common source of new-user issues in the future --- Dockerfile | 4 ++-- OldPortDockerfile | 15 +++++++++++++++ README.md | 8 ++++---- docker-compose.yml | 12 +++++++++++- old_port_main.py | 20 ++++++++++++++++++++ server | 3 ++- 6 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 OldPortDockerfile create mode 100644 old_port_main.py diff --git a/Dockerfile b/Dockerfile index 8d834a32..01014ae5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,6 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . -EXPOSE 8000 +EXPOSE 9000 -ENTRYPOINT ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0"] \ No newline at end of file +ENTRYPOINT ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0", "--port", "9000"] \ No newline at end of file diff --git a/OldPortDockerfile b/OldPortDockerfile new file mode 100644 index 00000000..22990ee2 --- /dev/null +++ b/OldPortDockerfile @@ -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", "old_port_main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file diff --git a/README.md b/README.md index 73af3861..7cb5360b 100644 --- a/README.md +++ b/README.md @@ -28,14 +28,14 @@ All the processing will happen on your computer locally, it does not transmit yo # Installation 1. Clone this repository: `git clone https://github.com/cmdr2/stable-diffusion-ui.git` or [download the zip file](https://github.com/cmdr2/stable-diffusion-ui/archive/refs/heads/main.zip) and unzip. 2. Open your terminal, and in the project directory run: `./server` (warning: this will take some time during the first run, since it'll download Stable Diffusion's [docker image](https://replicate.com/stability-ai/stable-diffusion), nearly 17 GiB) -3. Open http://localhost:8000 in your browser. That's it! +3. Open http://localhost:9000 in your browser. That's it! If you're getting errors, please check the [Troubleshooting](#troubleshooting) section below. To stop the server, please run `./server stop` # Usage -Open http://localhost:8000 in your browser (after running `./server` from step 2 previously). +Open http://localhost:9000 in your browser (after running `./server` from step 2 previously). ## With a text description 1. Enter a text prompt, like `a photograph of an astronaut riding a horse` in the textbox. @@ -73,8 +73,8 @@ Please ensure you have `docker-compose` version 1.29 or higher. Check `docker-co ## RuntimeError: Found no NVIDIA driver on your system: If you have an NVIDIA GPU and the latest [NVIDIA driver](http://www.nvidia.com/Download/index.aspx), please ensure that you've installed [nvidia-container-toolkit](https://stackoverflow.com/a/58432877). (Thanks [u/exintrovert420](https://www.reddit.com/user/exintrovert420/)) -## Some other process is already running at port 8000 / port 8000 could not be bound -You can override the port used. Please change `docker-compose.yml` inside the project directory, and update the line `8000:8000` to `1337:8000` (or where 1337 is whichever port number you want). +## Some other process is already running at port 9000 / port 9000 could not be bound +You can override the port used. Please change `docker-compose.yml` inside the project directory, and update the line `9000:9000` to `1337:9000` (where 1337 is whichever port number you want). After doing this, please restart your server, by running `./server restart`. diff --git a/docker-compose.yml b/docker-compose.yml index f1703810..018a31e6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: stable-diffusion-ui: container_name: sd-ui ports: - - '8000:8000' + - '9000:9000' build: context: . dockerfile: Dockerfile @@ -24,5 +24,15 @@ services: depends_on: - stability-ai + stable-diffusion-old-port-redirect: + container_name: sd-old-port-redirect + ports: + - '8000:8000' + build: + context: . + dockerfile: OldPortDockerfile + volumes: + - .:/app + networks: default: \ No newline at end of file diff --git a/old_port_main.py b/old_port_main.py new file mode 100644 index 00000000..db3b461e --- /dev/null +++ b/old_port_main.py @@ -0,0 +1,20 @@ +from fastapi import FastAPI +from fastapi.responses import HTMLResponse + +app = FastAPI() + +@app.get('/', response_class=HTMLResponse) +def read_root(): + return ''' + +

The UI has moved to http://localhost:9000. The current address that you used (ending with :8000) will be removed in the future, so please use http://localhost:9000 going ahead (and in any bookmarks you've saved).

+ +

Why has the address changed?

+

The previously used port (8000) is often used by other servers, which results in port conflicts. So the project's port number has been changed, while the project is still young. Otherwise port-conflicts with 8000 will be a common source of new-user issues in the future.

+

Sorry about this, and apologies for the inconvenience :)

+ ''' diff --git a/server b/server index a0d50cfe..e108030d 100755 --- a/server +++ b/server @@ -6,7 +6,8 @@ if [ -z "$1" ]; then fi start_server() { - docker-compose up & + docker-compose up -d stable-diffusion-old-port-redirect > /dev/null 2>&1 # old port 8000 server, show redirect notice + docker-compose up stability-ai stable-diffusion-ui & } stop_server() {