Fixed up docker-compose (#267)

You can't have two CMD statements in one Dockerfile. Each service should
have it's own container so I split webserver and llmserver into two
containers.

```
docker compose build
docker compose up
```
This commit is contained in:
magic.chen 2023-06-23 07:08:13 +08:00 committed by GitHub
commit 2f3a06011a
6 changed files with 99 additions and 29 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
models/

4
.gitignore vendored
View File

@ -25,10 +25,10 @@ lib/
lib64/
parts/
sdist/
models
var/
wheels/
models/
models/*
pip-wheel-metadata/
share/python-wheels/
*.egg-info/

View File

@ -1,21 +0,0 @@
FROM ubuntu:latest
RUN apt-get update && apt-get install -y \
git \
python3 \
pip
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
EXPOSE 3306
EXPOSE 8000
CMD ["python", "pilot/server/llmserver.py"]
CMD ["python", "pilot/server/webserver.py"]

21
Dockerfile-llmserver Normal file
View File

@ -0,0 +1,21 @@
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"]

23
Dockerfile-webserver Normal file
View File

@ -0,0 +1,23 @@
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
RUN python3 -m spacy download zh_core_web_sm
EXPOSE 7860
CMD ["python3", "pilot/server/webserver.py"]

View File

@ -1,14 +1,60 @@
version: '3.10'
services:
db-gpt:
db:
image: mysql:8.0.33
environment:
MYSQL_DATABASE: 'db'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'password'
MYSQL_ROOT_PASSWORD: 'aa123456'
ports:
- 3306:3306
volumes:
- my-db:/var/lib/mysql
restart: unless-stopped
webserver:
build:
context: .
dockerfile: Dockerfile
image: db-gpt:latest
container_name: db-gpt
dockerfile: Dockerfile-webserver
environment:
- MODEL_SERVER=http://llmserver:8000
- LOCAL_DB_HOST=db
- WEB_SERVER_PORT=7860
volumes:
- ./models:/app/models
- ./plugins:/app/plugins
- data:/app/pilot/data
env_file:
- .env.template
ports:
- 7860:7860
expose:
- 7860
restart: unless-stopped
llmserver:
build:
context: .
dockerfile: Dockerfile-llmserver
environment:
- LOCAL_DB_HOST=db
volumes:
- ./models:/app/models
env_file:
- .env.template
ports:
- 8000:8000
- 3306:3306
restart: unless-stopped
read-only: true
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ['1']
capabilities: [gpu]
volumes:
my-db:
data: