GithubHelp home page GithubHelp logo

felipenoris / math-server-docker Goto Github PK

View Code? Open in Web Editor NEW
72.0 8.0 17.0 408 KB

The ideal multi-user Data Science server with Jupyterhub and RStudio, ready for Python, R and Julia languages.

License: MIT License

Shell 1.28% Python 5.04% Dockerfile 93.68%
jupyter data-science julia-language latex shiny-server rstudio-servers jupyterhub jupyter-kernels python docker

math-server-docker's Introduction

math-server-docker

License

Dockerfile to build the ideal multi-user Data Science server with Jupyterhub and RStudio, ready for Python, R and Julia languages.

It's based on CentOS 7 image, which is a very stable Linux distribution, compatible with Red Hat (widely used in Corporations), but often offers outdated packages. In order to provide up-to-date tools, this Dockerfile builds most tools from source.

List of tools

There's also a number of utilities under the hood:

Usage

To build the image, run the following comand:

# docker build -t math-server .

Be patient. It may take up to 8 hours to complete.

After the build is complete, you can start the server with:

# docker run -d -p 8787:8787 -p 8000:8000 --name ms1 math-server

With a running container, you can go ahead and create users:

# docker exec ms1 useradd myuser

# docker exec -it ms1 passwd myuser

The default ports are:

  • 8787 for RStudio

  • 8000 for Jupyter

Requirements

Docker.

Application specific notes

The last command in the Dockerfile starts Jupyterhub and RStudio:

CMD /usr/lib/rstudio-server/bin/rserver \
	&& jupyterhub --no-ssl -f jupyterhub_config.py

Jupyter

Data files are at /usr/local/share/jupyter/hub.

By default, Jupyter will be accessible on the following link: http://localhost:8000, and will create state files (jupyterhub_cookie_secret, jupyterhub.sqlite) on current directory, and use default configuration.

You can generate a sample configuration file with:

# jupyterhub --generate-config

To start the server using a configuration file, use:

# jupyterhub -f jupyterhub_config.py

To set IP and port, use:

# jupyterhub --ip=192.168.1.2 --port=443

You may have to open port for external access:

# /sbin/iptables -I INPUT -p tcp -m tcp --dport 8000 -j ACCEPT
# /sbin/service iptables save

For https support, add the following lines to the config file:

c.JupyterHub.port = 443
c.JupyterHub.ssl_cert = '/root/.ssh/sample-cert.pem'
c.JupyterHub.ssl_key = '/root/.ssh/sample-key.pem'

443 is the default port for https. So the server will be accessible using https://localhost.

sample-cert.pem is the signed certificate file, and sample-key.pem is the private ssl key.

You can generate self signed certificate file by running the code below, but be aware that your browser will not recognize the certificate as trusted.

# mkdir ~/.ssh
# openssl req -x509 -newkey rsa:2048 -keyout ~/.ssh/sample-key.pem -out ~/.ssh/sample-cert.pem -days 9999 -nodes -subj "/C=BR/ST=Rio de Janeiro/L=Rio de Janeiro/O=org/OU=unit/CN=website"
# chmod 400 sample*.pem

This project provides a minimal jupyter_config.py configuration file that sets a few important environment variables that should be passed to child spawned processes, namely: 'PATH', 'LD_LIBRARY_PATH', 'JAVA_HOME', 'CPATH', 'CMAKE_ROOT', 'http_proxy', 'https_proxy'.

Jupyterlab

Jupyterlab is the default user interface. This behavior is set by the following line in the provided jupyterhub_config.py file:

c.Spawner.default_url = '/lab'

