Skip to content

Commit

Permalink
[TM-1467] add new requeriments for python
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarLima1 committed Dec 19, 2024
1 parent 8761ebe commit b903b96
Showing 1 changed file with 47 additions and 38 deletions.
85 changes: 47 additions & 38 deletions docker/php.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM php:8.2-apache AS php

# Set GDAL version
ENV GDAL_VERSION=3.4.3

# Install basic dependencies
RUN apt-get update && apt-get install -y \
libxml2-dev \
libonig-dev \
Expand All @@ -9,33 +13,38 @@ RUN apt-get update && apt-get install -y \
libmagickwand-dev \
mariadb-client \
libzip-dev \
python3.11-venv \
python3.11-dev \
exiftool \
build-essential \
software-properties-common \
wget \
curl \
gcc \
g++ \
python3.11-dev \
python3.11-venv \
python3-pip \
python3-numpy \
cmake \
sqlite3 \
libsqlite3-dev \
libspatialite-dev \
libpq-dev \
libcurl4-gnutls-dev \
libproj-dev \
proj-data \
proj-bin \
exiftool
libgeos-dev \
&& rm -rf /var/lib/apt/lists/*

# Install GDAL 3.4.3 from source
RUN wget https://github.com/OSGeo/gdal/releases/download/v3.4.3/gdal-3.4.3.tar.gz && \
tar -xvf gdal-3.4.3.tar.gz && \
cd gdal-3.4.3 && \
./configure --with-python=/usr/bin/python3.11 && \
make -j$(nproc) && \
make install && \
ldconfig && \
cd .. && \
rm -rf gdal-3.4.3 gdal-3.4.3.tar.gz
RUN wget https://github.com/OSGeo/gdal/releases/download/v${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz \
&& tar xzf gdal-${GDAL_VERSION}.tar.gz \
&& cd gdal-${GDAL_VERSION} \
&& ./configure \
&& make -j$(nproc) \
&& make install \
&& ldconfig \
&& cd .. \
&& rm -rf gdal-${GDAL_VERSION} gdal-${GDAL_VERSION}.tar.gz

# Set GDAL environment variables
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

# PHP Extensions
# Your existing PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install \
bcmath \
Expand All @@ -56,31 +65,31 @@ RUN docker-php-ext-install exif
RUN docker-php-ext-enable exif
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

## APACHE
# Apache configuration
RUN a2enmod rewrite
COPY docker/000-default.conf /etc/apache2/sites-available/000-default.conf
COPY docker/php.ini /usr/local/etc/php/php.ini

## Python setup
# Python virtual environment setup
RUN python3.11 -m venv /opt/python
COPY resources/python/polygon-voronoi/requirements.txt /root/voronoi-requirements.txt
ENV PATH="/opt/python/bin:${PATH}"

# Set GDAL environment variables
ENV CPLUS_INCLUDE_PATH=/usr/local/include
ENV C_INCLUDE_PATH=/usr/local/include
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
ENV GDAL_VERSION=3.4.3

# Install Python packages
RUN pip3 install --upgrade pip
RUN pip3 install --no-cache-dir numpy wheel setuptools

# Install GDAL with specific version
# Install Python dependencies in the correct order
COPY resources/python/polygon-voronoi/requirements.txt /root/voronoi-requirements.txt
RUN pip3 install --upgrade pip wheel setuptools
RUN pip3 install numpy==1.26.4
RUN pip3 install pyproj==3.4.1
RUN pip3 install GDAL==${GDAL_VERSION}

# Install remaining requirements
RUN pip3 install -r /root/voronoi-requirements.txt
RUN pip3 install fiona==1.10.1
RUN pip3 install shapely==2.0.1
RUN pip3 install pandas==2.1.3
RUN pip3 install geopandas==1.0.1
RUN pip3 install rasterio==1.4.1
RUN pip3 install exactextract==0.2.0
RUN pip3 install rasterstats==0.20.0
RUN pip3 install pyyaml==6.0.2
RUN pip3 install requests==2.32.3
RUN pip3 install boto3==1.35.43

RUN chmod -R a+rx /opt/python
USER www-data
Expand Down

0 comments on commit b903b96

Please sign in to comment.