diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef9a421832c3eb57aa6998f6cc66d465bd3068a4..5d9777349920f58eef69344b42bd1e6042a7bc5d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,7 @@ variables: ################################################################################ # Build and push anchor .build_and_push_docker_image: &build_and_push_docker_image + - cd $IMAGE_DIR - docker build --pull --tag "$CI_REGISTRY_IMAGE/$IMAGE_NAME:latest" . - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:latest" @@ -41,16 +42,37 @@ stages: # * BUILD BUILD BUILD BUILD BUILD BUILD BUILD BUILD BUILD BUILD BUILD BUILD BUILD BUILD BUILD * # ********************************************************************************************* -Build Calqul: +Build Calqul Python: stage: Build Calqul variables: DOCKER_TLS_CERTDIR: "" NAMESPACE_ENV: "d01" - IMAGE_NAME: calqul-$NAMESPACE_ENV + IMAGE_NAME: calqul-python-$NAMESPACE_ENV + IMAGE_DIR: ./Dockerfiles/python rules: - if: $CI_COMMIT_BRANCH == "develop" - changes: # build image only if sources have changed. - - Dockerfile # Image definition has changed + - ./Dockerfiles/python/Dockerfile # Image definition has changed + services: + - docker:dind + script: + - *docker_login + - *build_and_push_docker_image + tags: + - build-push-to-registry + + +Build Calqul Postgis: + stage: Build Calqul + variables: + DOCKER_TLS_CERTDIR: "" + NAMESPACE_ENV: "d01" + IMAGE_NAME: calqul-postgis-$NAMESPACE_ENV + IMAGE_DIR: ./Dockerfiles/postgis + rules: + - if: $CI_COMMIT_BRANCH == "develop" + - changes: # build image only if sources have changed. + - ./Dockerfiles/postgis/Dockerfile # Image definition has changed services: - docker:dind script: diff --git a/Dockerfiles/postgis/Dockerfile b/Dockerfiles/postgis/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..01cfc4f41b52ccd0697511d6fe02768e59035115 --- /dev/null +++ b/Dockerfiles/postgis/Dockerfile @@ -0,0 +1,30 @@ +# ARB::Base de données postgis pour le calcul du calque de plantabilité + +FROM postgis/postgis + +# Openshift Stuff +# Set labels used in OpenShift to describe the builder images. +LABEL io.k8s.description="base de données relationnelle PostgreSQL \ +avec support des données géographiques (PostGIS). Base temporaire \ +utilisée pour le calcul du calque de plantabilité, \ +puis ses résultats sont ensuite exportés, et enfin elle est détruite." \ + io.k8s.display-name="PostgreSQL 10 avec extension PostGIS" \ + io.openshift.tags="sql,postgresql,postgis,arb" + +# Create another dir for pgdata than /var/postgresql/data/ +# see http://heidloff.net/article/deploying-postgres-on-openshift/ + +ENV PGDATA=/var/lib/postgresql/data/pgdata +RUN groupadd non-root-postgres-group +RUN useradd non-root-postgres-user --group non-root-postgres-group +RUN chown -R non-root-postgres-user:non-root-postgres-group /var/lib/postgresql/data +RUN chmod 777 /var/lib/postgresql/data +RUN chown -R non-root-postgres-user:non-root-postgres-group /docker-entrypoint-initdb.d/ + +# Entry point. +# At startup, the Postgis Docker Image automatically runs .sh script and .sal scripts which are in this directory. +# See Dockerfiles/db/db-init/20_init_arb.sh script for more information. +COPY ./db-init/ /docker-entrypoint-initdb.d/ + +USER non-root-postgres + diff --git a/Dockerfiles/postgis/db-init/20_init_arb.sh b/Dockerfiles/postgis/db-init/20_init_arb.sh new file mode 100644 index 0000000000000000000000000000000000000000..a4cb3219cd1a269c72e027e3341ac7e6ac11a6b3 --- /dev/null +++ b/Dockerfiles/postgis/db-init/20_init_arb.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Boostraping de la base de données ARB +# + +# Working Directory +cd /docker-entrypoint-initdb.d + +echo "--------------------------------------------------------------------------" +echo " --> Boostraping de la base de donnees ARB" +echo " le repertoire est '$(pwd)'" +echo "--------------------------------------------------------------------------" +# Mettre ici le le schéma d'initailisation, les reprises de données, reéation de roles et grants, etc... +echo "User : $POSTGRES_USER" +echo " Database : $POSTGRES_DB" +# psql -U $POSTGRES_USER -d $POSTGRES_DB -c 'CREATE ROLE postgres' +# psql -U $POSTGRES_USER -d $POSTGRES_DB -f /docker-entrypoint-initdb.d/backups/BACKUP_SCHEMA.sql +# psql -U $POSTGRES_USER -d $POSTGRES_DB -c 'ALTER TABLE prod_immo.operation ADD etat_chargement varchar NULL;' +echo "--------------------------------------------------------------------------" +echo " Base de donnees ARB prete." +echo "--------------------------------------------------------------------------" diff --git a/Dockerfile b/Dockerfiles/python/Dockerfile similarity index 100% rename from Dockerfile rename to Dockerfiles/python/Dockerfile diff --git a/scripts/hello-world.py b/Dockerfiles/python/scripts/hello-world.py similarity index 100% rename from scripts/hello-world.py rename to Dockerfiles/python/scripts/hello-world.py diff --git a/scripts/requirements.txt b/Dockerfiles/python/scripts/requirements.txt similarity index 100% rename from scripts/requirements.txt rename to Dockerfiles/python/scripts/requirements.txt