From a38ae8ecba4111eb9f91ff7fa58012fce86ce1bf Mon Sep 17 00:00:00 2001
From: Till Steinbach <steinbach.till@gmx.de>
Date: Mon, 23 Aug 2021 22:17:47 +0200
Subject: [PATCH] dockerfiles

---
 vwsfriend/Dockerfile | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/vwsfriend/Dockerfile b/vwsfriend/Dockerfile
index 0686899d..7447ac88 100644
--- a/vwsfriend/Dockerfile
+++ b/vwsfriend/Dockerfile
@@ -1,14 +1,21 @@
 # Here is the build image
-FROM python:3.8.0-slim as builder
-RUN apt-get update \
-&& apt-get install gcc libpq-dev python-dev -y \
-&& apt-get clean
-RUN python -m venv /opt/venv
+FROM ubuntu:20.04 as builder
+
+ENV DEBIAN_FRONTEND="noninteractive"
+ENV TZ="Etc/UTC"
+
+RUN apt-get update && apt-get install --no-install-recommends -y python3.9 python3.9-dev python3.9-venv python3-pip python3-wheel build-essential && \
+    apt-get clean && rm -rf /var/lib/apt/lists/*
+
+RUN python3.9 -m venv /opt/venv
 # Make sure we use the virtualenv:
 ENV PATH="/opt/venv/bin:$PATH"
-RUN pip install vwsfriend
+RUN pip3 install --no-cache-dir wheel
+RUN pip3 install --no-cache-dir vwsfriend
 
-FROM python:3.9.6-slim-buster
+#RUN python setup.py install
+
+FROM ubuntu:20.04 AS runner-image
 
 ENV WECONNECT_USER=
 ENV WECONNECT_PASSWORD=
@@ -16,8 +23,15 @@ ENV WECONNECT_INTERVAL=
 ENV ADDITIONAL_PARAMETERS=
 ENV DATABASE_URL=
 
+RUN apt-get update && apt-get install --no-install-recommends -y python3.9 python3-venv && \
+    apt-get clean && rm -rf /var/lib/apt/lists/*
+
 COPY --from=builder /opt/venv /opt/venv
+ENV VIRTUAL_ENV=/opt/venv
 ENV PATH="/opt/venv/bin:$PATH"
 RUN mkdir -p /config
 
+# make sure all messages always reach console
+ENV PYTHONUNBUFFERED=1
+
 CMD vwsfriend --username ${WECONNECT_USER} --password ${WECONNECT_PASSWORD} --interval ${WECONNECT_INTERVAL} --database-url ${DATABASE_URL} --config-dir /config ${ADDITIONAL_PARAMETERS}