Skip to content

Commit

Permalink
fix: Update docker compose for sd and llm
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro-v committed Aug 30, 2023
1 parent dd8ecba commit 858c872
Showing 1 changed file with 56 additions and 33 deletions.
89 changes: 56 additions & 33 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ services:
timeout: 10s
retries: 5
start_period: 5s

networks:
jan_community:
ipv4_address: 172.20.0.14
Expand All @@ -152,59 +151,83 @@ services:
jan_community:
ipv4_address: 172.20.0.15

# Service to download a model file.
downloader:
image: busybox
# The command extracts the model filename from MODEL_URL and downloads it if it doesn't exist.
command: /bin/sh -c "LLM_MODEL_FILE=$(basename ${MODEL_URL}); if [ ! -f /models/$LLM_MODEL_FILE ]; then wget -O /models/$LLM_MODEL_FILE ${MODEL_URL}; fi"
# Mount a local directory to store the downloaded model.
# Service to run the Llama web application.
llm:
image: ghcr.io/abetlen/llama-cpp-python@sha256:b6d21ff8c4d9baad65e1fa741a0f8c898d68735fff3f3cd777e3f0c6a1839dd4
# Mount the directory that contains the downloaded model.
volumes:
- ./jan-inference/llm/models:/models

ports:
- 8000:8000
environment:
# Specify the path to the model for the web application.
MODEL: /models/${LLM_MODEL_FILE}
PYTHONUNBUFFERED: 1
# Restart policy configuration
restart: on-failure
# Specifies that this service should start only after wait-for-downloader has completed successfully.
networks:
jan_community:
ipv4_address: 172.20.0.16
ipv4_address: 172.20.0.18

# Service to wait for the downloader service to finish downloading the model.
wait-for-downloader:
image: busybox
# The command waits until the model file (specified in MODEL_URL) exists.
command: /bin/sh -c "LLM_MODEL_FILE=$(basename ${MODEL_URL}); echo 'Waiting for downloader to finish'; while [ ! -f /models/$LLM_MODEL_FILE ]; do sleep 1; done; echo 'Model downloaded!'"
# Specifies that this service should start after the downloader service has started.
depends_on:
downloader:
condition: service_started
# Mount the same local directory to check for the downloaded model.
sd-downloader:
build:
context: ./jan-inference/sd/
dockerfile: compile.Dockerfile
# The command extracts the model filename from MODEL_URL and downloads it if it doesn't exist.
command: /bin/sh -c "if [ ! -f /models/*.bin ]; then python /sd.cpp/sd_cpp/models/convert.py --out_type q4_0 --out_file /models/${SD_MODEL_FILE}.q4_0.bin /models/${SD_MODEL_FILE}; fi"
# Mount a local directory to store the downloaded model.
volumes:
- ./jan-inference/llm/models:/models

- ./jan-inference/sd/models:/models
networks:
jan_community:
ipv4_address: 172.20.0.17
ipv4_address: 172.20.0.19

# Service to run the Llama web application.
llm:
image: ghcr.io/abetlen/llama-cpp-python:latest
# Service to run the SD web application.
sd:
build:
context: ./jan-inference/sd/
dockerfile: inference.Dockerfile
# Mount the directory that contains the downloaded model.
volumes:
- ./jan-inference/llm/models:/models
ports:
- 8000:8000
- ./jan-inference/sd/models:/models
- ./jan-inference/sd/output/:/serving/output
command: /bin/bash -c "python -m uvicorn main:app --proxy-headers --host 0.0.0.0 --port 8000"
environment:
# Specify the path to the model for the web application.
MODEL: /models/llama-2-7b-chat.ggmlv3.q4_1.bin
BASE_URL: http://0.0.0.0:8000
MODEL_NAME: ${SD_MODEL_FILE}.q4_0.bin
MODEL_DIR: "/models"
SD_PATH: "/sd"
PYTHONUNBUFFERED: 1
ports:
- 8001:8000
# Restart policy configuration
restart: on-failure
# Specifies that this service should start only after wait-for-downloader has completed successfully.
depends_on:
wait-for-downloader:
sd-downloader:
condition: service_completed_successfully
# Connect this service to two networks: inference_net and traefik_public.

networks:
jan_community:
ipv4_address: 172.20.0.18
ipv4_address: 172.20.0.21

# Service for Traefik, a modern HTTP reverse proxy and load balancer.
# traefik:
# image: traefik:v2.10
# ports:
# # Map port 80 in the container to port 80 on the host.
# - "80:80"
# # Map port 8080 in the container (Traefik's dashboard) to port 8080 on the host.
# - "8080:8080"
# # Mount the Docker socket to allow Traefik to listen to Docker's API.
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock:ro
# - ./traefik/traefik.yml:/traefik.yml:ro
# - ./traefik/config.yml:/config.yml:ro
# networks:
# jan_community:
# ipv4_address: 172.20.0.22

networks:
jan_community:
Expand Down

0 comments on commit 858c872

Please sign in to comment.