From 563cd4aba0d42d1484dfe4668a58da759f039c95 Mon Sep 17 00:00:00 2001 From: "Carlo Miguel F. Cruz" Date: Fri, 1 Nov 2024 15:17:08 +0800 Subject: [PATCH] Use python3 venv which is recommended for adhering with PEP 668. Starting alpine:3.19 with py3-pip v23.3.1-r0, py3-pip installations using apk will cause the error `error: externally-managed-environment` when pip attempts to upgrade the pip installation. We now use a virtual env for the test app to avoid this issue. Change-type: patch Signed-off-by: Carlo Miguel F. Cruz --- Dockerfile.template | 8 +++++--- start.sh | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile.template b/Dockerfile.template index 2dc2f2b..82f88e5 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -1,11 +1,13 @@ FROM balenalib/%%RESIN_MACHINE_NAME%%-alpine:latest -RUN apk update && apk add bash py-pip lockfile-progs --no-cache && \ +WORKDIR /usr/src/app + +RUN apk update && apk add bash python3 lockfile-progs --no-cache && \ + python3 -m venv venv && \ + source venv/bin/activate && \ pip install --upgrade pip && \ pip install flask -WORKDIR /usr/src/app - COPY . ./ CMD ["bash", "start.sh"] diff --git a/start.sh b/start.sh index 2bc464f..35f05e6 100644 --- a/start.sh +++ b/start.sh @@ -1,4 +1,7 @@ #!/bin/bash + +source venv/bin/activate + python server.py & for ((i=1;i<=5;i++)); do