From 66cf9ab33ce076cd5c137403dc23917bc9ba9e78 Mon Sep 17 00:00:00 2001 From: Camilo Giraldo Date: Wed, 29 Mar 2023 13:33:15 +1000 Subject: [PATCH 1/3] bash scripts to easily start and stop docker-compose --- Dockerfile | 16 +++++++--------- docker-compose.yml | 2 +- docs/README.md | 32 ++++++++++++++++++++++++-------- start_docker.sh | 12 ++++++++++++ stop_docker.sh | 12 ++++++++++++ 5 files changed, 56 insertions(+), 18 deletions(-) create mode 100755 start_docker.sh create mode 100755 stop_docker.sh diff --git a/Dockerfile b/Dockerfile index 0d1b3ad..8feb2f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,13 +6,13 @@ EXPOSE 3000 # Install dependencies RUN apt-get update \ && apt-get install -y \ - build-essential \ - curl \ - g++ \ - git \ - make \ - python3-venv \ - software-properties-common + build-essential \ + curl \ + g++ \ + git \ + make \ + python3-venv \ + software-properties-common # Add NodeSource PPA to get Node.js 18.x RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - @@ -28,7 +28,5 @@ RUN npm install dalai@0.3.1 RUN npx dalai alpaca setup - # Run the dalai server CMD [ "npx", "dalai", "serve" ] - diff --git a/docker-compose.yml b/docker-compose.yml index 893bdfe..68c8435 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.7' +version: '3.8' services: dalai: build: . diff --git a/docs/README.md b/docs/README.md index e236b5d..2fe0ac8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -111,18 +111,34 @@ You do NOT have to install all models, you can install one by one. Let's take a # Quickstart -## Docker compose +## Docker Compose +Requires that you have docker and docker compose installed and running. To verify this, simply run: -Requires that you have docker installed and running. -``` +- `docker version` +- `docker-compose version` + +To run dalai and alpaca, simply run: +- `./start_docker.sh` to start the container and +- Once the container is up and the model has been downloaded, access the site in the browser `http://127.0.0.1:3000/` or simply run in the terminal `open http://127.0.0.1:3000/`. +- `./stop_docker.sh`to stop the container. + +___Note 1: This will dave the models in the `./models` folder.___ + +___Note 2: You can specify a different model by modifying `docker-compose.yml`___ + +**Windows Users** + +Start Container: +```cmd docker compose build -docker compose run dalai npx dalai alpaca install 7B # or a different model -docker compose up -d +docker-compose run --rm dalai npx dalai alpaca install 7B # or a different model +docker-compose -p dalai up -d ``` -This will dave the models in the `./models` folder - -View the site at http://127.0.0.1:3000/ +Stop Container +```cmd +docker-compose -p dalai down +``` ## Mac diff --git a/start_docker.sh b/start_docker.sh new file mode 100755 index 0000000..0835cc5 --- /dev/null +++ b/start_docker.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Check if Docker is running +if ! docker info > /dev/null 2>&1; then + echo "This script uses Docker and is currently not runing, please start Docker and try again!" + exit 1 +fi + +# Start dalai alpaca 7B model +docker compose build +docker-compose run --rm dalai npx dalai alpaca install 7B # or a different model +docker-compose -p dalai up -d diff --git a/stop_docker.sh b/stop_docker.sh new file mode 100755 index 0000000..4f77ba7 --- /dev/null +++ b/stop_docker.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#Check if Docker is running +if ! docker info > /dev/null 2>&1; then + echo "This script uses Docker and is currently not runing, please start Docker and try again!" + exit 1 +else + # Start dalai alpaca 7B model + if [ $( docker ps | grep dalai | wc -l ) -gt 0 ]; then + docker-compose -p dalai down + fi +fi From 6d8ec49efb3d95276ffc545f7af1170cef29d448 Mon Sep 17 00:00:00 2001 From: Camilo Giraldo Date: Sun, 2 Apr 2023 03:26:08 +1000 Subject: [PATCH 2/3] Update start_docker.sh Co-authored-by: Tam Nguyen --- start_docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start_docker.sh b/start_docker.sh index 0835cc5..d5ecb58 100755 --- a/start_docker.sh +++ b/start_docker.sh @@ -2,7 +2,7 @@ # Check if Docker is running if ! docker info > /dev/null 2>&1; then - echo "This script uses Docker and is currently not runing, please start Docker and try again!" + echo "This script uses Docker and is currently not running, please start Docker and try again!" exit 1 fi From da3a740add4762e255eaeac4ed7598a8c69b289d Mon Sep 17 00:00:00 2001 From: Camilo Giraldo Date: Sun, 2 Apr 2023 03:27:15 +1000 Subject: [PATCH 3/3] Update stop_docker.sh --- stop_docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stop_docker.sh b/stop_docker.sh index 4f77ba7..e24192f 100755 --- a/stop_docker.sh +++ b/stop_docker.sh @@ -2,7 +2,7 @@ #Check if Docker is running if ! docker info > /dev/null 2>&1; then - echo "This script uses Docker and is currently not runing, please start Docker and try again!" + echo "This script uses Docker and is currently not running, please start Docker and try again!" exit 1 else # Start dalai alpaca 7B model