From d5a2ba02c6cb6fea52f474036228cf0d3e6c944e Mon Sep 17 00:00:00 2001 From: Philipp van Kempen Date: Mon, 4 Nov 2024 12:50:38 +0100 Subject: [PATCH] docker: use virtualenv instead of system python --- docker/Dockerfile | 12 +++++++----- docker/Dockerfile2 | 13 +++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1f0bb138..4281887e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -75,9 +75,11 @@ FROM mlonmcu-ci AS mlonmcu ADD . /mlonmcu WORKDIR /mlonmcu -RUN pip3 install --upgrade pip --no-cache-dir -RUN pip3 install -r requirements.txt --no-cache-dir -RUN pip3 install . --no-cache-dir +RUN python3 -m venv /venv +ENV PATH="/venv/bin:$PATH" +RUN . /venv/bin/activate && pip install --upgrade pip --no-cache-dir +RUN . /venv/bin/activate && pip install -r requirements.txt --no-cache-dir +RUN . /venv/bin/activate && pip install . --no-cache-dir CMD ["mlonmcu"] @@ -91,13 +93,13 @@ ENV MLONMCU_HOME=/environment RUN mlonmcu setup -g -RUN pip3 install -r /environment/requirements_addition.txt --no-cache-dir +RUN . /venv/bin/activate && pip install -r /environment/requirements_addition.txt --no-cache-dir RUN df -h RUN df -h -RUN mlonmcu setup -v +RUN . /venv/bin/activate && mlonmcu setup -v RUN df -h diff --git a/docker/Dockerfile2 b/docker/Dockerfile2 index d949193d..cecaa2b7 100644 --- a/docker/Dockerfile2 +++ b/docker/Dockerfile2 @@ -6,23 +6,24 @@ ARG MLONMCU_TEMPLATE ADD . /mlonmcu WORKDIR /mlonmcu RUN df -h -RUN pip3 install --upgrade pip --no-cache-dir -RUN pip3 install -r requirements.txt --no-cache-dir -RUN pip3 install . --no-cache-dir +ENV PATH="/venv/bin:$PATH" +RUN . /venv/bin/activate && pip install --upgrade pip --no-cache-dir +RUN . /venv/bin/activate && pip install -r requirements.txt --no-cache-dir +RUN . /venv/bin/activate && pip install . --no-cache-dir RUN df -h WORKDIR /environment RUN df -h -RUN mlonmcu init --template ${MLONMCU_TEMPLATE} --non-interactive /environment --clone-models --allow-exists +RUN . /venv/bin/activate && mlonmcu init --template ${MLONMCU_TEMPLATE} --non-interactive /environment --clone-models --allow-exists ENV MLONMCU_HOME=/environment RUN mlonmcu setup -g -RUN pip3 install -r /environment/requirements_addition.txt --no-cache-dir +RUN . /venv/bin/activate && pip install -r /environment/requirements_addition.txt --no-cache-dir RUN df -h -RUN mlonmcu setup -v --rebuild +RUN . /venv/bin/activate && mlonmcu setup -v --rebuild RUN df -h CMD ["mlonmcu"]