├── .gitignore ├── .hgtags ├── Dockerfile ├── README.md ├── configs ├── .monetdb └── supervisord.conf └── scripts ├── init-db.sh └── set-monetdb-password.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .monetdb 2 | -------------------------------------------------------------------------------- /.hgtags: -------------------------------------------------------------------------------- 1 | b0ac053952d9f0562909c26492eb31081262f0d1 11.21.11 2 | cb4c89143a3e52064aa5a89f10fc05c400680afa 11.21.5 3 | 2b5d62d0a05379520f490406365aa4d1b2ad15bc 11.21.17 4 | 85c20775239951b06ae80ec1b448810502a778e0 11.21.19 5 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # Dockerfile to build MonetDB and R images 3 | # Based on CentOS 7 4 | ############################################################ 5 | FROM centos:7 6 | MAINTAINER Panagiotis Koutsourakis 7 | 8 | ####################################################### 9 | # Expose ports 10 | ####################################################### 11 | EXPOSE 50000 12 | 13 | ####################################################### 14 | # Setup supervisord 15 | ####################################################### 16 | # Install supervisor 17 | RUN yum install -y python-setuptools 18 | RUN easy_install supervisor 19 | # Create a log dir for the supervisor 20 | RUN mkdir -p /var/log/supervisor 21 | # Copy the config 22 | COPY configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf 23 | 24 | ############################################################# 25 | # Enables repos, update system, install packages and clean up 26 | ############################################################# 27 | RUN yum -y install epel-release numpy 28 | 29 | # Update & upgrade 30 | RUN yum update -y && \ 31 | yum upgrade -y 32 | 33 | ############################################################# 34 | # MonetDB installation 35 | ############################################################# 36 | # Create users and groups 37 | RUN groupadd -g 5000 monetdb && \ 38 | useradd -u 5000 -g 5000 monetdb 39 | 40 | # Enable MonetDB repo 41 | RUN yum install -y https://www.monetdb.org/downloads/epel/MonetDB-release-epel.noarch.rpm 42 | 43 | # Update & upgrade 44 | RUN yum update -y && \ 45 | yum upgrade -y 46 | 47 | ARG MonetDBVersion=11.31.7 48 | 49 | # Install MonetDB server 50 | RUN yum install -y MonetDB-$MonetDBVersion \ 51 | MonetDB-stream-$MonetDBVersion \ 52 | MonetDB-client-$MonetDBVersion \ 53 | MonetDB-SQL-server5-$MonetDBVersion \ 54 | MonetDB-SQL-server5-hugeint-$MonetDBVersion \ 55 | MonetDB5-server-$MonetDBVersion \ 56 | MonetDB5-server-hugeint-$MonetDBVersion 57 | 58 | # Install MonetDB extensions 59 | RUN yum install -y MonetDB-geom-MonetDB5-$MonetDBVersion \ 60 | MonetDB-R-$MonetDBVersion \ 61 | MonetDB-python2-$MonetDBVersion 62 | 63 | # Clean up 64 | RUN yum -y clean all 65 | 66 | ####################################################### 67 | # Setup MonetDB 68 | ####################################################### 69 | # Add helper scripts 70 | COPY scripts/set-monetdb-password.sh /home/monetdb/set-monetdb-password.sh 71 | RUN chmod +x /home/monetdb/set-monetdb-password.sh 72 | 73 | # Add a monetdb config file to avoid prompts for username/password 74 | # We will need this one to authenticate when running init-db.sh, as well 75 | COPY configs/.monetdb /home/monetdb/.monetdb 76 | 77 | # Copy the database init scripts 78 | COPY scripts/init-db.sh /home/monetdb/init-db.sh 79 | RUN chmod +x /home/monetdb/init-db.sh 80 | 81 | # As of the Jun2016 release, we have to set the property listenaddr to any host 82 | # because now it only listens to the localhost by default 83 | RUN echo "listenaddr=0.0.0.0" >> /var/monetdb5/dbfarm/.merovingian_properties 84 | 85 | # Init the db in a script to allow more than one process to run in the container 86 | # We need two: one for monetdbd and one for mserver 87 | # The script will init the database with using the unprivileged user monetdb 88 | RUN su -c 'sh /home/monetdb/init-db.sh' monetdb 89 | 90 | CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] 91 | 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | monetdb-r-docker 2 | =========================== 3 | [![Docker Hub](https://img.shields.io/badge/docker-ready-blue.svg)](https://hub.docker.com/r/monetdb/monetdb-r-docker/) 4 | 5 | Docker container for [MonetDB with R](https://www.monetdb.org/content/embedded-r-monetdb). Based on CentOS 7. 6 | 7 | # Supported tags and respective Dockerfile links 8 | * [`Aug2018`, `11.31.7`, `latest` (Dockerfile)](https://github.com/MonetDB/monetdb-r-docker/blob/aug2018/Dockerfile) 9 | * [`Mar2018`, `11.29.3`, (Dockerfile)](https://github.com/MonetDB/monetdb-r-docker/blob/mar2018/Dockerfile) 10 | 11 | # Launching a MonetDB container 12 | Pull the image from the registry: 13 | 14 | ``` 15 | docker pull monetdb/monetdb-r-docker 16 | ``` 17 | 18 | ## Quick start 19 | ``` 20 | docker run -d -P -p 50000:50000 --name monetdb-r monetdb/monetdb-r-docker 21 | ``` 22 | The `-d` option will send the docker process to the background. The `-P` option will publish all exposed ports. 23 | 24 | After that, you should be able to access MonetDB on the default port `50000`, with the default username/password: `monetdb/monetdb`. 25 | 26 | 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. 27 | 28 | ## Production run 29 | Before letting other users access the database-in-container, you should set a new password for the admin user `monetdb`: 30 | 31 | ``` 32 | docker exec -d monetdb-r /root/set-monetdb-password.sh 33 | ``` 34 | 35 | # Advanced 36 | ## Multiple database servers per container 37 | 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`. 38 | 39 | For more information on how to use MonetDB, check out the [tutorial](https://www.monetdb.org/Documentation/UserGuide/Tutorial). 40 | 41 | ## Build your own 42 | You can use the image as a base image when building your own version. 43 | After pulling the image from the registry, run the command bellow to build and tag your own version. 44 | 45 | ``` 46 | docker build --rm -t /monetdb-r-docker . 47 | ``` 48 | 49 | # Details 50 | ## Base image 51 | The MonetDB image is based on the CentOS 7. We migrated from Fedora (latest). 52 | ## Software 53 | The image includes the latest stable version of the software available for CentOS at build time: 54 | * MonetDB server with hugeint support 55 | * R module for embedded R support 56 | * Python2 module for embedded Python support (since Dec2016 only) 57 | * GEOS module 58 | * GSL module 59 | * Mclient - The native MonetDB client 60 | * MonetDB ODBC driver 61 | 62 | The default database on the image has R and Python2 integration enabled. 63 | 64 | ## Ports 65 | MonetDB runs on port `50000` by default, which is exposed on the image. 66 | -------------------------------------------------------------------------------- /configs/.monetdb: -------------------------------------------------------------------------------- 1 | user=monetdb 2 | password=monetdb 3 | -------------------------------------------------------------------------------- /configs/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:monetdbd] 5 | command=monetdbd start /var/monetdb5/dbfarm 6 | autorestart=false 7 | user=monetdb 8 | redirect_stderr=true 9 | stdout_logfile=/var/log/supervisor/monetdbd.log 10 | priority=1 11 | exitcodes=0 12 | startsecs=0 13 | -------------------------------------------------------------------------------- /scripts/init-db.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | chown -R monetdb:monetdb /var/monetdb5 4 | 5 | if [ ! -d "/var/monetdb5/dbfarm" ]; then 6 | monetdbd create /var/monetdb5/dbfarm 7 | else 8 | echo "Existing dbfarm found in '/var/monetdb5/dbfarm'" 9 | fi 10 | 11 | monetdbd start /var/monetdb5/dbfarm 12 | 13 | sleep 5 14 | if [ ! -d "/var/monetdb5/dbfarm/db" ]; then 15 | monetdb create db && \ 16 | monetdb set embedr=true db && \ 17 | monetdb set embedpy=true db && \ 18 | monetdb release db 19 | else 20 | echo "Existing database found in '/var/monetdb5/dbfarm/db'" 21 | fi 22 | 23 | for i in {30..0}; do 24 | echo 'Testing MonetDB connection ' $i 25 | mclient -d db -s 'SELECT 1' &> /dev/null 26 | if [ $? -ne 0 ] ; then 27 | echo 'Waiting for MonetDB to start...' 28 | sleep 1 29 | else 30 | echo 'MonetDB is running' 31 | break 32 | fi 33 | done 34 | if [ $i -eq 0 ]; then 35 | echo >&2 'MonetDB startup failed' 36 | exit 1 37 | fi 38 | 39 | mkdir -p /var/log/monetdb 40 | chown -R monetdb:monetdb /var/log/monetdb 41 | 42 | echo "Initialization done" 43 | -------------------------------------------------------------------------------- /scripts/set-monetdb-password.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dbname="db" 4 | username="monetdb" 5 | 6 | if [ -n "$1" ]; then 7 | password=$1 8 | echo "Setting new password for database '$dbname' and user '$username'." 9 | echo -e "user=monetdb\npassword=monetdb" > .monetdb 10 | mclient $dbname -s "ALTER USER SET PASSWORD '$password' USING OLD PASSWORD 'monetdb'"; 11 | rm -f .monetdb 12 | else 13 | echo "No password provided, aborting." 14 | fi 15 | --------------------------------------------------------------------------------