kevinthedang / discord-ollama

Discord Bot that utilizes Ollama to interact with any Large Language Models to talk with users and allow them to host/create their own models.
Creative Commons Attribution 4.0 International
72 stars 6 forks source link

Reduce/Cleanup Script Clutter #87

Closed kevinthedang closed 1 week ago

kevinthedang commented 1 month ago

Issue

There are a lot of scripts in package.json and it would be nice if we just had less more concise scripts to run so there is no need for large scripts to type in.

Solution

References

{
  "name": "discord-ollama",
  "version": "0.5.5",
  "description": "Ollama Integration into discord",
  "main": "build/index.js",
  "exports": "./build/index.js",
  "scripts": {
    "dev-tsx": "tsx watch src/index.ts",
    "dev-mon": "nodemon --config nodemon.json src/index.ts",
    "build": "tsc",
    "test:run": "vitest run",
    "test:coverage": "vitest run --coverage",
    "prod": "node .",
    "client": "npm run build && npm run prod",
    "clean": "docker compose down && docker rmi $(docker images | grep $(node -p \"require('./package.json').version\") | tr -s ' ' | cut -d ' ' -f 3) && docker rmi $(docker images --filter \"dangling=true\" -q --no-trunc)",
    "start": "docker compose build --no-cache && docker compose up -d",
    "docker:start": "npm run docker:network && npm run docker:build && npm run docker:client && npm run docker:ollama",
    "docker:start-cpu": "npm run docker:network && npm run docker:build && npm run docker:client && npm run docker:ollama-cpu",
    "docker:clean": "docker rm -f discord && docker rm -f ollama && docker rmi $(docker images --filter \"dangling=true\" -q --no-trunc)",
    "docker:network": "docker network create --subnet=172.18.0.0/16 ollama-net",
    "docker:build": "docker build --no-cache -t discord/bot:$(node -p \"require('./package.json').version\") .",
    "docker:test": "docker run -d --rm -v discord:/src/app --name test discord/bot:$(node -p \"require('./package.json').version\") npm run test:run",
    "docker:client": "docker run -d -v discord:/src/app --name discord --network ollama-net --ip 172.18.0.3 discord/bot:$(node -p \"require('./package.json').version\")",
    "docker:ollama": "docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama --network ollama-net --ip 172.18.0.2 ollama/ollama:latest",
    "docker:ollama-cpu": "docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama --network ollama-net --ip 172.18.0.2 ollama/ollama:latest"
  },
  "other truncated stuff": { }
}
JT2M0L3Y commented 1 month ago

@kevinthedang I think this issue (i.e., cleaning docker deployment/delivery stuff out of node configuration) may require the success of #61 so that these commands can be documented for developers, but not accessible unless run manually on command line for whatever deployment purpose necessary.

kevinthedang commented 1 month ago

@JT2M0L3Y

The intended purpose of #61 is to deploy the docker image through some kind of .yml file that will allow it to push to some registry.

I am unfamiliar with the possibility of creating manually run GitHub pipelines but I know they are possible in GitLab.

In my (10 seconds of) research, it looks like some pipeline needs workflow_dispatch to be manually run. Ideally, this pipeline should be created in master and can only be dispatched by users with privilege to the repository.

What I am getting at is that we do not need to rely on #61 for this issue. Let me know what you think.

Resources

JT2M0L3Y commented 1 month ago

@kevinthedang

We should aim to remove the docker environment setup from the package.json as it blends deployment and configuration together.

What I mean is, to remove the "clutter" from the scripts commands, we require another method of providing the docker environment (publishing the docker environment instead). In this way, we protect the docker compose process from modification.

It may not be directly dependent, but #61 is still related to this issue.