From c72ee2617ed6725ad0b373f4c15b848ef6307bac Mon Sep 17 00:00:00 2001 From: Alivecow Date: Tue, 25 Feb 2025 15:51:14 +0100 Subject: [PATCH] feat: Create ollama container and pull initial image. Refs: OPS-17, OPS-12, OPS,10 --- .gitignore | 3 +++ Dockerfile | 10 +++++----- docker-compose.yml | 14 +++++++++++++- entrypoint.sh | 6 ++++++ 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 entrypoint.sh diff --git a/.gitignore b/.gitignore index 545c490..a1db2f1 100644 --- a/.gitignore +++ b/.gitignore @@ -171,3 +171,6 @@ cython_debug/ .pypirc .python-version pyrightconfig.json + +# Ollama Local Dir +ollama diff --git a/Dockerfile b/Dockerfile index a3b1136..2dba618 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,21 +3,21 @@ FROM python:3.12-alpine AS base # VENV not needed in docker container ENV POETRY_VIRTUALENVS_CREATE=false +COPY ./entrypoint.sh / + WORKDIR /app COPY . . # Install dependencies +RUN apk add curl RUN pip install poetry RUN poetry install - FROM base as dev # Expose development port EXPOSE 5000 -# Include host flag to make flask listen on all interfaces -# Otherwise it is not accessible from the outside. -CMD [ "flask", "--app", "senju/main", "run", "--debug", "--host=0.0.0.0"] - +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index a02c168..ad97378 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,22 @@ services: senju: build: - build: . + context: . target: dev ports: - "127.0.0.1:5000:5000" volumes: - .:/app + depends_on: + - ollama + + ollama: + image: docker.io/ollama/ollama + volumes: + - ./ollama:/root/.ollama + container_name: ollama + environment: + - OLLAMA_KEEP_ALIVE=24h + - OLLAMA_HOST=0.0.0.0 + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..ea3ed14 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +curl http://ollama:11434/api/pull -d '{"model": "llama3.2:1b"}' + +flask --app senju/main run --debug --host=0.0.0.0 +