niio972 / ocpu-docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This readme allows you to install a docker image of openCPU which contains a demo app and the latest version of phisWSClientR package.

Prerequisites :

  • Access to root account
  • Able to use the 8004

1. Install docker (If docker is already installed go to step 1.4)

Follow the Installation guide. (recommended)

1.1. Installation version dated from 2019-02-13 (refer to the previous link)

 sudo apt-get update

 sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg2 \
    software-properties-common

1.2. Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

# check GPG key
sudo apt-key fingerprint 0EBFCD88

pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

1.3. Use the following command to set up the stable repository.

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable"

1.4. Install docker

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io

1.4. Configure Docker as non root user

# create docker group it doesn't exist
sudo groupadd docker
# put phis user in  docker group
user=phis
sudo usermod -aG docker $user
# $USER means the connected user
# if is different from phis user run the following commands
# sudo usermod -aG docker $USER

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

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

1.5. Enable docker service at startup

sudo systemctl enable docker

1.6. Configure Docker DNS which allows docker containers it to connect to internet

1.6.1 Get servver DNS configuration

1.6.1.1. for ubuntu

Run the following command :

nmcli dev show | grep 'IP4.DNS'

The excepted result is above :

IP4.DNS[1]:                             147.99.0.248
IP4.DNS[2]:                             147.99.0.249

1.6.1.2 for debian

more  /etc/resolv.conf
# Generated by NetworkManager
nameserver 138.102.210.7
nameserver 147.100.166.31

1.6.2. Connect with root account and set right docker DNS

sudo su
echo "{\"dns\": [\"YOUR_DNS_1_IP_HERE\", \"YOUR_DNS_2_IP_HERE\"]}" > /etc/docker/daemon.json
  • daemon.json file content example :
{
  "dns": ["147.99.0.222", "147.99.0.223"]
}

1.6.3. restart docker and from root:

service docker restart

2. Run docker container

2.1 Build docker image

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

##2.2 Run docker image

  • example :
docker run -d -t -p 8004:8004  --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.

#2.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.

#2.4 Stop docker container Run in terminal :

docker stop opensilex-ocpu

#2.5 Start docker container Run in terminal :

docker start opensilex-ocpu

#2.6 Remove docker container Run in terminal :

docker stop opensilex-ocpu
docker rm opensilex-ocpu

3. 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")'

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

4.1 From github account (recommended way)

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_github("opensilex/phisWSClientR")

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/phisWSClientR")'

4.1 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.2.0.tar.gz",repos=NULL,type ="source")'

To uninstall docker :

Follow instructions at :

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

About


Languages

Language:Dockerfile 100.0%