From 908b1c39db7c99be7aedbf38f838fc61f2a838b5 Mon Sep 17 00:00:00 2001 From: Michael Gillett <51103663+migillett@users.noreply.github.com> Date: Sun, 1 Mar 2026 16:18:50 -0500 Subject: [PATCH] instructions for config.yaml rework of docker its ALIVE disable :ro tag for config.yaml leave empty line lets open ports instead of network mode host run as current user run as user nevermind update readme with instructions relocate docker section --- README.md | 17 +++++++---- docker-compose.yml | 15 +++++----- dockerfile | 71 ++++++++++++++++++---------------------------- 3 files changed, 45 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index d4066da..b343763 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,17 @@ This script will: The script will prompt you for each optional removal step. +## Docker + +You can now run PyMC Repeater from within a [Docker Container](https://www.docker.com/). Checkout the example [Docker Compose](./docker-compose.yml) file for an example. + +```bash +docker compose up -d --force-recreate --build +``` + +Just note that you will have to pass in a `config.yaml` into the container. You can create a new config by following the instructions in the [Configuration section](#configuration). + + ## Roadmap / Planned Features - [ ] **Public Map Integration** - Submit repeater location and details to public map for discovery @@ -249,12 +260,6 @@ Pre-commit hooks will automatically: - Lint with flake8 - Fix trailing whitespace and other file issues -## Docker - -```bash -docker build -t pymc:latest . --platform linux/arm/v7 -``` - ## Support - [Core Lib Documentation](https://rightup.github.io/pyMC_core/) diff --git a/docker-compose.yml b/docker-compose.yml index b2d0009..f65a1de 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,14 +3,13 @@ services: build: . container_name: pymc-repeater restart: unless-stopped + ports: + - 8000:8000 devices: - /dev/spidev0.0 - - /dev/spidev0.1 + - /dev/gpiochip0 + cap_add: + - SYS_RAWIO volumes: - - ./config.yaml:/etc/pymc_repeater/config.yaml:ro - - pymc_data:/var/lib/pymc_repeater - ports: - - "8000:8000" - -volumes: - pymc_data: + - ./config.yaml:/etc/pymc_repeater/config.yaml + - ./data:/var/lib/pymc_repeater diff --git a/dockerfile b/dockerfile index 807f7b0..8d3689f 100644 --- a/dockerfile +++ b/dockerfile @@ -1,52 +1,35 @@ -# --------------------------- -# Builder stage -# --------------------------- -FROM python:3.11-alpine AS builder +FROM python:3.12-slim-bookworm -WORKDIR /build +ENV INSTALL_DIR=/opt/pymc_repeater \ + CONFIG_DIR=/etc/pymc_repeater \ + DATA_DIR=/var/lib/pymc_repeater \ + PYTHONUNBUFFERED=1 \ + SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER=1.0.5 -# Build dependencies -RUN apk add --no-cache \ - build-base \ - linux-headers \ - python3-dev +# Install runtime dependencies only +RUN apt-get update && apt-get install -y \ + libffi-dev \ + python3-rrdtool \ + jq \ + wget \ + swig \ + git \ + build-essential \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* -COPY pyproject.toml . +# Create runtime directories +RUN mkdir -p ${INSTALL_DIR} ${CONFIG_DIR} ${DATA_DIR} + +WORKDIR ${INSTALL_DIR} + +# Copy source COPY repeater ./repeater +COPY pyproject.toml . -# Build wheels (including spidev) -RUN pip wheel --no-cache-dir --wheel-dir /wheels . - -# --------------------------- -# Runtime stage -# --------------------------- -FROM python:3.11-alpine - -ENV PYTHONUNBUFFERED=1 \ - CONFIG_PATH=/etc/pymc_repeater/config.yaml - -ARG UID=10001 -ARG GID=10001 - -# Create non-root user -RUN addgroup -g ${GID} repeater && \ - adduser -D -u ${UID} -G repeater repeater - -WORKDIR /opt/pymc_repeater - -# Copy wheels from builder -COPY --from=builder /wheels /wheels - -# Install from wheels only -RUN pip install --no-cache-dir /wheels/* && \ - rm -rf /wheels - -# Config directory -RUN mkdir -p /etc/pymc_repeater && \ - chown -R ${UID}:${GID} /etc/pymc_repeater - -USER ${UID}:${GID} +# Install package +RUN pip install --no-cache-dir . EXPOSE 8000 -ENTRYPOINT ["/bin/sh", "-c", "test -f ${CONFIG_PATH} || (echo 'Missing config.yaml' && exit 1); exec python3 -m repeater --config ${CONFIG_PATH}"] +ENTRYPOINT ["python3", "-m", "repeater.main", "--config", "/etc/pymc_repeater/config.yaml"]