Skip to content

Commit 0c0fc7d

Browse files
author
DHBaek
authored
Merge pull request #20 from ainize-team/feature/donghoon/use-docker-compose
Feature/donghoon/use docker compose
2 parents 934ce95 + c19364e commit 0c0fc7d

File tree

4 files changed

+99
-17
lines changed

4 files changed

+99
-17
lines changed

.env.sample

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
BROKER_BASE_URI=amqp://{user-name}:{password}@172.17.0.1:5674
2-
VHOST_NAME=stable-diffusion-v2
3-
DATABASE_URL={filebase-database-url}
4-
STORAGE_BUCKET={filebase-storage-bucket}
1+
BROKER_BASE_URI=amqp://<user_name>:<password>@<rabbitmq_container_name>:5672
2+
DATABASE_URL=<filebase_database_url>
3+
STORAGE_BUCKET=<filebase_storage_bucket>
54
APP_NAME=text-to-art

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,7 @@ dmypy.json
128128
# Pyre type checker
129129
.pyre/
130130

131-
env.list
131+
env.list
132+
133+
# FireBase
134+
serviceAccountKey.json

README.md

+40-12
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,47 @@
22

33
Serving Text To Image Model Using FastAPI and Celery
44

5-
## For Developers
65

7-
1. install dev package.
86

7+
## How to start
8+
### Using docker-compose(recommended)
9+
1. Create RabbitMQ and FastAPI container(refer to [TTI-FastAPI](https://github.com/ainize-team/TTI-FastAPI))
10+
11+
2. Clone repository
912
```shell
10-
pip install -r requirements.txt
11-
pip install -r requirements-dev.txt
13+
git clone https://github.com/ainize-team/TTI-Worker
14+
cd TTI-Worker
1215
```
1316

14-
2. install pre-commit.
17+
3. Edit [docker-compose.yml](./docker-compose.yml) and [.env file](./.env.sample) for your project.
18+
- Vhost for each worker is in [docker-compose.yml](./docker-compose.yml) and common RabbitMQ config is in [.env file](./.env.sample).
1519

20+
4. Run worker container
1621
```shell
17-
pre-commit install
22+
docker-compose up -d
23+
24+
# If you want to run a specific worker container, write service name.
25+
docker-compose up -d <service name>
1826
```
1927

20-
## Installation
21-
1. Run RabbitMQ image as a broker
28+
### Using docker
29+
1. Run RabbitMQ comtainer as a broker
2230
```shell
23-
docker run -d --name tti-rabbitmq -p 5672:5672 -p 8080:15672 --restart=unless-stopped rabbitmq:3.9.21-management
31+
docker run -d --name tti-rabbitmq -p 5672:5672 -p 15672:15672 --restart=unless-stopped rabbitmq:3.11.2-management
2432
```
2533

26-
2. Build docker image
34+
2. Clone repository
2735
```shell
28-
git clone https://github.com/ainize-team/TTI-Worker.git
36+
git clone https://github.com/ainize-team/TTI-Worker
2937
cd TTI-Worker
38+
```
39+
40+
3. Build docker image
41+
```shell
3042
docker build -t tti-worker .
3143
```
3244

33-
3. Run docker image
45+
4. Create docker container
3446
```shell
3547
docker run -d --name <worker_container_name> \
3648
--gpus='"device=0"' -e BROKER_URI=<broker_uri> \
@@ -50,3 +62,19 @@ tti-worker
5062

5163
## Test with FastAPI
5264
- Check our [TTI-FastAPI](https://github.com/ainize-team/TTI-FastAPI) Repo.
65+
66+
67+
## For Developers
68+
69+
1. Install dev package
70+
71+
```shell
72+
pip install -r requirements.txt
73+
pip install -r requirements-dev.txt
74+
```
75+
76+
2. Install pre-commit
77+
78+
```shell
79+
pre-commit install
80+
```

docker-compose.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
version: '3'
2+
3+
services:
4+
stable-diffusion-v2:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
container_name: stable-diffuion-v2-worker
9+
env_file:
10+
- .env
11+
environment:
12+
- VHOST_NAME=stable-diffusion-v2
13+
volumes:
14+
- <firebase_credential_path>:/app/key
15+
- <model_local_path>:/app/model
16+
networks:
17+
- tti-fastapi_dev
18+
restart: unless-stopped
19+
deploy:
20+
resources:
21+
reservations:
22+
devices:
23+
- driver: nvidia
24+
device_ids: [<gpu_id>]
25+
capabilities: [gpu]
26+
27+
stable-diffusion-v2-1:
28+
build:
29+
context: .
30+
dockerfile: Dockerfile
31+
container_name: stable-diffuion-v2-1-worker
32+
env_file:
33+
- .env
34+
environment:
35+
- VHOST_NAME=stable-diffusion-v2-1
36+
volumes:
37+
- <firebase_credential_path>:/app/key
38+
- <model_local_path>:/app/model
39+
networks:
40+
- tti-fastapi_dev
41+
restart: unless-stopped
42+
deploy:
43+
resources:
44+
reservations:
45+
devices:
46+
- driver: nvidia
47+
device_ids: [<gpu_id>]
48+
capabilities: [gpu]
49+
50+
networks:
51+
tti-fastapi_dev:
52+
external: true

0 commit comments

Comments
 (0)