In RStudio:
# setup (once) staff to be shared by admin, and default permissions 775
sudo su
gpasswd -a admin staff
echo 'umask 002' >> /etc/profile
# override RStudio's default group read only with group read & write
echo 'Sys.umask('2')\n' >> /usr/local/lib/R/etc/Rprofile.site
# vs quick fix in Terminal of rstudio.marineenergy.app: sudo chmod -R g+w *
# Add shiny to staff so has permission to install libraries into `/usr/local/lib/R/site-library` and write files
usermod -aG staff shiny
# set primary group to staff
usermod -g staff shiny
#confirm primary group set to staff
id shiny
# uid=998(shiny) gid=50(staff) groups=50(staff)
user=kimberly.bastille
pass=ch@ngemE
# userdel $user; groupdel $user
# add user inside rstudio docker container from host
useradd -m -p $(openssl passwd -crypt $pass) $user
# echo usermod -p "$pass" $user
# usermod -p $(openssl passwd -crypt $pass) $user
# setup (every user) primary group to staff
usermod -aG staff $user
usermod -aG sudo $user
usermod -aG shiny $user
usermod -g staff $user
groups $user
# setup symbolic links in home dir
ln -s /share /home/$user/share
ln -s /share/github /home/$user/github
ln -s /srv/shinyapps /home/$user/shiny-apps
ln -s /var/log/shiny-server /home/$user/shiny-logs
To change your password, in https://rstudio.ecoquants.com Terminal:
passwd
Three easy steps:
# 1. git clone the repo
cd /share/github
git clone https://github.com/NOAA-EDAB/NEespShiny
# 2. serve shiny app
sudo ln -s /share/github/NEespShiny /srv/shiny-server/NEespShiny
- view it online: https://shiny.ecoquants.com/NEespShiny/
Server software stack for MBON server serving dashboards Server Server
Contents:
- Server software
- Shell into server
- Create Server on DigitalOcean
- Install Docker
- Build containers
- Setup domain iea-ne.us
- Run docker-compose
- Docker maintenance
- TODO
-
Content management system:
-
Analytical apps:
-
Spatial engine:
-
Containerized using:
-
Infographics
- iea-ne_info info. iea-ne.us
- Connect to UCSB VPN via Secure Pulse
- SSH, eg for Ben:
sshpass -f ~/private/password_docker-iea-demo.us ssh [email protected]
Created droplet at https://digitalocean.com with [email protected] (Google login):
- Choose an image : Distributions : Marketplace :
- Docker by DigitalOcean VERSION 18.06.1 OS Ubuntu 18.04
- Choose a plan : Standard :
- iea-demo.us:
- $20 /mo $0.030 /hour
- 4 GB / 2 CPUs
- 80 GB SSD disk
- 4 TB transfer
- iea-demo.us:
- $40 /mo $0.060 /hour
- 8 GB / 4 CPUs
- 160 GB SSD disk
- 5 TB transfer
- iea-demo.us:
- Choose a datacenter region :
- San Francisco (New York currently experiencing issues)
- Authentication :
- One-time password Emails a one-time root password to you (less secure)
- How many Droplets?
- 1 Droplet
- Choose a hostname :
- iea-demo.us:
- iea-demo.us
- iea-demo.us:
DigitalOcean - iea-ne.us project
Email recieved with IP and temporary password:
-
iea-demo.us:
Your new Droplet is all set to go! You can access it using the following credentials:
Droplet Name: docker-iea-demo.us IP Address: 157.245.189.38 Username: root Password: 513dbca94734429761db936640
Have to reset password upon first login.
Saved on my Mac to a local file:
ssh [email protected]
# enter password from above
# you will be asked to change it upon login
echo S3cr!tpw > ~/private/password_docker-iea-ne.us
cat ~/private/password_docker-iea-ne.us
Since we used an image with docker
and docker-compose
already installed, we can skip this step.
References:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
# add the GPG key for the official Docker repository to your system
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# add the Docker repository to APT sources
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
# update the package database with the Docker packages from the newly added repo
sudo apt update
# install Docker
sudo apt install docker-ce
# confirm architecture
uname -a
# Linux docker-iea-ne 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
# update packages
sudo apt update
# check that it’s running
sudo systemctl status docker
# add permissions to run docker for current user
sudo usermod -aG docker ${USER}
References:
# check for latest version at https://github.com/docker/compose/releases and update in url
sudo curl -L https://github.com/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# set the permissions
sudo chmod +x /usr/local/bin/docker-compose
# verify that the installation was successful by checking the version:
docker-compose --version
# docker-compose version 1.25.4, build 8d51620a
Reference:
docker run --name test-web -p 80:80 -d nginx
# confirm working
docker ps
curl http://localhost
returns:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
Turn off:
docker stop test-web
-
Bought domain iea-demo.us for $12/yr with account [email protected].
-
DNS matched to server IP
64.225.118.240
to domain iea-demo.us via Google Domains, plus the following subdomains added under Custom resource records with: -
Type: A, Data:157.245.189.38 and Name:
- @
- wp
- gs
- rstudio
- shiny
- info
- erddap
- ckan
-
Name: www, Type: CNAME, Data:iea-ne.us
References:
- Quickstart: Compose and WordPress | Docker Documentation
- docker-compose.yml · kartoza/docker-geoserver
- How To Install WordPress With Docker Compose | DigitalOcean
First, you will create the environment .env
file to specify password and host:
- NOTE: Set
PASSWORD
, substituting "S3cr!tpw" with your password. The docker-compose.yml uses variable substitution in Docker.
# get latest docker-compose files
git clone https://github.com/marinebon/iea-server.git
cd ~/iea-server
# set environment variables
echo "PASSWORD=S3cr!tpw" > .env
echo "HOST=mbon.marine.usf.edu" >> .env
cat .env
# launch
docker-compose up -d
# Creating network "iea-server_default" with the default driver
# Creating volume "iea-server_postgis-backups" with default driver
# Creating volume "iea-server_geoserver-data" with default driver
# Creating volume "iea-server_postgis-data" with default driver
# Creating volume "iea-server_mysql-data" with default driver
# Creating volume "iea-server_wordpress-html" with default driver
# Creating volume "iea-server_shiny-apps" with default driver
# Creating volume "iea-server_erddap-data" with default driver
# Creating volume "iea-server_erddap-config" with default driver
# Creating volume "iea-server_nginx-html" with default driver
# Pulling postgis (kartoza/postgis:11.0-2.5)...
# 11.0-2.5: Pulling from kartoza/postgis
# 68ced04f60ab: Pull complete
# ...
# OR update
git pull; docker-compose up -d
# OR build if Dockerfile updated in subfolder
git pull; docker-compose up --build -d
# git pull; docker-compose up -d --no-deps --build erddap
# OR reload
docker-compose restart
# OR stop
docker-compose stop
Haven't figured out how to RUN these commands after user admin is created in rstudio-shiny container.
-
Setup permissions and shortcuts for admin in rstudio.
After logging into rstudio.iea-ne.us, to go to Terminal window and run:
sudo su - ln -s /srv/shiny-server /home/admin/shiny-apps ln -s /var/log/shiny-server /home/admin/shiny-logs mkdir /srv/github ln -s /srv/github /home/admin/github cd /srv/github git clone https://github.com/marinebon/iea-ne_info.git git clone https://github.com/marinebon/iea-uploader.git chown -R admin /srv/shiny-server chown -R admin /srv/github ln -s /usr/share/nginx/html /home/admin/info-html chown -R admin /home/admin/info-html
Since rstudio-shiny is a custom image bdbest/rstudio-shiny:s4w
, I docker-compose push to bdbest/rstudio-shiny:s4w | Docker Hub.
# login to docker hub
docker login --username=bdbest
# push updated image
docker-compose push
Note setting of HOST
to local
vs iea-ne.us
:
# get latest docker-compose files
git clone https://github.com/marinebon/iea-server.git
cd ~/iea-server
# set environment variables
echo "PASSWORD=S3cr!tpw" > .env
echo "HOST=iea-ne.us" >> .env
cat .env
# launch
docker-compose up -d
# see all containers
docker ps -a
Then visit http://localhost or http://rstudio.localhost.
TODO: try migrating volumes in /var/lib/docker onto local machine.
# stop all running containers
docker stop $(docker ps -q)
# remove all containers
docker rm $(docker ps -aq)
# remove all image
docker rmi $(docker images -q)
# remove all volumes
docker volume rm $(docker volume ls -q)
# remove all stopped containers
docker container prune
To tail the logs from the Docker containers in realtime, run:
docker-compose logs -f
docker inspect rstudio-shiny
in rstudio.iea-demo.us terminal:
cd /srv
mkdir -p github/iea-ne_apps
cd /srv/shiny-server/
mv * ../github/iea-ne_apps/.
mv .git ../github/iea-ne_apps/.
mv .gitignore ../github/iea-ne_apps/.
ln -s /srv/github/iea-ne_apps/test /srv/shiny-server/test
cd ../github
ln -s /srv/github/iea-uploader /srv/shiny-server/uploader
git pull
nc_local=./erddap/data/iea-ne/ex-chl-ppd/M_201901-MODISA-NESGRID-CHLOR_A.nc
nc_docker=erddap:/erddapData/iea-ne/ex-chl-ppd/M_201901-MODISA-NESGRID-CHLOR_A.nc
docker exec erddap bash -c "mkdir -p /erddapData/iea-ne/ex-chl-ppd"
docker exec erddap bash -c "mkdir -p /usr/local/tomcat/conf/Catalina/localhost"
docker cp $nc_local $nc_docker
docker exec -it erddap bash -c "cd /usr/local/tomcat/webapps/erddap/WEB-INF && bash GenerateDatasetsXml.sh -verbose"
Doh! Still Bad Gateway at http://erddap.iea-demo.us/
Parameters for loading M_201901-MODISA-NESGRID-CHLOR_A.nc using:
GenerateDatasetsXml.sh -verbose
- Which EDDType: EDDGridFromNcFiles
- Parent directory: /erddapData/iea-ne/ex-chl-ppd
- File name regex: .*\.*nc
- Full file name of one file: /erddapData/iea-ne/ex-chl-ppd/M_201901-MODISA-NESGRID-CHLOR_A.nc
- ReloadEveryNMinutes: 10
- cacheFromUrl:
^D
Web content:
- Rmd website served by nginx
- infographics
Shiny apps:
- data-uploader
Install:
-
ERDDAP: data server
- similar to ERDDAP | MBON, search "Hyde"
- marinebon/erddap-config: ERDDAP config files (setup.xml, datasets.xml)
-
Drupal: content management system
- drupal | Docker Hub
- used by integratedecosystemassessment.noaa.gov
- alternative to Wordpress
-
CKAN: data catalog
- similar mbon.ioos.us
- used by data.gov
- federated
-
eduwass/docker-nginx-git: Docker Image with Nginx, Git auto-pull and webhooks
-
try test migration of volumes in /data/docker on a local machine
-
add https
- "Step 4 — Obtaining SSL Certificates and Credentials" in How To Install WordPress With Docker Compose | DigitalOcean
- docker-letsencrypt-nginx-proxy-companion:
- Hosting multiple SSL-enabled sites with Docker and Nginx | Serverwise
- cron job to renew
-
add phpmyadmin for web interface to mysql wordpress database