starting work on a docker build

This commit is contained in:
Michael Gillett
2026-03-01 10:46:42 -05:00
parent ded15ea43d
commit d24bcb1f43
3 changed files with 72 additions and 0 deletions

View File

@@ -249,7 +249,11 @@ 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

16
docker-compose.yml Normal file
View File

@@ -0,0 +1,16 @@
services:
pymc-repeater:
build: .
container_name: pymc-repeater
restart: unless-stopped
devices:
- /dev/spidev0.0
- /dev/spidev0.1
volumes:
- ./config.yaml:/etc/pymc_repeater/config.yaml:ro
- pymc_data:/var/lib/pymc_repeater
ports:
- "8000:8000"
volumes:
pymc_data:

52
dockerfile Normal file
View File

@@ -0,0 +1,52 @@
# ---------------------------
# Builder stage
# ---------------------------
FROM python:3.11-alpine AS builder
WORKDIR /build
# Build dependencies
RUN apk add --no-cache \
build-base \
linux-headers \
python3-dev
COPY pyproject.toml .
COPY repeater ./repeater
# 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}
EXPOSE 8000
ENTRYPOINT ["/bin/sh", "-c", "test -f ${CONFIG_PATH} || (echo 'Missing config.yaml' && exit 1); exec python3 -m repeater --config ${CONFIG_PATH}"]