From 512a58954a5a5fff28f155ba2db407406c3804f7 Mon Sep 17 00:00:00 2001 From: Thierry Date: Mon, 13 Jan 2025 00:50:47 +0100 Subject: [PATCH] Add Dockerfile_qgis-django --- Dockerfile_qgis-django | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Dockerfile_qgis-django diff --git a/Dockerfile_qgis-django b/Dockerfile_qgis-django new file mode 100644 index 0000000..cf780fd --- /dev/null +++ b/Dockerfile_qgis-django @@ -0,0 +1,43 @@ +FROM qgis/qgis:3.40.2-bookworm + +# Set environment variables for QGIS +ENV QGIS_PREFIX_PATH=/usr +ENV QT_QPA_PLATFORM=offscreen +ENV XDG_RUNTIME_DIR=/tmp/runtime-root +# Set environment variables +## Prevents Python from writing pyc files to disc (equivalent to python -B option) +ENV PYTHONDONTWRITEBYTECODE 1 +## Prevents Python from buffering stdout and stderr (equivalent to python -u option) +ENV PYTHONUNBUFFERED=1 + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq nano sed curl git wget libldap2-dev libsasl2-dev locales && apt autoremove && apt clean && \ + rm -rf /var/lib/apt/lists/* + +# Set the locale +RUN sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen && \ + locale-gen +ENV LANG fr_FR.UTF-8 +ENV LANGUAGE fr_FR:en +ENV LC_ALL fr_FR.UTF-8 + +#### DJANGO ####### +WORKDIR /code +COPY . /code/ +# Assuming somewhere on top there is already `python3-venv` installed +# via system package manager, e.g. `apt-get install -y python3-venv` +# Link local QGIS Python bindings and local python packages with Python virtual environment +RUN python3 -m venv --system-site-packages /opt/venv +ENV PATH="/opt/venv/bin:$PATH" +# Below you can continue using `pip install` as normal +RUN pip3 install --no-cache-dir -r requirements.txt + +RUN echo 'alias python=python3' >> ~/.bashrc +# Clean all +RUN apt-get autoremove -y \ + && rm /etc/localtime \ + && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \ + && dpkg-reconfigure -f noninteractive tzdata \ + && apt-get clean \ + && apt-get purge \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*