From cb25fefcb09e9230c16225a8654013f523619e5a Mon Sep 17 00:00:00 2001 From: rafaelcosc <rpd17@inf.ufpr.br> Date: Wed, 18 Sep 2019 09:46:31 -0300 Subject: [PATCH] commit image Signed-off-by: rafaelcosc <rpd17@inf.ufpr.br> --- .gitlab-ci.yml | 4 +- .hgtags | 4 - Dockerfile | 111 ++---------------- README.md | 65 ---------- configs/.monetdb | 2 - initdb-postgis.sh | 25 ++++ tmp/Dockerfile | 102 ++++++++++++++++ {configs => tmp/configs}/supervisord.conf | 0 script.sh => tmp/script.sh | 0 {scripts => tmp/scripts}/init-db.sh | 0 .../scripts}/set-monetdb-password.sh | 0 tmp/update-postgis.sh | 26 ++++ 12 files changed, 167 insertions(+), 172 deletions(-) delete mode 100644 .hgtags delete mode 100644 configs/.monetdb create mode 100644 initdb-postgis.sh create mode 100644 tmp/Dockerfile rename {configs => tmp/configs}/supervisord.conf (100%) rename script.sh => tmp/script.sh (100%) rename {scripts => tmp/scripts}/init-db.sh (100%) rename {scripts => tmp/scripts}/set-monetdb-password.sh (100%) create mode 100644 tmp/update-postgis.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d297f14..9237192 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ variables: - image_version: '11.33.3' - DOCKER_URL: 'dockerregistry.c3sl.ufpr.br:5000/c3sl/monetdb-ci-service' + image_version: '2.5.2' + DOCKER_URL: 'dockerregistry.c3sl.ufpr.br:5432/c3sl/postgres-ext-ci-service' stages: - build diff --git a/.hgtags b/.hgtags deleted file mode 100644 index 3291c20..0000000 --- a/.hgtags +++ /dev/null @@ -1,4 +0,0 @@ -b0ac053952d9f0562909c26492eb31081262f0d1 11.21.11 -cb4c89143a3e52064aa5a89f10fc05c400680afa 11.21.5 -2b5d62d0a05379520f490406365aa4d1b2ad15bc 11.21.17 -85c20775239951b06ae80ec1b448810502a778e0 11.21.19 diff --git a/Dockerfile b/Dockerfile index 64704d1..94423c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,102 +1,15 @@ -############################################################ -# Dockerfile to build MonetDB and R images -# Based on CentOS 7 -############################################################ -FROM centos:7 -MAINTAINER Panagiotis Koutsourakis <panagiotis.koutsourakis@monetdbsolutions.com> +FROM postgres:10 -####################################################### -# Expose ports -####################################################### -EXPOSE 50000 +ENV POSTGIS_MAJOR 2.5 +ENV POSTGIS_VERSION 2.5.2+dfsg-1~exp1.pgdg90+1 -####################################################### -# 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 +RUN apt-get update \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \ + postgis=$POSTGIS_VERSION \ + && rm -rf /var/lib/apt/lists/* -############################################################# -# 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"] +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh diff --git a/README.md b/README.md index 16a3eb9..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,65 +0,0 @@ -monetdb-r-docker -=========================== -[](https://hub.docker.com/r/monetdb/monetdb-r-docker/) - -Docker container for [MonetDB with R](https://www.monetdb.org/content/embedded-r-monetdb). Based on CentOS 7. - -# Supported tags and respective Dockerfile links -* [`Aug2018`, `11.31.7`, `latest` (Dockerfile)](https://github.com/MonetDB/monetdb-r-docker/blob/aug2018/Dockerfile) -* [`Mar2018`, `11.29.3`, (Dockerfile)](https://github.com/MonetDB/monetdb-r-docker/blob/mar2018/Dockerfile) - -# Launching a MonetDB container -Pull the image from the registry: - -``` -docker pull monetdb/monetdb-r-docker -``` - -## Quick start -``` -docker run -d -P -p 50000:50000 --name monetdb-r monetdb/monetdb-r-docker -``` -The `-d` option will send the docker process to the background. The `-P` option will publish all exposed ports. - -After that, you should be able to access MonetDB on the default port `50000`, with the default username/password: `monetdb/monetdb`. - -Or you can run `docker exec -it monetdb-r mclient db` to open an [`mclient`](https://www.monetdb.org/Documentation/mclient-man-page) shell in the container. - -## Production run -Before letting other users access the database-in-container, you should set a new password for the admin user `monetdb`: - -``` -docker exec -d monetdb-r /root/set-monetdb-password.sh <password> -``` - -# Advanced -## Multiple database servers per container -The MonetDB daemon [monetdbd](https://www.monetdb.org/Documentation/monetdbd-man-page) allows for multiple MonetDB database server processes to run on the same system and listed on the same port. While it is not advised to run more than one database server in the same Docker container, you can do that by creating a new database with the [monetdb](https://www.monetdb.org/Documentation/monetdb-man-page) command-line control tool. In this container, the database server is controller by the MonetDB daemon (`monetdbd`), both of which are started by `supervisord`. - -For more information on how to use MonetDB, check out the [tutorial](https://www.monetdb.org/Documentation/UserGuide/Tutorial). - -## Build your own -You can use the image as a base image when building your own version. -After pulling the image from the registry, run the command bellow to build and tag your own version. - -``` -docker build --rm -t <yourname>/monetdb-r-docker . -``` - -# Details -## Base image -The MonetDB image is based on the CentOS 7. We migrated from Fedora (latest). -## Software -The image includes the latest stable version of the software available for CentOS at build time: -* MonetDB server with hugeint support -* R module for embedded R support -* Python2 module for embedded Python support (since Dec2016 only) -* GEOS module -* GSL module -* Mclient - The native MonetDB client -* MonetDB ODBC driver - -The default database on the image has R and Python2 integration enabled. - -## Ports -MonetDB runs on port `50000` by default, which is exposed on the image. diff --git a/configs/.monetdb b/configs/.monetdb deleted file mode 100644 index 4539760..0000000 --- a/configs/.monetdb +++ /dev/null @@ -1,2 +0,0 @@ -user=monetdb -password=monetdb diff --git a/initdb-postgis.sh b/initdb-postgis.sh new file mode 100644 index 0000000..f09b903 --- /dev/null +++ b/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<- 'EOSQL' +CREATE DATABASE template_postgis; +UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS dblink; + CREATE EXTENSION IF NOT EXISTS pgcrypto; + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done \ No newline at end of file diff --git a/tmp/Dockerfile b/tmp/Dockerfile new file mode 100644 index 0000000..64704d1 --- /dev/null +++ b/tmp/Dockerfile @@ -0,0 +1,102 @@ +############################################################ +# 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"] diff --git a/configs/supervisord.conf b/tmp/configs/supervisord.conf similarity index 100% rename from configs/supervisord.conf rename to tmp/configs/supervisord.conf diff --git a/script.sh b/tmp/script.sh similarity index 100% rename from script.sh rename to tmp/script.sh diff --git a/scripts/init-db.sh b/tmp/scripts/init-db.sh similarity index 100% rename from scripts/init-db.sh rename to tmp/scripts/init-db.sh diff --git a/scripts/set-monetdb-password.sh b/tmp/scripts/set-monetdb-password.sh similarity index 100% rename from scripts/set-monetdb-password.sh rename to tmp/scripts/set-monetdb-password.sh diff --git a/tmp/update-postgis.sh b/tmp/update-postgis.sh new file mode 100644 index 0000000..57c2f90 --- /dev/null +++ b/tmp/update-postgis.sh @@ -0,0 +1,26 @@ +#!/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 -- GitLab