Skip to content

Commit

Permalink
Use python3 venv which is recommended for adhering with PEP 668.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cmfcruz committed Nov 1, 2024
1 parent b70d736 commit 563cd4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 3 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash

source venv/bin/activate

python server.py &
for ((i=1;i<=5;i++));
do
Expand Down

0 comments on commit 563cd4a

Please sign in to comment.