To revert to old Jupyter user interface, you can either access manually the /tree url (as in http://localhost:8000/user/username/tree) or edit jupyterhub_config.py deleting the c.Spawner.default_url line.

See Jupyterlab documentation for more information.

RStudio

Configuration files are at /etc/rstudio. There's also the Server Options file at /usr/lib/rstudio-server/R/ServerOptions.R.

Default port is 8787.

Change the default port by editing rserver.conf. The following will change to port 80:

# echo -e "www-port=80" | tee /etc/rstudio/rserver.conf
# rstudio-server restart
# rstudio-server verify-installation

auth-pam-sessions-profile directive on /etc/rstudio.rserver.conf may not work. If that happens, RStudio will look at /etc/pam.d/rstudio.

Proxy settings are not configured in RStudio by default. If you're running behind proxy, you should update ServerOptions.R file.

RUN echo "options(download.file.method = 'wget')" >> /usr/lib/rstudio-server/R/ServerOptions.R
RUN echo "Sys.setenv(http_proxy = 'my-proxy-url')" >> /usr/lib/rstudio-server/R/ServerOptions.R
RUN echo "Sys.setenv(https_proxy = 'my-proxy-url')" >> /usr/lib/rstudio-server/R/ServerOptions.R

Packages

Python

Users can packages with conda or pip command line.

With pip, users can install local packages for Python2 using:

$ source activate py2

$ pip install --user pkgname

And also for Python3 using:

$ source activate py3

$ pip install --user pkgname

Refer to conda documentation to install packages using conda utility.

R

Check package locations with $ R -e '.libPaths()'.

System packages will be installed at /usr/lib64/R/library.

Each user can have a local package dir, automatically created under ~/R.

root user will add packages with R -e 'install.packages("pkg-name")' command.

Julia

Since Julia v1.0, system packages are disabled. Only user-level packages are supported.

To install IJulia kernel, open a terminal and use the following commands:

julia> using Pkg

julia> pkg"add IJulia"

Restart your Jupyter session. After that, a Julia notebook option should show up.

LaTeX

The Docker image comes with a LaTeX distribution that is installed using texlive tool. TeX packages can me managed using tlmgr.

System-wide packages can be installed using:

# tlmgr install [pkgname]

Users can also install local packages. To do that, a user must initialize a ~/texmf tree:

$ tlmgr init-usertree

After that, the user can install local packages using:

$ tlmgr --usermode install [pkgname]

References

math-server-docker's People

Contributors

felipenoris avatar opm22 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

math-server-docker's Issues

pip2 / pip3

Either create pip2 and pip3 links, or update docs about how to install Python packages.

use Anaconda

migrate Python installation to conda package.

Install package rugarch for R

Depends on rgl package.

install.packages('rgl') yields the following error on CentOS7:

configure: error: missing required header GL/glu.h
ERROR: configuration failed for package ‘rgl’

rjulia

Test rjulia against Julia v0.6.

RQuantLib build broken for Centos7

utils.cpp: In function ‘QuantLib::BusinessDayConvention getBusinessDayConvention(double)’:
utils.cpp:410:16: error: ‘HalfMonthModifiedFollowing’ is not a member of ‘QuantLib’
         return QuantLib::HalfMonthModifiedFollowing;
                ^
utils.cpp:412:16: error: ‘Nearest’ is not a member of ‘QuantLib’
         return QuantLib::Nearest;
                ^
utils.cpp:415:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make: *** [utils.o] Error 1
ERROR: compilation failed for package ‘RQuantLib’

tidyverse

Test tidyverse R package installation

Checklist for next release

  • add Julia 0.5 installation
  • add IJulia kernel for Julia 0.5
  • fix python's distribution package installation
  • check if it´s possible to use a single LLVM installation
  • update Python version
  • use virtualenv so that jupyter´s kernel and packages use Python 2.7.12

install latest node?

# node
ENV NODE_VER 7.6.0

RUN wget https://github.com/nodejs/node/archive/v$NODE_VER.tar.gz \
	&& tar xf v$NODE_VER.tar.gz && cd node-$NODE_VER \
	&& ./configure \
	&& make -j"$(nproc --all)" \
	&& make -j"$(nproc --all)" install \
	&& cd .. && rm -f v$NODE_VER.tar.gz && rm -rf node-$NODE_VER

# reinstall npm with the lastest version
# Workaround https://github.com/npm/npm/issues/15558
# with https://github.com/npm/npm/issues/15611#issuecomment-289133810
RUN npm install npm \
	&& rm -rf /usr/local/lib/node_modules \
	&& mv node_modules /usr/local/lib/

# Makes npm work behind proxy if http_proxy variable is set
RUN npm config set proxy ${http_proxy} \
	&& npm config set https-proxy ${https_proxy} \
	&& npm config set registry http://registry.npmjs.org/ \
	&& npm set strict-ssl false

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.