Skip to content

Commit

Permalink
updated to rocker/tidyverse:3.6.0 and modified project template
Browse files Browse the repository at this point in the history
  • Loading branch information
pgstevenson committed May 27, 2019
1 parent 85a589f commit 5195ad5
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
certs/localhost
.Rproj.user
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RStudio

A containerized RStudio instance from the rocker base image:

rocker/tidyverse:3.5.3
rocker/tidyverse:3.6.0

This container comes with a `nginx` reverse proxy (access via. port 80)
and the Tidyverse collection of packages pre-installed by default.
Expand All @@ -19,11 +19,21 @@ The projects directory is pre-configured with a project template (00_next_projec
that is useful for projects that conform to the principles of reproducible research
and "project-as-a-package".

### Default login
### Suggested R Packages

`install.packages(c("lubridate", "ProjectTemplate"))`

### Default R Studio login

username: rstudio
password: rstudio1

Update password in `docker-compose.yml` at the following location:

Default password: rstudio1
```
environment:
- PASSWORD=rstudio1
```

## Docker Ubuntu Server Installation/Set-up

Expand Down Expand Up @@ -53,7 +63,7 @@ Default password: rstudio1
## HTTPS encryption

[These instructions](https://medium.com/@pentacent/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71)
were used to set up a secure HTTPS connection to RStuido with Certbot SSL
were used to set up a secure HTTPS connection to RStudio with Certbot SSL
certificates. Also see [here](https://github.com/wmnnd/nginx-certbot).

This will not work out of the box, the NGINX configuration file will need to be
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
container_name: nginx
restart: on-failure
networks:
- tki-net
- net
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./data/certbot/conf:/etc/letsencrypt
Expand All @@ -26,7 +26,7 @@ services:
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"

rstudio:
image: rocker/tidyverse:3.5.3
image: rocker/tidyverse:3.6.0
container_name: rstudio
restart: on-failure
volumes:
Expand All @@ -44,15 +44,15 @@ services:
volume:
no-copy: true
networks:
- tki-net
- net
environment:
- PASSWORD=rstudio1
expose:
- 8787

networks:
tki-net:
name: tki-net
name: net

volumes:
r_libs:
Expand Down
45 changes: 23 additions & 22 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,33 @@ http {
server rstudio:8787;
}

#### START REMOVE - remove this block of code if SSL certification is not wanted ####
server {
listen 80;
server_name example.org; #### UPDATE example.org to your domain name ####
server_tokens off;

location /.well-known/acme-challenge/ {
root /var/www/certbot;
}

location / {
return 301 https://$host$request_uri;
}
}
#### END REMOVE ####
# #### START BLOCK - uncomment this block to enable SSL encryption ####
# server {
# listen 80;
# server_name example.org; #### UPDATE example.org to your domain name ####
# server_tokens off;
#
# location /.well-known/acme-challenge/ {
# root /var/www/certbot;
# }
#
# location / {
# return 301 https://$host$request_uri;
# }
# }
# #### END BLOCK ####

server {
listen 443 SSL; # listen 80; #### remove "listen 443 SSL; #" statement if SSL certification is not wanted ####
listen 80; #### remove this line if SSL certification is enabled ####
# listen 443 SSL; #### uncomment this line if SSL certification is enabled ####
server_name example.org; #### UPDATE example.org to your domain name ####

#### START REMOVE - remove this block of code if SSL certification is not wanted ####
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem; #### UPDATE example.org to your domain name ####
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem; #### UPDATE example.org to your domain name ####
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
#### END REMOVE ####
# #### START BLOCK - uncomment this block to enable SSL encryption ####
# ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem; #### UPDATE example.org to your domain name ####
# ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem; #### UPDATE example.org to your domain name ####
# include /etc/letsencrypt/options-ssl-nginx.conf;
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# #### END BLOCK ####

location / {
proxy_pass http://rstudio;
Expand Down
2 changes: 2 additions & 0 deletions projects/00_next_project/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^.*\.Rproj$
^\.Rproj\.user$
21 changes: 18 additions & 3 deletions projects/00_next_project/R/00-cleaner.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# Reads raw delimited data and saves as RDS files in data folder
# created 25-May-2018 by Paul Stevenson
#' Reads raw delimited data and saves as RDS files in data folder
#' created 25-May-2018 by Paul Stevenson
#' updated 27-May-2019 by Paul Stevenson

#### libraries ----

library(dplyr)
library(readr)
library(readstata13)

#### helper functions ----

source("R/99-helper.R")

#### load data ----

dat <- read_csv("data-raw/file.csv")

devtools::use_data("var_name", overwrite = T)
#### Data cleaning ----


#### save data ----

save(dat, file = "data/dat.RData")
29 changes: 23 additions & 6 deletions projects/00_next_project/R/01-main.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
# This is the starting point for the project. load.project will load the
# data and run any scripts in the munge directory.
# Created by Paul Stevenson 17-May-2018
#' This is the starting point for the project. load.project will load the
#' data and run any scripts in the munge directory.
#' Created by Paul Stevenson 17-May-2018
#' Updated 27-May-2019 by Paul Stevenson

library('repmis')
#### libraries ----

LoadandCite(pkgs = c("tidyverse", "lubridate", "ProjectTemplate", "repmis", "biometrics"),
file = "report/assets/bib/packages.bib")
library(ProjectTemplate)
library(dplyr)

#### Project automation with Project Template ----

load.project(munging = TRUE, data_loading = TRUE)

#### load data ----

# load("data/dat.RData")
# load("cache/dat.RData")

#### helper functions ----

source("R/99-helper.R")

#### Data wrangling/cleaning ----


#### Analysis ----
8 changes: 4 additions & 4 deletions projects/00_next_project/config/global.dcf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 0.8.2
version: 0.9.0
data_loading: TRUE
data_loading_header: TRUE
data_ignore:
Expand All @@ -9,8 +9,8 @@ logging: FALSE
logging_level: INFO
load_libraries: FALSE
libraries: stats, reshape2, plyr, tidyverse
as_factors: TRUE
data_tables: FALSE
as_factors: FALSE
attach_internal_libraries: FALSE
cache_loaded_data: FALSE
cache_loaded_data: FALSE
sticky_variables: NONE
tables_type: tibble
24 changes: 23 additions & 1 deletion projects/00_next_project/munge/01-munge.R
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# Example preprocessing script.
#' Example preprocessing script.
#' Created 21-May-2019 by Paul Stevenson
#' Updated 27-May-2019 by Paul Stevenson

#### libraries ----

library(ProjectTemplate)
library(dplyr)

#### helper functions ----

source("R/99-helper.R")

#### load data ----

load("data/dat.RData")

#### Data wrangling ----


#### save data ----

cache("dat")

0 comments on commit 5195ad5

Please sign in to comment.