-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
75 lines (61 loc) · 2.18 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
# Add UbuntuGIS PPA for latest GDAL
RUN apt-get update && apt-get install -y software-properties-common
RUN add-apt-repository ppa:ubuntugis/ppa
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3.9 \
python3.9-dev \
python3.9-venv \
python3-pip \
build-essential \
libpq-dev \
gdal-bin \
libgdal-dev \
python3-gdal \
git \
libspatialindex-dev \
libproj-dev \
proj-data \
proj-bin \
libgeos-dev \
libgeos++-dev \
libffi-dev \
libsqlite3-mod-spatialite \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Get GDAL version and set environment variables
RUN export GDAL_VERSION=$(gdal-config --version) && \
export CPLUS_INCLUDE_PATH=/usr/include/gdal && \
export C_INCLUDE_PATH=/usr/include/gdal && \
export GDAL_LIBRARY_PATH=$(gdal-config --prefix)/lib/libgdal.so && \
echo "GDAL_VERSION=${GDAL_VERSION}" >> /etc/environment && \
echo "CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}" >> /etc/environment && \
echo "C_INCLUDE_PATH=${C_INCLUDE_PATH}" >> /etc/environment && \
echo "GDAL_LIBRARY_PATH=${GDAL_LIBRARY_PATH}" >> /etc/environment
# Create virtual environment
RUN python3.9 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Upgrade pip and install wheel
RUN pip install --no-cache-dir --upgrade pip wheel setuptools
# Install GDAL with system version first
RUN export GDAL_VERSION=$(gdal-config --version) && \
pip install --no-cache-dir GDAL==${GDAL_VERSION}
# Set work directory
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
# Install requirements with better error reporting and ensure fiona is installed after GDAL
RUN pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir fiona==$(pip show fiona | grep Version | cut -d' ' -f2) --no-binary fiona || \
(echo "Failed to install requirements" && cat /root/.cache/pip/log/*/log && exit 1)
# Copy project
COPY . .
# Make manage.py executable
RUN chmod +x manage.py
# Expose port
EXPOSE 8090
# Run the application
CMD ["python3.9", "manage.py", "runserver", "0.0.0.0:8090"]