diff --git a/README.md b/README.md index d77e60b..3d94089 100644 --- a/README.md +++ b/README.md @@ -365,7 +365,16 @@ sudo bash ./setup-radio-config.sh 4. Configure the [docker compose](./docker-compose.yml) to your specific hardware and file paths. Be sure to comment-out or delete lines that aren't required for your hardware. Please note that your hardware devices might be at a different path than those listed in the docker compose file. -5. Build and start the container. +5. If you are using SPI/GPIO hardware, make sure the `GPIO_GID` and `SPI_GID` + values match the numeric group IDs on your host. The compose file defaults + to `GPIO_GID=986` and `SPI_GID=989`. + +```bash +getent group gpio +getent group spi +``` + +6. Build and start the container. ```bash docker compose up -d --force-recreate --build diff --git a/docker-compose.yml b/docker-compose.yml index 647db59..98a862d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,12 @@ services: pymc-repeater: build: context: . + dockerfile: dockerfile args: PUID: ${PUID:-1000} PGID: ${PGID:-1000} + GPIO_GID: ${GPIO_GID:-986} + SPI_GID: ${SPI_GID:-989} container_name: pymc-repeater restart: unless-stopped ports: @@ -20,7 +23,9 @@ services: - SYS_RAWIO # USB DEVICSE PERMISSIONS group_add: - - plugdev + - "${GPIO_GID:-986}" + - "${SPI_GID:-989}" + - plugdev volumes: - ./config:/etc/pymc_repeater - ./data:/var/lib/pymc_repeater diff --git a/dockerfile b/dockerfile index a2e1218..39e2f6d 100644 --- a/dockerfile +++ b/dockerfile @@ -5,6 +5,8 @@ ARG USER=repeater ARG GROUP=repeater ARG PUID=15888 ARG PGID=15888 +ARG GPIO_GID=986 +ARG SPI_GID=989 ARG TARGETARCH ARG YQ_VERSION=v4.40.5 @@ -16,7 +18,9 @@ ENV INSTALL_DIR=/opt/pymc_repeater \ PYTHONUNBUFFERED=1 \ SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER=${PACKAGE_VERSION} \ PUID=${PUID} \ - PGID=${PGID} + PGID=${PGID} \ + GPIO_GID=${GPIO_GID} \ + SPI_GID=${SPI_GID} # Install runtime dependencies only RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ @@ -45,7 +49,10 @@ RUN arch="${TARGETARCH:-}" \ # Create the group and user in order to run without root privileges RUN groupadd --gid "$PGID" "$GROUP" \ - && useradd --uid "$PUID" --gid "$PGID" --home-dir "$HOME_DIR" --create-home --shell /usr/bin/bash "$USER" + && groupadd --gid "$GPIO_GID" gpio \ + && groupadd --gid "$SPI_GID" spi \ + && useradd --uid "$PUID" --gid "$PGID" --home-dir "$HOME_DIR" --create-home --shell /usr/bin/bash "$USER" \ + && usermod -a -G gpio,spi "$USER" # Create runtime directories RUN mkdir -p ${INSTALL_DIR} ${CONFIG_DIR} ${DATA_DIR} \