From 82ea510348cd1970546d44db733b10a81526b12f Mon Sep 17 00:00:00 2001
From: Cresson Remi <remi.cresson@irstea.fr>
Date: Thu, 9 Feb 2023 12:21:54 +0100
Subject: [PATCH] Update Dockerfile

---
 Dockerfile | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 58 insertions(+), 3 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 1667155..cf2ffc5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,59 @@
-FROM postgres
-ARG PTH=/var/lib/postgresql
-RUN chgrp -R 0 $PTH && chmod -R g+rwX $PTH
+FROM centos/postgresql-95-centos7 as pg
+
+LABEL maintainer="David Bitner / Remi Cresson"
+
+ENV POSTGIS_MAJOR 3
+ENV PGUSER postgres
+ENV PGDATABASE postgres
+ENV PGHOST localhost
+ENV \
+    PYTHONUNBUFFERED=1 \
+    PYTHONFAULTHANDLER=1 \
+    PYTHONDONTWRITEBYTECODE=1 \
+    PIP_NO_CACHE_DIR=off \
+    PIP_DISABLE_PIP_VERSION_CHECK=on \
+    PIP_DEFAULT_TIMEOUT=100
+USER root
+RUN \
+    yum install -y \
+        git \
+        gnupg \
+        apt-transport-https \
+        debian-archive-keyring \
+        software-properties-common \
+        postgresql-$PG_MAJOR-pgtap \
+        postgresql-$PG_MAJOR-partman \
+        postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
+        postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
+        build-essential \
+        python3 \
+        python3-pip \
+        python3-setuptools
+RUN pip3 install -U pip setuptools packaging \
+    && pip3 install -U psycopg2-binary \
+    && pip3 install -U psycopg[binary] \
+    && pip3 install -U migra[pg] \
+    && yum remove -y apt-transport-https \
+    && yum -y autoremove \
+    && rm -rf /var/lib/apt/lists/*
+
+EXPOSE 5432
+
+RUN mkdir -p /docker-entrypoint-initdb.d
+RUN echo "#!/bin/bash \n unset PGHOST \n pypgstac migrate" >/docker-entrypoint-initdb.d/initpgstac.sh && chmod +x /docker-entrypoint-initdb.d/initpgstac.sh
+
+RUN git clone https://github.com/stac-utils/pgstac \
+    && cd pgstac/pypgstac \
+    && sed -i 's/python_requires=">=3.7"/python_requires=">=3.6"/g' setup.py \
+    && sed -i 's/pydantic\[dotenv\]==1.10/pydantic\[dotenv\]==1.9/g' setup.py \
+    && cat setup.py \
+    && pip install .
+    
+ENV POSTGRESQL_USER=username
+ENV POSTGRESQL_PASSWORD=password
+ENV POSTGRESQL_DB=postgis
+ENV PGUSER=username
+ENV PGPASSWORD=password
+ENV PGHOST=localhost
+ENV PGDATABASE=postgis
 USER 1001
-- 
GitLab