Skip to content
Snippets Groups Projects
Commit 4c20831c authored by Rafael Dias's avatar Rafael Dias
Browse files

clean old data


Signed-off-by: default avatarrafaelcosc <rpd17@inf.ufpr.br>
parent 34098b90
No related branches found
No related tags found
No related merge requests found
Pipeline #21607 passed
############################################################
# Dockerfile to build MonetDB and R images
# Based on CentOS 7
############################################################
FROM centos:7
MAINTAINER Panagiotis Koutsourakis <panagiotis.koutsourakis@monetdbsolutions.com>
#######################################################
# Expose ports
#######################################################
EXPOSE 50000
#######################################################
# Setup supervisord
#######################################################
# Install supervisor
RUN yum install -y python-setuptools
RUN easy_install supervisor
# Create a log dir for the supervisor
RUN mkdir -p /var/log/supervisor
# Copy the config
COPY configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
#############################################################
# Enables repos, update system, install packages and clean up
#############################################################
RUN yum -y install epel-release numpy
# Update & upgrade
RUN yum update -y && \
yum upgrade -y
#############################################################
# MonetDB installation
#############################################################
# Create users and groups
RUN groupadd -g 5000 monetdb && \
useradd -u 5000 -g 5000 monetdb
# Enable MonetDB repo
RUN yum install -y https://www.monetdb.org/downloads/epel/MonetDB-release-epel.noarch.rpm
# Update & upgrade
RUN yum update -y && \
yum upgrade -y
ARG MonetDBVersion=11.33.3
# Install MonetDB server
RUN yum install -y MonetDB-$MonetDBVersion \
MonetDB-stream-$MonetDBVersion \
MonetDB-client-$MonetDBVersion \
MonetDB-SQL-server5-$MonetDBVersion \
MonetDB-SQL-server5-hugeint-$MonetDBVersion \
MonetDB5-server-$MonetDBVersion \
MonetDB5-server-hugeint-$MonetDBVersion
# Install MonetDB extensions
RUN yum install -y MonetDB-geom-MonetDB5-$MonetDBVersion \
MonetDB-R-$MonetDBVersion \
MonetDB-python2-$MonetDBVersion
# Clean up
RUN yum -y clean all
#######################################################
# Setup MonetDB
#######################################################
# Add helper scripts
COPY scripts/set-monetdb-password.sh /home/monetdb/set-monetdb-password.sh
RUN chmod +x /home/monetdb/set-monetdb-password.sh
# Add a monetdb config file to avoid prompts for username/password
# We will need this one to authenticate when running init-db.sh, as well
COPY configs/.monetdb /home/monetdb/.monetdb
# Copy the database init scripts
COPY scripts/init-db.sh /home/monetdb/init-db.sh
RUN chmod +x /home/monetdb/init-db.sh
# As of the Jun2016 release, we have to set the property listenaddr to any host
# because now it only listens to the localhost by default
RUN echo "listenaddr=0.0.0.0" >> /var/monetdb5/dbfarm/.merovingian_properties
# Init the db in a script to allow more than one process to run in the container
# We need two: one for monetdbd and one for mserver
# The script will init the database with using the unprivileged user monetdb
RUN su -c 'sh /home/monetdb/init-db.sh' monetdb
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
# CUSTOM
ENV MONETDB_NAME dbmonet
ENV MONETDB_USER dbmonet
ENV MONETDB_PASSWORD dbmonet
WORKDIR /home/monetdb
COPY script.sh /etc/script/script.sh
CMD ["/bin/bash", "/etc/script/script.sh"]
[supervisord]
nodaemon=true
[program:monetdbd]
command=monetdbd start /var/monetdb5/dbfarm
autorestart=false
user=monetdb
redirect_stderr=true
stdout_logfile=/var/log/supervisor/monetdbd.log
priority=1
exitcodes=0
startsecs=0
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf &
# the first argument will the database name
condition=true
while $condition ; do
# it will create a database called monetdb
monetdb create $MONETDB_NAME
# $? is the result 0 for sucess 1 for err
try=$?
if [ $try == "0" ]
then
# the test has succeed
condition=false
else
# the test has failed will try again in 5s
sleep 5s
fi
done
monetdb release $MONETDB_NAME
# .monetdb will be read when mclient is called without user and password
echo "user=monetdb" > .monetdb
echo "password=monetdb" >> .monetdb
mclient -d $MONETDB_NAME -s "create user \"$MONETDB_USER\" with password '$MONETDB_PASSWORD' name 'ci' schema \"sys\"";
echo "user=$MONETDB_USER" > .monetdb
echo "password=$MONETDB_PASSWORD" >> .monetdb
wait
\ No newline at end of file
#!/bin/bash
chown -R monetdb:monetdb /var/monetdb5
if [ ! -d "/var/monetdb5/dbfarm" ]; then
monetdbd create /var/monetdb5/dbfarm
else
echo "Existing dbfarm found in '/var/monetdb5/dbfarm'"
fi
monetdbd start /var/monetdb5/dbfarm
sleep 5
if [ ! -d "/var/monetdb5/dbfarm/db" ]; then
monetdb create db && \
monetdb set embedr=true db && \
monetdb set embedpy=true db && \
monetdb release db
else
echo "Existing database found in '/var/monetdb5/dbfarm/db'"
fi
for i in {30..0}; do
echo 'Testing MonetDB connection ' $i
mclient -d db -s 'SELECT 1' &> /dev/null
if [ $? -ne 0 ] ; then
echo 'Waiting for MonetDB to start...'
sleep 1
else
echo 'MonetDB is running'
break
fi
done
if [ $i -eq 0 ]; then
echo >&2 'MonetDB startup failed'
exit 1
fi
mkdir -p /var/log/monetdb
chown -R monetdb:monetdb /var/log/monetdb
echo "Initialization done"
#!/bin/bash
dbname="db"
username="monetdb"
if [ -n "$1" ]; then
password=$1
echo "Setting new password for database '$dbname' and user '$username'."
echo -e "user=monetdb\npassword=monetdb" > .monetdb
mclient $dbname -s "ALTER USER SET PASSWORD '$password' USING OLD PASSWORD 'monetdb'";
rm -f .monetdb
else
echo "No password provided, aborting."
fi
#!/bin/sh
set -e
# Perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"
POSTGIS_VERSION="${POSTGIS_VERSION%%+*}"
# Load PostGIS into both template_database and $POSTGRES_DB
for DB in template_postgis "$POSTGRES_DB" "${@}"; do
echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION"
psql --dbname="$DB" -c "
-- Upgrade PostGIS (includes raster)
CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION';
ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION';
-- Upgrade Topology
CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION';
ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION';
-- Install Tiger dependencies in case not already installed
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
-- Upgrade US Tiger Geocoder
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION';
ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION';
"
done
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment