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

This commit is contained in:
cmdr2 2022-08-26 21:04:55 +05:30
parent f526b2df94
commit 96e4a4ae03
6 changed files with 54 additions and 8 deletions

View File

@ -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"]
ENTRYPOINT ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0", "--port", "9000"]

15
OldPortDockerfile Normal file
View File

@ -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"]

View File

@ -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`.

View File

@ -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:

20
old_port_main.py Normal file
View File

@ -0,0 +1,20 @@
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
app = FastAPI()
@app.get('/', response_class=HTMLResponse)
def read_root():
return '''
<style>
body {
font-family: Arial;
font-size: 11pt;
}
</style>
<h4>The UI has moved to <a href="http://localhost:9000">http://localhost:9000</a>. The current address that you used (ending with :8000) will be removed in the future, so please use <a href="http://localhost:9000">http://localhost:9000</a> going ahead (and in any bookmarks you've saved).</h4>
<h3>Why has the address changed?</h3>
<p>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.</p>
<p>Sorry about this, and apologies for the inconvenience :)</p>
'''

3
server
View File

@ -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() {