From d9febeef0fc796b9de75db2d2fed3d364eafefa8 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 23 Oct 2025 09:39:21 -0700 Subject: [PATCH] cleanupX2 --- Dockerfile | 30 ++++++++++++++++++++---------- compose.yaml | 23 ++++++++++++++++++++--- script/docker/compose.yaml | 5 ++++- script/docker/ollama-entrypoint.sh | 4 ++-- 4 files changed, 46 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index b34222b..b778755 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,31 @@ FROM python:3.13-slim -ENV PYTHONUNBUFFERED=1 -RUN apt-get update && apt-get install -y gettext tzdata locales nano && rm -rf /var/lib/apt/lists/* +ENV PYTHONUNBUFFERED=1 \ + LANG=en_US.UTF-8 \ + LANGUAGE=en_US:en \ + LC_ALL=en_US.UTF-8 \ + TZ=America/Los_Angeles -# Set the locale default to en_US.UTF-8 -RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ - dpkg-reconfigure --frontend=noninteractive locales && \ - update-locale LANG=en_US.UTF-8 -ENV LANG="en_US.UTF-8" -ENV TZ="America/Los_Angeles" +RUN apt-get update && \ + apt-get install -y gettext tzdata locales nano && \ + sed -i 's/^# *\(en_US.UTF-8 UTF-8\)/\1/' /etc/locale.gen && \ + locale-gen en_US.UTF-8 && \ + rm -rf /var/lib/apt/lists/* WORKDIR /app + +# Install dependencies first for better caching +COPY requirements.txt /app/ +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application COPY . /app COPY config.template /app/config.ini -RUN pip install -r requirements.txt - RUN chmod +x /app/script/docker/entrypoint.sh +# Add a non-root user and switch to it +RUN useradd -m appuser +USER appuser + ENTRYPOINT ["/bin/bash", "/app/script/docker/entrypoint.sh"] diff --git a/compose.yaml b/compose.yaml index f25a7c0..d770b39 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,3 +1,6 @@ +# Docker Compose configuration for Meshing Around. +# This setup includes the main Meshing Around service, with optional Ollama and Prometheus Node Exporter services. +# Adjust device mappings, ports, and configurations as needed for your environment. services: meshing-around: stdin_open: true @@ -5,10 +8,18 @@ services: ports: - 8420:8420 devices: # Optional if using meshtasticd. Pass through radio device. - - /dev/ttyUSB0 + - /dev/ttyUSB0 # Replace this with your actual device! + #- /dev/ttyAMA0 # Example volumes: - /data/meshing-around/config.ini:/app/config.ini:rw image: ghcr.io/SpudGunMan/meshing-around:test-all-changes + container_name: meshing-around + restart: unless-stopped + environment: + - OLLAMA_API_URL=http://ollama:11434 + extra_hosts: + #- "host.docker.internal:host-gateway" # Enables access to host services from within the container. + user: "1000:1000" # run as non-root user for better security meshtasticd: # Runs a virtual node. Optional, but can be used to link meshing-around directly to mqtt. ports: @@ -19,8 +30,14 @@ services: ollama: # Used for enabling LLM interactions. ports: - - 11434:11434 + - 11434:11434 # Ollama API port volumes: - /data/ollama:/root/.ollama container_name: ollama - image: alpine/ollama \ No newline at end of file + image: ollama/ollama:latest + restart: unless-stopped + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:11434/api/tags"] + interval: 30s + timeout: 10s + retries: 5 \ No newline at end of file diff --git a/script/docker/compose.yaml b/script/docker/compose.yaml index 45569d3..9c24ca5 100644 --- a/script/docker/compose.yaml +++ b/script/docker/compose.yaml @@ -1,4 +1,4 @@ -# Docker Compose configuration for Meshing Around application with optional services. +# OLD Docker Compose configuration for Meshing Around application with optional services. # This setup includes the main Meshing Around service, with optional Ollama and Prometheus Node Exporter services. # Adjust device mappings, ports, and configurations as needed for your environment. @@ -14,6 +14,9 @@ services: configs: - source: me_config target: /app/config.ini + devices: # Optional if using meshtasticd. Pass through radio device. + - /dev/ttyAMA10 # Replace this with your actual device! + #- /dev/ttyUSB0 # Example for USB device user: 1000:1000 # run as non-root user for better security. extra_hosts: # - "host.docker.internal:host-gateway" # Enables access to host services from within the container. diff --git a/script/docker/ollama-entrypoint.sh b/script/docker/ollama-entrypoint.sh index ced1718..5af322c 100644 --- a/script/docker/ollama-entrypoint.sh +++ b/script/docker/ollama-entrypoint.sh @@ -8,8 +8,8 @@ pid=$! # Pause for Ollama to start. sleep 5 -echo "🔴 Retrieve llama3.2:3b model..." -ollama pull llama3.2:3b +echo "🔴 Retrieve gemma3:270m model..." +ollama pull gemma3:270m echo "🟢 Done!" # Wait for Ollama process to finish.