diff --git a/.env.example b/.env.example index af3af2c..73dedd0 100644 --- a/.env.example +++ b/.env.example @@ -15,13 +15,16 @@ PYMC_REPEATER_IMAGE=pymcdev/pymc-repeater:main # PYMC_CONFIG_VOLUME=/opt/pymc-repeater/config # PYMC_DATA_VOLUME=/opt/pymc-repeater/data -# SPI/GPIO access uses the host's numeric group IDs. Check your host with: +# Serial/SPI/GPIO access uses the host's numeric group IDs. Check your host with: +# getent group dialout # getent group gpio # getent group spi # Example output: +# dialout:x:20: # gpio:x:997: # spi:x:999: # Put the third field from each output line below. +DIALOUT_GID=20 GPIO_GID=986 SPI_GID=989 diff --git a/README.md b/README.md index be44d1a..c16e43c 100644 --- a/README.md +++ b/README.md @@ -400,8 +400,8 @@ Copy `.env.example` to `.env` before starting: cp .env.example .env ``` -Set `GPIO_GID` and `SPI_GID` from `getent group gpio` and `getent group spi` -if your host values are different. +Set `DIALOUT_GID`, `GPIO_GID`, and `SPI_GID` from `getent group dialout`, +`getent group gpio`, and `getent group spi` if your host values are different. Default storage should use Docker named volumes. This avoids Portainer creating root-owned `./config` and `./data` bind mount folders on first start. If you @@ -414,8 +414,8 @@ that source as a directory, which breaks startup. ### Setup 1. Copy `.env.example` to `.env`. -2. Review `.env` and update `PYMC_REPEATER_IMAGE`, `GPIO_GID`, or `SPI_GID` - if needed. +2. Review `.env` and update `PYMC_REPEATER_IMAGE`, `DIALOUT_GID`, + `GPIO_GID`, or `SPI_GID` if needed. 3. Configure `docker-compose.yml` for your hardware and device paths. 4. Uncomment the USB device mapping only if your host has that device path. 5. Pull and start the container. @@ -447,6 +447,7 @@ services: - SYS_RAWIO group_add: + - "${DIALOUT_GID:-20}" - "${GPIO_GID:-986}" - "${SPI_GID:-989}" - plugdev diff --git a/docker-compose.build.yml b/docker-compose.build.yml index 0f1c2f6..bfcc204 100644 --- a/docker-compose.build.yml +++ b/docker-compose.build.yml @@ -7,5 +7,6 @@ services: args: PUID: ${PUID:-15888} PGID: ${PGID:-15888} + DIALOUT_GID: ${DIALOUT_GID:-20} GPIO_GID: ${GPIO_GID:-986} SPI_GID: ${SPI_GID:-989} diff --git a/docker-compose.yml b/docker-compose.yml index d2aff30..31301f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: - SYS_RAWIO # USB DEVICE PERMISSIONS group_add: + - "${DIALOUT_GID:-20}" - "${GPIO_GID:-986}" - "${SPI_GID:-989}" - plugdev diff --git a/dockerfile b/dockerfile index 39e2f6d..17e06c3 100644 --- a/dockerfile +++ b/dockerfile @@ -5,6 +5,7 @@ ARG USER=repeater ARG GROUP=repeater ARG PUID=15888 ARG PGID=15888 +ARG DIALOUT_GID=20 ARG GPIO_GID=986 ARG SPI_GID=989 ARG TARGETARCH @@ -19,6 +20,7 @@ ENV INSTALL_DIR=/opt/pymc_repeater \ SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER=${PACKAGE_VERSION} \ PUID=${PUID} \ PGID=${PGID} \ + DIALOUT_GID=${DIALOUT_GID} \ GPIO_GID=${GPIO_GID} \ SPI_GID=${SPI_GID} @@ -49,10 +51,11 @@ RUN arch="${TARGETARCH:-}" \ # Create the group and user in order to run without root privileges RUN groupadd --gid "$PGID" "$GROUP" \ + && (getent group dialout >/dev/null || groupadd --gid "$DIALOUT_GID" dialout) \ && 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" + && usermod -a -G dialout,gpio,spi "$USER" # Create runtime directories RUN mkdir -p ${INSTALL_DIR} ${CONFIG_DIR} ${DATA_DIR} \