-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM docker.io/rocker/rstudio:latest@sha256:ee7c4efa46f0b5d46e051393ef05f262aceb959463b15fc3648955965290d231 | ||
|
||
USER root | ||
RUN mkdir /safe_data /safe_outputs /scratch /root/src | ||
|
||
COPY ./src /root/src | ||
|
||
WORKDIR /root/src | ||
|
||
RUN r install_packages.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# TRE Rocker example | ||
|
||
## Running | ||
|
||
Run with `ces-run --debug --opt-file ./opt_file.txt` where `opt-file.txt` contains the following lines: | ||
|
||
```txt | ||
-p 8787:8787 | ||
-e PASSWORD=test | ||
``` | ||
|
||
Note that the password can be changed or left out entirely. In this case, the container will generate a new password to use, which will be printed in the same terminal where `ces-run` was called. | ||
|
||
## Notes | ||
|
||
This example takes a rocker image, creates the TRE file system directories and an extra directory for source files `src`. A script that produces a plot is copied inside `src`, along with another containing a list of required packages and a bash script to automate the test. The required packages are then installed through the script and the rstudio instance is started, which can be accessed at localhost:8787 using a browser. | ||
|
||
The user can run the code directly, create the plot and copy it to safe_outputs through the rstudio interface or run the `run_test.sh` script, which will perform these steps automatically. | ||
|
||
The container uses rootless mode operation by default (assumes that the user starting the container in the host is not root). When run using podman (as in `ces-run`) the login user is **root**, while in docker **rstudio**. Forcing a user change results in rstudio not starting. | ||
|
||
The example is tailored to podman, and the files are copied under the `/root/src` directory for ease of access when rstudio is first started. When using docker, they could for example be placed in `/home/rstudio/src` with appropriate permissions (the owner should be changed to the user **rstudio**). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
install.packages("ggplot2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# library | ||
library(ggplot2) | ||
|
||
# basic graph | ||
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + | ||
geom_point() | ||
|
||
# a data frame with all the annotation info | ||
annotation <- data.frame( | ||
x = c(2,4.5), | ||
y = c(20,25), | ||
label = c("label 1", "label 2") | ||
) | ||
|
||
# Add text | ||
p + geom_text(data=annotation, aes( x=x, y=y, label=label), , | ||
color="orange", | ||
size=7 , angle=45, fontface="bold" ) | ||
|
||
ggsave("test_figure.png") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
cd /root/src | ||
|
||
# Run example script | ||
r plot_example.R | ||
|
||
# Copy output to /safe_outputs | ||
mv *.png /safe_outputs |