Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ENOTEMPTY and add Dockerfile + docker-compose #223

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM node:18-buster-slim

ARG MODEL_NAME=alpaca
ARG MODEL_VERSION=7B

EXPOSE 3000

RUN apt-get update \
&& apt-get install -y \
build-essential \
curl \
g++ \
make \
python3-venv \
software-properties-common

RUN apt-get update

COPY . .
WORKDIR /root/

# Install dalai and its dependencies
RUN npm install

# # Install a model
RUN npx dalai ${MODEL_NAME} install ${MODEL_VERSION}

# # Run the dalai server
ENTRYPOINT [ "npx", "dalai", "serve" ]
11 changes: 11 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.9'

services:
serve-dalai-7b:
build:
context: .
args:
MODEL_NAME: alpaca
MODEL_VERSION: 7B
ports:
- "3000:3000"
19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,20 @@ class Dalai {

// temporary

let models_path = path.resolve(engine.home, "models")
let temp_path = path.resolve(this.home, "tmp")
let temp_models_path = path.resolve(temp_path, "models")
await fs.promises.mkdir(temp_path, { recursive: true }).catch((e) => { })
let models_path = path.resolve(engine.home, "models");
await fs.promises.mkdir(models_path, { recursive: true }).catch((e) => { });
let temp_path = path.resolve(this.home, "tmp");
let temp_models_path = path.resolve(temp_path, "models");
await fs.promises.mkdir(temp_path, { recursive: true }).catch((e) => { });
// 1. move the models folder to ../tmp
await fs.promises.rename(models_path, temp_models_path)
await fs.promises.rename(models_path, temp_models_path);
// 2. wipe out the folder
await fs.promises.rm(engine.home, { recursive: true }).catch((e) => { console.log(e) })
await fs.promises.rm(models_path, { recursive: true }).catch((e) => { console.log(e) });
// 3. install engine
await this.add(core)
await this.add(core);
// 4. move back the files inside /tmp
await fs.promises.rename(temp_models_path, models_path)

await fs.promises.rename(temp_models_path, models_path);
// next add the models
let res = await this.cores[core].add(...models)
return res
Expand Down