diff --git a/examples/docker-compose/README.md b/examples/docker-compose/README.md new file mode 100644 index 00000000..7ee53da2 --- /dev/null +++ b/examples/docker-compose/README.md @@ -0,0 +1,41 @@ +# Ollama Service + +This Docker Compose setup deploys the Ollama service, using the main ollama image hosted on dockerhub. Ollama is designed to run seamlessly in a Docker environment, with health checks and volume management. + +## Prerequisites + +- Docker +- Docker Compose + +Ensure Docker and Docker Compose are installed and up-to-date on your system. + +## Configuration + +The service configuration is managed through the `docker-compose.yaml` file and environment variables. You can customize the Ollama service port by setting the `OLLAMA_PORT` environment variable; if not set, it defaults to 11434. + +## Getting Started + +1. **Run:** To start the Ollama service run: +```bash + docker-compose up -d +``` + +2. **Build and Run:** To build the project and start the Ollama service, run: +```bash + docker-compose up --build +``` + +## NOTES: + +1. Health Check: The service includes a health check that verifies the application's ability to accept connections on port 11434 (or a custom port if OLLAMA_PORT is set). + +2. Accessing Ollama: Once running, Ollama is accessible on localhost at the port specified by OLLAMA_PORT or the default 11434. + +3. Volumes: To persist data, the setup mounts a volume from ./ollama to /root/.ollama within the container. + +4. Stopping the Service: To stop and remove the Ollama container, use: + +```bash + docker-compose down +``` + diff --git a/examples/docker-compose/docker-compose.yaml b/examples/docker-compose/docker-compose.yaml new file mode 100644 index 00000000..9b295f4a --- /dev/null +++ b/examples/docker-compose/docker-compose.yaml @@ -0,0 +1,17 @@ +version: "3.8" + +services: + ollama: + build: + context: ../.. + dockerfile: Dockerfile + container_name: ollama + image: ollama/ollama + healthcheck: + test: ["CMD-SHELL", "/usr/bin/bash -c 'cat < /dev/null > /dev/tcp/localhost/11434 || exit 1'"] + interval: 10s + ports: + - "${OLLAMA_PORT:-11434}:11434" + volumes: + - ./ollama:/root/.ollama + restart: on-failure