Skip to content

OpenSILEX/opensilex-opencpu-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 

Repository files navigation

This readme allows you to install a docker image of openCPU which contains a demonstration R web application, the latest stable version of phisWSClientR package and a server version of rstudio server.

Prerequisites :

  • Access to root account
  • Able to use the 8004

1. Install automatically docker and opencpu docker container with install-docker-ocpu.sh script

Click here to see the steps to install/configure docker and install opensilex opencpu container with install-docker-ocpu.sh.

This script allow you to install easily docker, configure it for your purpose and install opensilex opencpu docker.

 Usage: install-docker-ocpu.sh [ 
          Usage: install-docker-ocpu.sh [ 
            [-i --install-all docker-rstudio-password]  regroup all other functions
            [-d --install-docker ] For Ubuntu and Debian - installation documentation date : 2019-06-14
            [-c --configure-docker] For Ubuntu and Debian  
            [-u --docker-dns-reconfigure] For Ubuntu and Debian 
            [-n --configure-network] # add 172.17.0.1 to dnsmasq for Ubuntu only
            [-o --install-ocpu-docker-with-password docker-rstudio-password] For Ubuntu and Debian
            [-h --help]
          ]

Three steps are needed to install and run this docker container :

1.1 Install docker if not installed (installation documentation date : 2019-06-14)

It is better to install docker from the official documentation

  . install-docker-ocpu.sh -d 

1.2 Configure docker for opencpu

  . install-docker-ocpu.sh -c 

1.3 Log out and reconnect to your account

1.4 Install opencpu docker

  . install-docker-ocpu.sh -o {password for rstudio server}

Example : . install-docker-ocpu.sh -o secret

If you have some issues with internet connection configuration (DNS server). You can use these following commands.

1.5 (Optional) configure docker DNS

  . install-docker-ocpu.sh -u 

If the container is successfully installed, go to the step 3.3 .

2. Install manually docker and opencpu container (If docker is already installed go to step 2.4)

Click here to see steps to install manually docker opencpu

2.5. Configure Docker as non root user

# create docker group if it doesn't exist
sudo groupadd docker
# put your user in  docker group
sudo usermod -aG docker $USER

Log out and log back in so that your group membership is re-evaluated. or use :

su - ${USER}

For more information go to https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user

2.6. Enable docker service at startup

sudo systemctl enable docker

2.7. (Optional) Configure Docker DNS which allows docker containers it to connect to internet (Only if you have issue with DNS)

2.7.1. Get servver DNS configuration

2.7.1.1. For ubuntu

Run the following command :

nmcli dev show | grep 'IP4.DNS'

The excepted result is above :

IP4.DNS[1]:                             147.100.116.5
IP4.DNS[2]:                             147.100.126.4

2.7.1.2. For debian

more  /etc/resolv.conf
# Generated by NetworkManager
nameserver 147.100.116.5
nameserver 147.100.126.4

2.7.1.3. Set right docker DNS (Informtations about DNS configuration)

2.7.1.4. Specific step for Ubuntu system (network configuration)

#A clean solution is to configure docker+dnsmasq so than DNS #requests from the docker container are forwarded to the dnsmasq #daemon running on the host.

#For that, you need to configure dnsmasq to listen to the network #interface used by docker, by adding a file /etc/NetworkManager/#dnsmasq.d/docker-bridge.conf:

sudo touch /etc/NetworkManager/dnsmasq.d/docker-bridge.conf

echo "listen-address=172.17.0.1" > /etc/NetworkManager/dnsmasq.d/docker-bridge.conf

sudo service network-manager restart

2.7.1.5. Step for Ubuntu or Debian system (docker dns configuration)

#You can add 172.17.0.1, i.e. the host's IP #address from within docker, to the list of DNS servers in docker's configuration file.

echo "{\"dns\": [\"172.17.0.1\",\"YOUR_DNS_1_IP_HERE\", \"YOUR_DNS_2_IP_HERE\", \"OTHER_DNS_IP_HERE\",....]}" > /etc/docker/daemon.json
  • daemon.json file content example :
{
  "dns": ["172.17.0.1","147.100.116.5", "147.100.126.4"]
}

2.7.1.6. Restart docker and from root:

service docker restart

3. Run docker container

3.1. Build docker image

docker build --no-cache {repository or local directory} -t opensilex/opencpu

docker build --no-cache https://github.com/OpenSILEX/opensilex-opencpu-docker.git -t opensilex/opencpu

3.2. Run docker image

  • example :
docker run -d -t -p 8004:8004 -e USER_PASSWORD=secret --name=opensilex-ocpu opensilex/opencpu:latest
# or
# if you want to link a host folder and container folder
# docker run -v {host_scripts_path}:/home/opencpu/scripts --name opencpu-server -t -p 8004:8004 opencpu/rstudio

By default, the docker file already contains "opensilex/opensilex-datavis-rapp-demo" application and "phisWSClientR" package.

3.3. Test demo application

You can now go to : http://localhost:8004/ocpu/apps/opensilex/opensilex-datavis-rapp-demo/www/ .

You will able to try the demo R application.

3.4. Stop docker container

Run in terminal :

docker stop opensilex-ocpu

3.5. Start docker container

Run in terminal :

docker start opensilex-ocpu

3.6. Remove docker container

Run in terminal :

docker stop opensilex-ocpu
docker rm opensilex-ocpu

4. How to install a custom openCPU application

You can connect to the http://{serverIp}:8004/rstudio your favorite R IDE

The default password is opencpu but it can be modified. (coming soon ...)

And run this command

opencpu::install_apps("opensilex/opensilex-datavis-rapp-demo")

or you can connect to the docker container :

docker exec -i -t container_name /bin/bash
# switch to non root user
su opencpu
# install package
R -e 'opencpu::install_apps("opensilex/opensilex-datavis-rapp-demo")'

5. How to move an R package from host to container {host_scripts_path} and install it

Click here to see steps to move an R package from host to container

5.1. From github account (recommended way)

You can connect to the http://{serverIp}:8005/rstudio your favorite R IDE

The default password is opencpu but it can be modified. (coming soon ...)

And run this command

remotes::install_github("openSILEX/phisWSClientR", build_vignettes=TRUE, ref="v1.3.0", upgrade ="always")

or you can connect to the docker container :

docker exec -i -t container_name /bin/bash
# switch to non root user
su opencpu
# install package
R -e 'remotes::install_github("openSILEX/phisWSClientR", build_vignettes=TRUE,ref="v1.3.0",upgrade ="always")'

5.2. From local directory inside the container (See 3.2 step comments before)

If you have set a link between {host_scripts_path} and /home/opencpu/scripts. You can move your R package archive (tar.gz) in {host_scripts_path} in order to be able to access it in the container.

Now can connect to the docker container and install your package from the source :

docker exec -i -t container_name /bin/bash
# switch to non root user
su opencpu
# install package
R -e 'install.packages("/home/opencpu/scripts/phisWSClientR_1.3.0.tar.gz",repos=NULL,type ="source")'

6. To uninstall docker :

Follow instructions at :

https://docs.docker.com/install/linux/docker-ce/debian/#uninstall-docker-ce

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published