Commit faec0b30 by Jan Wijffels

Init

parents
.Rproj.user
.Rhistory
.RData
Open sourced docker images by BNOSAC
===========================================
Contains open sourced docker images available through docker hub
- cran-mirror (dockerised mirror of CRAN: https://cran.r-project.org/)
- concerto (dockerised version of concerto: http://www.psychometrics.cam.ac.uk/newconcerto)
- r-common (basic docker image for R users)
FROM ubuntu:12.04
MAINTAINER "Jan Wijffels" jwijffels@bnosac.be
ENV DEBIAN_FRONTEND noninteractive
RUN export DEBIAN_FRONTEND=noninteractive
## Set a default user
RUN useradd docker \
&& mkdir /home/docker \
&& chown docker:docker /home/docker \
&& addgroup docker staff \
&& echo "docker:docker" | chpasswd
WORKDIR /home/docker
RUN apt-get update -qq && apt-get install -y --no-install-recommends apt-utils
RUN apt-get update -qq && apt-get install -y --no-install-recommends wget locales vim-tiny sudo
## Set default locale
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen en_US.utf8 && /usr/sbin/update-locale LANG=en_US.UTF-8
ENV LC_ALL en_US.UTF-8
## Installation instructions at http://cran.r-project.org/bin/linux/ubuntu/ to obtain the latest R
RUN gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 \
&& gpg -a --export E084DAB9 | sudo apt-key add - \
&& echo "deb http://cran.at.r-project.org/bin/linux/ubuntu precise/" | tee -a /etc/apt/sources.list
# Install R
RUN apt-get update -qq && apt-get -y dist-upgrade && apt-get install -y --no-install-recommends \
libc6 \
file \
ca-certificates \
git \
psmisc \
libcurl4-openssl-dev \
software-properties-common \
libapparmor1 \
libssl0.9.8 \
supervisor \
r-base \
r-base-dev \
r-recommended \
&& wget http://download2.rstudio.org/rstudio-server-0.98.978-amd64.deb \
&& dpkg -i rstudio-server-0.98.978-amd64.deb \
&& rm rstudio-server-*-amd64.deb \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds /tmp/* /var/tmp/* \
&& apt-get autoremove -y \
&& apt-get clean -y
## Set CRAN repository
RUN echo 'options(repos = list(CRAN = "http://cran.at.r-project.org"))' >> /etc/R/Rprofile.site
## Make a user and a user directory for Rstudio, configure git and set sudo rights
## Run supervisord (https://docs.docker.com/articles/using_supervisord/ and http://supervisord.org/configuration.html) which runs the rstudio server on port 8787
RUN mkdir -p /var/log/supervisor
COPY userconf.sh /usr/bin/userconf.sh
RUN chmod +x /usr/bin/userconf.sh
COPY supervisord.conf /etc/supervisord.conf
EXPOSE 8787
##
## Concerto
##
## for mysql server popup
RUN echo mysql-server mysql-server/root_password password abc123 | debconf-set-selections
RUN echo mysql-server mysql-server/root_password_again password abc123 | debconf-set-selections
## install mysql
RUN apt-get install -y mysql-server mysql-client mysql-common apache2 libmysqlclient-dev php5 libapache2-mod-php5 php5-mysql \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds /tmp/* /var/tmp/* \
&& apt-get autoremove -y \
&& apt-get clean -y
## Set up the concerto database
RUN /usr/sbin/mysqld & \
sleep 10 &&\
mysql --user=root --password=abc123 -e "create database db_master_name"; \
mysql --user=root --password=abc123 -e "GRANT ALL PRIVILEGES ON *.* TO 'db_master_user'@'%' IDENTIFIED BY 'db_password' WITH GRANT OPTION;"
## Follow the installation steps of Concerto regarding php settings
RUN sed -ri 's/^short_open_tag\s*=\s*Off/short_open_tag = On/g' /etc/php5/apache2/php.ini
RUN sed -ri 's/^short_open_tag\s*=\s*Off/short_open_tag = On/g' /etc/php5/cli/php.ini
## Get concerto
RUN wget https://concerto-platform.googlecode.com/files/concerto_platform_v4.0.0.beta8.zip
RUN mkdir /var/www/concerto
RUN unzip concerto_platform_v4.0.0.beta8.zip -d /var/www/concerto
RUN wget http://cran.r-project.org/src/contrib/Archive/rjson/rjson_0.2.13.tar.gz
## Install the concerto R package
RUN R CMD INSTALL rjson_0.2.13.tar.gz --library=/usr/lib/R/library
RUN R CMD build /var/www/concerto/lib/R/concerto
RUN R -e "install.packages(c('session', 'RMySQL'), lib = '/usr/lib/R/library')"
RUN R CMD INSTALL concerto_0.3.3.tar.gz --library=/usr/lib/R/library
RUN chown -R www-data /var/www/concerto
RUN chmod -R -v 777 /var/www/concerto
## Expose the MySQL and Apache port
EXPOSE 3306 80
## Start up Apache, MySQL and RStudio
CMD service apache2 start && /usr/bin/mysqld_safe && /usr/bin/supervisord --configuration=/etc/supervisord.conf
# bnosac/concerto #
Docker setup for [Concerto](https://code.google.com/p/concerto-platform/).
Concerto stands for "Computerized Adaptive Testing platform which combines R statistical engine with HTML presentation capabilities."
The bnosac/concerto docker application runs Concerto version 4.0.
Get the docker file
------------------------------
sudo docker pull bnosac/concerto
Run concerto
------------------------------
sudo docker run --tty=true --detach=true -p 80:80 -p 8787:8787 bnosac/concerto
Look for your running container and see which ip it is running at
sudo docker ps
sudo docker inspect 5974969072fb
go to http://172.17.0.4/concerto/setup to setup Concerto
go to http://172.17.0.4/concerto to see Concerto
go to http://172.17.0.4/concerto/cms/ and login with user 'admin' and password 'admin'
go to 172.17.0.4:8787 and login with user rstudio and password rstudio if you want to access RStudio
Access the shell
------------------------------------------------------------
sudo docker run --interactive=true --rm=true --tty=true bnosac/concerto /bin/bash
[supervisord]
nodaemon=true
[program:userconf]
command=/usr/bin/userconf.sh
[program:rserver]
command=/usr/lib/rstudio-server/bin/rserver
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
\ No newline at end of file
#!/bin/bash
USER=${USER:=rstudio}
PASSWORD=${PASSWORD:=rstudio}
EMAIL=${EMAIL:=bnosac-r-common@example.com}
USERID=${USERID:=1000}
ROOT=${ROOT:=TRUE}
userdel docker
useradd -m $USER -u $USERID
echo "$USER:$PASSWORD" | chpasswd
mkdir /home/$USER
chown $USER:$USER /home/$USER
## Make sure user has write access to /usr/local/lib/R/site.library
addgroup $USER staff
## Configure git
echo -e "[user]\n\tname = $USER\n\temail = $EMAIL\n\n[credential]\n\thelper = cache\n\n[push]\n\tdefault = simple\n\n[core]\n\teditor = vim\n" > /home/$USER/.gitconfig
## Global config make page-up/down search history
## echo '"\e[5~": history-search-backward' >> /etc/inputrc && echo '"\e[6~": history-search-backward' >> /etc/inputrc
# Use Env flag to know if user should be added to sudoers
if [ "$ROOT" == "TRUE" ]; then
adduser $USER sudo && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
fi
FROM ubuntu:14.04
MAINTAINER "Jan Wijffels" jwijffels@bnosac.be
ENV DEBIAN_FRONTEND noninteractive
## Create a docker user
RUN useradd docker \
&& mkdir /home/docker \
&& chown docker:docker /home/docker \
&& addgroup docker staff \
&& echo "docker:docker" | chpasswd
RUN apt-get update -qq && apt-get -y dist-upgrade && apt-get -y install openssh-server apache2 supervisor cron rsync && apt-get autoremove -y && apt-get clean -y
RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/run/sshd /var/log/supervisor
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
## Following instructions set at http://cran.r-project.org/mirror-howto.html
RUN a2enmod rewrite
RUN sed -ri '$ a\## CRAN Mirror settings' /etc/apache2/apache2.conf
RUN sed -ri '$ a\SetEnv CRAN_HOST "CRAN Mirror using bnosac/cran-mirror Docker image provided by www.bnosac.be"' /etc/apache2/apache2.conf
RUN sed -ri 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf
## Set up a crontab script to automatically synchronise the CRAN repository
ADD crontab /etc/crontab
RUN crontab /etc/crontab
EXPOSE 22 80
## The main script
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord"]
bnosac/cran-mirror
=================
Docker setup for hosting a CRAN mirror as explained at [http://cran.r-project.org/mirror-howto.html](http://cran.r-project.org/mirror-howto.html).
Features
------------------------------
The OS is Ubuntu 14.04. The docker image uses an Apache webserver and allows SSH.
The docker image synchs with the CRAN mirror cran.r-project.org on 2 timepoints
* At the start of the application
* Dayly at 02h30 UTC
The location of the CRAN mirror is synched to **/var/www/html**.
Mark that the CRAN mirror is more than 100Gb so depending on your network, it will take some time to synch for the first time the complete CRAN host.
Get the docker file
------------------------------
docker pull bnosac/cran-mirror
Example usage
------------------------------
Point the location of the CRAN mirror in the docker instance (/var/www/html) to a local directory on your computer (e.g. /home/bnosac/CRAN)
docker run -p 22:22 -p 80:80 -v /home/bnosac/CRAN/:/var/www/html -d bnosac/cran-mirror
That's it! It started synching CRAN on /home/bnosac/CRAN and will synch every day at 02h30 UTC.
You can now go to 0.0.0.0 in your browser or find the ip address where it is running and go to that address in your browser to see the R website.
docker ps
docker inspect --format '{{ .NetworkSettings.IPAddress }}' <your container ID>
You can now use your local repository to install R packages
R
install.packages('data.table', repos = "0.0.0.0")
Editing
------------------------------------------------------------
You can ssh to a running machine using ssh. Login with user docker and password docker
ssh docker@0.0.0.0
To run commands or edit settings inside the container run
docker run -v /home/bnosac/CRAN/:/var/www/html -ti bnosac/cran-mirror /bin/bash
##
## Synchronise the CRAN repository every day at 02:30 UTC
##
30 02 * * * rsync -rtlzv --delete cran.r-project.org::CRAN /var/www/html >> /var/log/cron.log 2>&1
[supervisord]
nodaemon=true
[program:sshd]
command=/usr/sbin/sshd -D
[program:apache2]
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
[program:cron]
command=cron -f
[program:rsync]
command=rsync -rtlzv --delete cran.r-project.org::CRAN /var/www/html
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
FROM ubuntu:14.04
MAINTAINER "Jan Wijffels" jwijffels@bnosac.be
ENV DEBIAN_FRONTEND noninteractive
RUN export DEBIAN_FRONTEND=noninteractive
## Set a default user
RUN useradd docker \
&& mkdir /home/docker \
&& chown docker:docker /home/docker \
&& addgroup docker staff \
&& echo "docker:docker" | chpasswd
WORKDIR /home/docker
RUN apt-get update -qq && apt-get install -y --no-install-recommends wget locales vim-tiny sudo
## Set default locale
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen en_US.utf8 && /usr/sbin/update-locale LANG=en_US.UTF-8
ENV LC_ALL en_US.UTF-8
## Installation instructions at http://cran.r-project.org/bin/linux/ubuntu/ to obtain the latest R
RUN gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
&& gpg -a --export E084DAB9 | sudo apt-key add - \
&& echo "deb http://cran.at.r-project.org/bin/linux/ubuntu trusty/" | tee -a /etc/apt/sources.list
# Install R
RUN apt-get update -qq && apt-get -y dist-upgrade && apt-get install -y --no-install-recommends \
libc6 \
file \
ca-certificates \
git \
psmisc \
libcurl4-openssl-dev \
software-properties-common \
libapparmor1 \
libssl0.9.8 \
supervisor \
r-base \
r-base-dev \
r-recommended \
&& wget http://download2.rstudio.org/rstudio-server-0.98.978-amd64.deb \
&& dpkg -i rstudio-server-0.98.978-amd64.deb \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds /tmp/* /var/tmp/* \
&& rm rstudio-server-*-amd64.deb \
&& apt-get autoremove -y \
&& apt-get clean -y
## Set CRAN repository
RUN echo 'options(repos = list(CRAN = "http://cran.at.r-project.org"))' >> /etc/R/Rprofile.site
## Make a user and a user directory for Rstudio, configure git and set sudo rights
## Run supervisord (https://docs.docker.com/articles/using_supervisord/ and http://supervisord.org/configuration.html) which runs the rstudio server on port 8787
RUN mkdir -p /var/log/supervisor
COPY userconf.sh /usr/bin/userconf.sh
RUN chmod +x /usr/bin/userconf.sh
COPY supervisord.conf /etc/supervisord.conf
EXPOSE 8787
CMD ["/usr/bin/supervisord", "--configuration=/etc/supervisord.conf"]
bnosac/r-common
=================
Docker setup for commonly used R development.
The OS is Ubuntu 14.04.
The docker application includes r-base, r-base-dev, r-recommended and sets up RStudio
Get the docker file
------------------------------
sudo docker pull bnosac/r-common
Example usage
------------------------------
sudo docker run --detach=true -p 8787:8787 bnosac/r-common
sudo docker ps
sudo docker inspect 5974969072fb
go to 172.17.0.4:8787 and login with user rstudio and password rstudio
Example usage with your own user
------------------------------------------------------------
sudo docker run --detach=true -p 8787:8787 -e USER=jwijffels -e PASSWORD=test bnosac/r-common
sudo docker ps
sudo docker inspect 5974969072fb
go to 172.17.0.4:8787 and login with user jwijffels and password test
Access the shell
------------------------------------------------------------
sudo docker run --interactive=true --rm=true --tty=true bnosac/r-common /bin/bash
[supervisord]
nodaemon=true
[program:userconf]
command=/usr/bin/userconf.sh
[program:rserver]
command=/usr/lib/rstudio-server/bin/rserver
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
\ No newline at end of file
#!/bin/bash
USER=${USER:=rstudio}
PASSWORD=${PASSWORD:=rstudio}
EMAIL=${EMAIL:=bnosac-r-common@example.com}
USERID=${USERID:=1000}
ROOT=${ROOT:=TRUE}
userdel docker
useradd -m $USER -u $USERID
echo "$USER:$PASSWORD" | chpasswd
mkdir /home/$USER
chown $USER:$USER /home/$USER
## Make sure user has write access to /usr/local/lib/R/site.library
addgroup $USER staff
## Configure git
echo -e "[user]\n\tname = $USER\n\temail = $EMAIL\n\n[credential]\n\thelper = cache\n\n[push]\n\tdefault = simple\n\n[core]\n\teditor = vim\n" > /home/$USER/.gitconfig
## Global config make page-up/down search history
## echo '"\e[5~": history-search-backward' >> /etc/inputrc && echo '"\e[6~": history-search-backward' >> /etc/inputrc
# Use Env flag to know if user should be added to sudoers
if [ "$ROOT" == "TRUE" ]; then
adduser $USER sudo && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
fi
Markdown is supported
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