Bruno-val-bus / student-helper

0 stars 0 forks source link

Set Up

Install requirements

Running Python Models with Docker Compose

This project uses Docker and Docker Compose to manage and run the Python models along with other dependent services. Docker Compose allows you to define and run multi-container Docker applications with ease. This will enable smoother development between different components and also for building and deploying the entire system.

Getting Started

To build and run the Docker containers for the models and services, you will need docker

Using LOCAL_OLLAMA_LLAMA3 model

docker compose -f docker-compose.yaml up ollama 
docker exec -it ollama ollama run llama3:8b

After it is downloaded, you can now interact with ollama directly out of your python script. Useful for development.

Using an entirely dockerized environment

In the docker-compose.yaml file, the services are defined as follows:

services:
  student_helper_backend:
    build:
      context: .
    container_name: student_helper_server
    networks:
      - student-helper-net
    volumes:
      - ./app1_data:/app/data
    depends_on:
      - ollama

  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    ports:
      - "11434:11434"
    networks:
      - student-helper-net
    volumes:
      - /ollama:/root/.ollama

networks:
  student-helper-net:
    driver: bridge

where the student_helper_server is the build docker container from our setup in .\Dockerfile.

Build the Docker Images:

First, navigate to the project directory.

Use the following command in the CLI to start all services in detached mode. This runs the rebuilds and runs containers locally in the background, allowing you to continue using your terminal:

docker-compose up --build -d

Running the --build flag rebuilds your local python image, so that the changes you made are considered. No need to run the flag if you have not changed anything during development (i.e. you want to test the integration into another service). Running in detached mode prevents the logs of all containers from flooding your terminal. The -d flag stands for "detached mode."

View Logs for a Specific Container:

To view the logs for a specific container, use the docker logs command followed by the container name:

docker logs -f <container-name>

You can find the container names using the docker ps command, which lists all running containers:

docker ps

Stopping docker containers

docker compose down
docker container stop <container name>
docker container rm <container name>

Testing