I have the following Dockerfile for the GeoDjango container. I have used the osgeo/gdal image that ships with gdal preinstalled, then I have installed the required python packages and the needed apt libraries, finally, I have used a shell entry point to do Django migrations and also start the Django server. as it can be seen I have used pipenv for environment management
FROM osgeo/gdal as base
RUN set -xe \
&& apt-get update \
&& apt-ge
t install -y python3.6 \
&& apt-get install -y python3-pip
RUN pip install --upgrade pip
RUN apt-get update && apt-get install -y --no-install-recommends gcc
RUN apt-get update \
&& apt-get install -y gdal-bin python3-gdal
FROM base AS python-deps
WORKDIR /code
COPY Pipfile /code/
COPY Pipfile.lock /code/
RUN pip install pipenv \
&& pipenv lock --keep-outdated --requirements > requirements.txt \
&& pip install -r requirements.txt
# Install python dependencies in /.venv
#RUN pipenv install
# Install application into container
COPY . /code/
# Run the application
ENTRYPOINT ["/bin/bash", "/code/entrypoint.sh"]
#ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:8000"]
However, I get the following:
C:\OSGeo4W\bin\gdal304.dll
I develop it on the macOS why I am getting such errors? my requirements file contains the following packages:
arabic-reshaper==2.1.3
asgiref==3.4.1
asn1crypto==1.3.0
backports.entry-points-selectable==1.1.1
beautifulsoup4==4.8.2
bs4==0.0.1
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
colorama==0.4.3
croniter==1.0.15
cryptography==2.8
DateTime==4.3
distlib==0.3.3
Django==3.2.7
django-ckeditor==3.6.2.1
django-cors-headers==3.8.0
django-grappelli==2.13.4
django-html-field==0.1.3
django-jalali==4.3.0
django-jalali-date==0.3.2
django-jinja==2.6.0
django-mssql-backend==2.4.2
django-phonenumber-field==6.0.0
django-pyodbc-azure==2.1.0.0
django-ranged-response==0.2.0
django-ratelimit==3.0.1
django-rest-framework==0.1.0
django-richtextfield==1.5.0
django-simple-captcha==0.5.12
django-singleton-model==0.2.3
django-summernote==0.8.11.6
django-xhtml2pdf==0.0.4
djangorestframework==3.12.4
filelock==3.3.2
fpdf==1.7.2
future==0.18.2
gunicorn==20.0.4
html5lib==1.0.1
idna==2.9
importlib-metadata==4.8.2
importlib-resources==5.4.0
jdatetime==3.6.2
Jinja2==2.11.1
jsonfield==3.1.0
jwcrypto==0.8
lxml==4.5.0
MarkupSafe==1.1.1
mysqlclient==1.4.6
ntlm-auth==1.4.0
numpy==1.19.5
oauthlib==3.1.0
olefile==0.46
orjson==3.6.1
pandas==1.1.5
pdfkit==0.6.1
persiantools==1.4.1
phonenumbers==8.12.37
phpserialize==1.3
Pillow==7.1.2
pipenv==2021.11.9
platformdirs==2.4.0
psycopg2==2.9.1
psycopg2-binary==2.9.1
pycparser==2.20
pycryptodome==3.10.1
pycryptodomex==3.9.7
pyodbc===4.0.0-unsupported
PyPDF2==1.26.0
python-bidi==0.4.2
python-dateutil==2.8.2
python-resize-image==1.1.19
pytz==2019.3
qrcode==6.1
ratelimit==2.2.1
reportlab==3.5.42
requests==2.23.0
requests-ntlm==1.1.0
six==1.14.0
soupsieve==2.0
sqlparse==0.3.1
typing-extensions==3.7.4.3
urllib3==1.25.8
virtualenv==20.10.0
virtualenv-clone==0.5.7
webencodings==0.5.1
wincertstore==0.2
wkhtmltopdf==0.2
xhtml2pdf==0.2.4
xlrd==1.2.0
XlsxWriter==1.3.7
xlutils==2.0.0
xlwt==1.3.0
xmltodict==0.12.0
zipp==3.6.0
zope.interface==5.0.1
The error log is as follow:
redif_server | File "/usr/local/lib/python3.8/dist-packages/django/contrib/gis/db/models/functions.py", line 3, in <module>
redif_server | from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
redif_server | File "/usr/local/lib/python3.8/dist-packages/django/contrib/gis/db/models/fields.py", line 3, in <module>
redif_server | from django.contrib.gis import forms, gdal
redif_server | File "/usr/local/lib/python3.8/dist-packages/django/contrib/gis/forms/__init__.py", line 3, in <module>
redif_server | from .fields import ( # NOQA
redif_server | File "/usr/local/lib/python3.8/dist-packages/django/contrib/gis/forms/fields.py", line 2, in <module>
redif_server | from django.contrib.gis.gdal import GDALException
redif_server | File "/usr/local/lib/python3.8/dist-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module>
redif_server | from django.contrib.gis.gdal.datasource import DataSource
redif_server | File "/usr/local/lib/python3.8/dist-packages/django/contrib/gis/gdal/datasource.py", line 40, in <module>
redif_server | from django.contrib.gis.gdal.driver import Driver
redif_server | File "/usr/local/lib/python3.8/dist-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
redif_server | from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
redif_server | File "/usr/local/lib/python3.8/dist-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
redif_server | from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
redif_server | File "/usr/local/lib/python3.8/dist-packages/django/contrib/gis/gdal/libgdal.py", line 53, in <module>
redif_server | lgdal = CDLL(lib_path)
redif_server | File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
redif_server | self._handle = _dlopen(self._name, mode)
redif_server | OSError: C:\OSGeo4W\bin\gdal304.dll: cannot open shared object file: No such file or directory