More docker compose improvements (#268)

For me GPU0 is a 3080 and GPU1 is a 4090 while others may only have one
GPU. So let us make gpu 0 the default.

Also I found a better way to build the containers and added a
cloudflared tunnel container
This commit is contained in:
magic.chen 2023-06-26 15:23:03 +08:00 committed by GitHub
commit 7d7452ac95
5 changed files with 34 additions and 36 deletions

View File

@ -1 +1,2 @@
models/ models/
plugins/

4
.gitignore vendored
View File

@ -28,7 +28,9 @@ sdist/
var/ var/
wheels/ wheels/
models/* models/
plugins/
pip-wheel-metadata/ pip-wheel-metadata/
share/python-wheels/ share/python-wheels/
*.egg-info/ *.egg-info/

View File

@ -1,23 +1,23 @@
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
WORKDIR /app
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \ git \
python3 \ python3 \
pip pip
WORKDIR /app
COPY . /app
# upgrade pip # upgrade pip
RUN pip3 install --upgrade pip RUN pip3 install --upgrade pip
COPY ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
RUN python3 -m spacy download zh_core_web_sm RUN python3 -m spacy download zh_core_web_sm
EXPOSE 7860
CMD ["python3", "pilot/server/webserver.py"] COPY . /app
EXPOSE 7860
EXPOSE 8000

View File

@ -1,21 +0,0 @@
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
RUN apt-get update && apt-get install -y \
git \
python3 \
pip
WORKDIR /app
COPY . /app
# upgrade pip
RUN pip3 install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8000
CMD ["python3", "pilot/server/llmserver.py"]

View File

@ -16,11 +16,16 @@ services:
webserver: webserver:
build: build:
context: . context: .
dockerfile: Dockerfile-webserver dockerfile: Dockerfile
command: python3 pilot/server/webserver.py
environment: environment:
- MODEL_SERVER=http://llmserver:8000 - MODEL_SERVER=http://llmserver:8000
- LOCAL_DB_HOST=db - LOCAL_DB_HOST=db
- WEB_SERVER_PORT=7860 - WEB_SERVER_PORT=7860
- ALLOWLISTED_PLUGINS=db_dashboard
depends_on:
- db
- llmserver
volumes: volumes:
- ./models:/app/models - ./models:/app/models
- ./plugins:/app/plugins - ./plugins:/app/plugins
@ -28,16 +33,19 @@ services:
env_file: env_file:
- .env.template - .env.template
ports: ports:
- 7860:7860 - 7860:7860/tcp
expose: expose:
- 7860 - 7860/tcp
restart: unless-stopped restart: unless-stopped
llmserver: llmserver:
build: build:
context: . context: .
dockerfile: Dockerfile-llmserver dockerfile: Dockerfile
command: python3 pilot/server/llmserver.py
environment: environment:
- LOCAL_DB_HOST=db - LOCAL_DB_HOST=db
depends_on:
- db
volumes: volumes:
- ./models:/app/models - ./models:/app/models
env_file: env_file:
@ -50,9 +58,17 @@ services:
reservations: reservations:
devices: devices:
- driver: nvidia - driver: nvidia
device_ids: ['1'] device_ids: ['0']
capabilities: [gpu] capabilities: [gpu]
tunnel:
image: cloudflare/cloudflared:latest
container_name: cloudflared-tunnel
restart: unless-stopped
environment:
- TUNNEL_URL=http://webserver:7860
command: tunnel --no-autoupdate
depends_on:
- webserver
volumes: volumes: