## Dockerfile for bambu.py FROM python:3.11.7-alpine LABEL maintainer="Peter Siegmund " LABEL org.opencontainers.image.source="https://git.mars3142.dev/mars3142/bambu_mqtt" LABEL org.opencontainers.image.description="MQTT-Bridge für BambuLab Drucker" LABEL org.opencontainers.image.version="0.1.0" WORKDIR /app ## Copy only requirements.txt first for better caching COPY requirements.txt /app/requirements.txt RUN apk add --no-cache build-base libffi-dev openssl-dev \ && python -m venv /app/.venv \ && /app/.venv/bin/pip install --no-cache-dir -r /app/requirements.txt \ && apk del build-base libffi-dev openssl-dev ## Now copy the actual code COPY bambu.py /app/bambu.py ## Create non-root user RUN adduser -D -h /app appuser \ && chown -R appuser:appuser /app USER appuser ENV PATH="/app/.venv/bin:$PATH" ## Healthcheck: checks if the process is running (simple example) HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ CMD pgrep -f "python -u bambu.py" || exit 1 ## ENTRYPOINT for better extensibility ENTRYPOINT ["python", "-u", "bambu.py"]