From 447ba87fec215470363ca77f6942b605b0c4493e Mon Sep 17 00:00:00 2001 From: Viktor Adam Date: Fri, 27 Oct 2023 09:54:09 +1000 Subject: [PATCH] Fix wsgi tests --- examples/wsgi/Dockerfile | 16 ++++++++++------ examples/wsgi/httpd.conf | 4 ++-- examples/wsgi/run_tests.sh | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/wsgi/Dockerfile b/examples/wsgi/Dockerfile index af95f3e..08d0326 100644 --- a/examples/wsgi/Dockerfile +++ b/examples/wsgi/Dockerfile @@ -2,15 +2,19 @@ FROM httpd RUN apt-get update \ && apt-get install --no-install-recommends -y \ - python3 python3-dev python3-setuptools python3-pip \ - libapr1-dev libaprutil1-dev gcc \ - && pip install mod_wsgi + python3 python3-dev python3-pip python3-venv \ + libapr1-dev libaprutil1-dev gcc -ADD examples/wsgi/requirements.txt /tmp/requirements.txt -RUN pip install -r /tmp/requirements.txt +WORKDIR /usr/local/apache2 +ADD examples/wsgi/requirements.txt /tmp/requirements.txt ADD . /tmp/latest -RUN pip install -e /tmp/latest --upgrade + +RUN python3 -m venv venv \ + && . venv/bin/activate \ + && pip install mod_wsgi \ + && pip install -r /tmp/requirements.txt \ + && pip install -e /tmp/latest --upgrade ADD examples/wsgi/httpd.conf /usr/local/apache2/conf/httpd.conf ADD examples/wsgi/app.py examples/wsgi/wsgi.py /var/flask/ diff --git a/examples/wsgi/httpd.conf b/examples/wsgi/httpd.conf index f1d4cea..41756dc 100644 --- a/examples/wsgi/httpd.conf +++ b/examples/wsgi/httpd.conf @@ -546,8 +546,8 @@ SSLRandomSeed startup builtin SSLRandomSeed connect builtin -LoadModule wsgi_module "/usr/local/lib/python3.9/dist-packages/mod_wsgi/server/mod_wsgi-py39.cpython-39-x86_64-linux-gnu.so" -WSGIPythonHome "/usr" +LoadModule wsgi_module "/usr/local/apache2/venv/lib/python3.11/site-packages/mod_wsgi/server/mod_wsgi-py311.cpython-311-x86_64-linux-gnu.so" +WSGIPythonHome "/usr/local/apache2/venv" WSGISocketPrefix /var/run/wsgi diff --git a/examples/wsgi/run_tests.sh b/examples/wsgi/run_tests.sh index a41aa06..54e6924 100755 --- a/examples/wsgi/run_tests.sh +++ b/examples/wsgi/run_tests.sh @@ -8,13 +8,13 @@ _fail() { exit 1 } -docker build -f Dockerfile -t wsgi-sample ../../. > /dev/null || _fail +docker build --platform linux/amd64 -f Dockerfile -t wsgi-sample ../../. > /dev/null || _fail docker run -d --name wsgi-sample -p 8889:80 wsgi-sample > /dev/null || _fail echo 'Waiting for the server to start...' for _ in $(seq 1 10); do - if curl -fs http://localhost:8889/ping > /dev/null; then + if curl --max-time 1 -fs http://localhost:8889/ping > /dev/null; then break else sleep 0.2