fix: support windows ingestor build (#136)

* fix: support windows ingestor build

* fix: restore alpine build deps for ingestor (#137)
This commit is contained in:
l5y
2025-09-20 22:00:45 +02:00
committed by GitHub
parent e8af3b2397
commit 89f0b1bcfe

View File

@@ -1,49 +1,37 @@
# Multi-stage build for PotatoMesh Data Ingestor
FROM python:3.13-alpine AS builder
# syntax=docker/dockerfile:1.6
# Install build dependencies
RUN apk add --no-cache \
gcc \
musl-dev \
linux-headers \
build-base
ARG TARGETOS=linux
ARG PYTHON_VERSION=3.12.6
# Linux production image
FROM python:${PYTHON_VERSION}-alpine AS production-linux
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Set working directory
WORKDIR /app
# Copy requirements and install Python dependencies
COPY data/requirements.txt ./
RUN pip install --no-cache-dir --user -r requirements.txt
RUN set -eux; \
apk add --no-cache \
tzdata \
curl; \
apk add --no-cache --virtual .build-deps \
gcc \
musl-dev \
linux-headers \
build-base; \
python -m pip install --no-cache-dir -r requirements.txt; \
apk del .build-deps
# Production stage
FROM python:3.13-alpine AS production
COPY data/ .
RUN addgroup -S potatomesh && \
adduser -S potatomesh -G potatomesh && \
adduser potatomesh dialout && \
chown -R potatomesh:potatomesh /app
# Install runtime dependencies
RUN apk add --no-cache \
tzdata \
curl
# Create non-root user and add to dialout group for serial access
RUN addgroup -g 1000 -S potatomesh && \
adduser -u 1000 -S potatomesh -G potatomesh && \
adduser potatomesh dialout
# Set working directory
WORKDIR /app
# Copy installed Python packages from builder stage
COPY --from=builder /root/.local /home/potatomesh/.local
# Copy application code
COPY --chown=potatomesh:potatomesh data/ .
# Switch to non-root user
USER potatomesh
# Add local Python packages to PATH
ENV PATH=/home/potatomesh/.local/bin:$PATH
# Default environment variables (can be overridden by host)
ENV MESH_SERIAL=/dev/ttyACM0 \
MESH_SNAPSHOT_SECS=60 \
MESH_CHANNEL_INDEX=0 \
@@ -51,5 +39,32 @@ ENV MESH_SERIAL=/dev/ttyACM0 \
POTATOMESH_INSTANCE="" \
API_TOKEN=""
# Start the mesh daemon
CMD ["python", "mesh.py"]
# Windows production image
FROM python:${PYTHON_VERSION}-windowsservercore-ltsc2022 AS production-windows
SHELL ["cmd", "/S", "/C"]
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY data/requirements.txt ./
RUN python -m pip install --no-cache-dir -r requirements.txt
COPY data/ .
USER ContainerUser
ENV MESH_SERIAL=/dev/ttyACM0 \
MESH_SNAPSHOT_SECS=60 \
MESH_CHANNEL_INDEX=0 \
DEBUG=0 \
POTATOMESH_INSTANCE="" \
API_TOKEN=""
CMD ["python", "mesh.py"]
FROM production-${TARGETOS} AS production