|
@@ -1,15 +1,21 @@
|
|
|
-FROM python:3-stretch
|
|
|
|
|
-MAINTAINER Lars von Wedel <vonwedel@me.com>
|
|
|
|
|
|
|
+##Miflora-mqtt-daemon Docker image
|
|
|
|
|
+#Builds compact image to run as an alternative to installing the modules/service.
|
|
|
|
|
|
|
|
-RUN mkdir -p /usr/src/app
|
|
|
|
|
-WORKDIR /usr/src/app
|
|
|
|
|
|
|
+# The build image
|
|
|
|
|
+FROM python:3.10.7-slim as builder
|
|
|
|
|
+LABEL stage=builder
|
|
|
|
|
+RUN apt-get update && apt-get install bluez gcc libglib2.0-dev build-essential -y && apt-get clean
|
|
|
|
|
+COPY requirements.txt /app/requirements.txt
|
|
|
|
|
+WORKDIR /app/
|
|
|
|
|
+RUN pip install --user -r requirements.txt
|
|
|
|
|
+COPY . /app
|
|
|
|
|
|
|
|
-RUN apt-get update && apt-get install -y bluez
|
|
|
|
|
|
|
+# The production image
|
|
|
|
|
+FROM python:3.10.7-slim as app
|
|
|
|
|
+RUN apt-get update && apt-get install bluetooth bluez -y && apt-get clean
|
|
|
|
|
+COPY --from=builder /root/.local /root/.local
|
|
|
|
|
+COPY --from=builder /app/miflora-mqtt-daemon.py /app/miflora-mqtt-daemon.py
|
|
|
|
|
+WORKDIR /app/
|
|
|
|
|
+ENV PATH=/root/.local/bin:$PATH
|
|
|
|
|
|
|
|
-COPY requirements.txt requirements.txt
|
|
|
|
|
-RUN pip install --upgrade pip
|
|
|
|
|
-RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
-
|
|
|
|
|
-COPY . .
|
|
|
|
|
-
|
|
|
|
|
-CMD [ "python3", "./miflora-mqtt-daemon.py", "--config_dir", "/config" ]
|
|
|
|
|
|
|
+CMD [ "python3", "./miflora-mqtt-daemon.py", "--config_dir", "/config" ]
|