Commit 1fc4acdc authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Re-commit changes related to database mini-dump.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 7f2e07c5
Pipeline #8050 passed with stage
in 18 minutes and 44 seconds
......@@ -9,6 +9,11 @@ gitlab_runner="gms_preprocessing_gitlab_CI_runner"
rm -rf context/sicor
git clone https://gitext.gfz-potsdam.de/EnMAP/sicor.git ./context/sicor
# get database mini-dump and setup script
# git clone git@gitext.gfz-potsdam.de:geomultisens/gms-meta.git ./context/
#wget -P ./context/db_minidump https://gitext.gfz-potsdam.de/geomultisens/gms-meta/blob/master/install_database.sh
#wget -P ./context/db_minidump https://gitext.gfz-potsdam.de/geomultisens/gms-meta/blob/master/gms_db_light.dump.gz
echo "#### Build runner docker image"
sudo docker rmi ${tag}
sudo docker build -f ${context_dir}/${dockerfile} -m 20G -t ${tag} ${context_dir}
......
......@@ -3,6 +3,10 @@ FROM gms_base_centos:0.2
# copy some needed stuff to /root
COPY *.yml /root/
# copy db_minidump code to /tmp
COPY gms-meta/install_database.sh /tmp/db_minidump
COPY gms-meta/gms_db_light.dump.gz /tmp/db_minidump
# update the ci_env environment (that already contains all packages installed via 'docker_pyenvs' repo)
RUN /bin/bash -i -c "\
source /root/miniconda3/bin/activate; \
......@@ -20,3 +24,6 @@ RUN bash -i -c "\
make requirements ; \
make download-tables ; \
pip install . --no-cache-dir"
# install database mini-dump
RUN bash -i -c "cd /tmp/db_minidump/; bash install_database_centos.sh"
#!/bin/bash
# check for root
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# files
YUM_REPO_FILE="/etc/yum.repos.d/CentOS-Base.repo"
DB_DUMP="./gms_db_light.dump.gz"
# installed version of postgresql
PG_VERSION="10"
# packages
PGSQL_PACKAGE="postgresql-$PG_VERSION"
POSTGIS_PACKAGE="postgresql-$PG_VERSION-postgis-2.4"
POSTGIS_SCRIPTS_PACKAGE="postgresql-$PG_VERSION-postgis-2.4-scripts"
GZIP_PACKAGE="gzip"
# function to install the given package if its missing
function install_if_missing {
if [ $(dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ];
# rpm -qa | grep postgresql10)
then
apt --yes install $1;
fi
}
# function setting up the postgresql apt repository
function setup_repo {
echo "Setting up apt repository"
sed -i '18 a exclude=postgresql*' ${YUM_REPO_FILE}
sed -i '27 a exclude=postgresql*' ${YUM_REPO_FILE}
}
# function bootstrapping the database
function bootstrap {
# check/install packages
## check for existing repo
if [ ! -f ${YUM_REPO_FILE} ]; then
setup_repo
fi
yum -y install https://download.postgresql.org/pub/repos/yum/testing/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
yum -y install postgresql${PG_VERSION} postgresql${PG_VERSION}-server postgresql${PG_VERSION}-libs \
postgresql${PG_VERSION}-contrib postgresql${PG_VERSION}-devel
yum -y install epel-release # helps to resolve postgis dependencies like gdal
yum -y install postgis2_${PG_VERSION}
yum -y install gzip
## install packages if missing
# install_if_missing $PGSQL_PACKAGE
# install_if_missing $POSTGIS_PACKAGE
# install_if_missing $POSTGIS_SCRIPTS_PACKAGE
# install_if_missing $GZIP_PACKAGE
}
# function importing the given dump of the gms db
function import_db {
gunzip -c ${DB_DUMP} | sudo -u postgres psql postgres
}
# 1. setup repo and check/install packages
bootstrap
# 2. import db dump
import_db
echo "** DONE ** (you might want to configure and start the gms-index-mediator now)"
exit
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment