Skip to content

Commit

Permalink
feat: Add a local llm service to docker-compose.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mxxntype committed May 22, 2024
1 parent 15bec45 commit 334c035
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export REDIS_PORT="6379"
# Server.
export SERVER_PORT="9001"

# Local LLM.
export LLM_PORT="11434"

# A complete URLs for future use.
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:localhost/${POSTGRES_DB}"
export DOCKER_DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${PGPORT}/${POSTGRES_DB}"
Expand Down
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ precommit:
# Redeploy all services, rebuilding `server` and `sqlrunner`.
deploy:
docker compose down
docker compose up --detach --build server postgresql pgadmin
docker compose up --detach --build server postgresql pgadmin llm

# Redeploy a new version of a container.
redeploy CONTAINER:
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ services:
depends_on:
- postgresql

llm:
image: ollama/ollama:latest
hostname: llm
restart: unless-stopped
container_name: ollama
tty: true
ports:
- "${LLM_PORT}:${LLM_PORT}"
volumes:
- ollama:/root/.ollama

llm-setup:
build:
context: .
dockerfile: llm/Dockerfile
restart: unless-stopped
env_file:
- .envrc

volumes:
postgresql-data:
pgadmin-data:
ollama:
5 changes: 5 additions & 0 deletions llm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM alpine/curl

COPY . .

ENTRYPOINT ["curl", "http://llm:11434/api/pull", "-d", "@llm/req.json", "--header", "Content-Type: application/json"]
3 changes: 3 additions & 0 deletions llm/req.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"model": "llama3"
}
1 change: 1 addition & 0 deletions server/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl Authenticator {

impl Interceptor for Authenticator {
fn call(&mut self, mut request: Request<()>) -> Result<Request<()>, Status> {
dbg!(&request);
let auth_pair: AuthPair = request.get_auth_pair().map_err(|_| unauthenticated())?;
let user_uuid: Uuid = auth_pair
.user_uuid
Expand Down
3 changes: 3 additions & 0 deletions shells/default/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ pkgs.mkShell {
PROTOC = "${pkgs.protobuf}/bin/protoc";
PROTOC_INCLUDE = "${pkgs.protobuf}/include";

nativeBuildInputs = with pkgs; [ pkg-config ];

buildInputs = with pkgs; [
protobuf # Protocol Buffers, Google's data interchange format.
grpcurl # Command-line tool for interacting with gRPC servers.
bloomrpc # GUI Client for gRPC Services (like Postman).
postgresql
openssl.dev
];
}

0 comments on commit 334c035

Please sign in to comment.