diff --git a/workspaces/ansible-terraform-workspace/Dockerfile b/workspaces/ansible-terraform-workspace/Dockerfile index 2ea1d4c..45f9da1 100644 --- a/workspaces/ansible-terraform-workspace/Dockerfile +++ b/workspaces/ansible-terraform-workspace/Dockerfile @@ -1,5 +1,5 @@ ARG docker_registry=docker.io/alnoda -ARG image_tag=2.2 +ARG image_tag=3.0 ## Images used: ARG BUILD_IMAGE=node:12.18.3 @@ -65,6 +65,10 @@ COPY ./mkdocs/Ara.png /home/docs/docs/assets/home/ COPY ./mkdocs/Blast-radius.png /home/docs/docs/assets/home/ COPY ./mkdocs/Terraform-Rover.png /home/docs/docs/assets/home/ COPY ./mkdocs/helpers.py /home/docs/macros +COPY ./mkdocs/terraform-circle.svg /home/docs/docs/assets/ +COPY ./mkdocs/terraform-circle-white.svg /home/docs/docs/assets/ +COPY ./mkdocs/extra.css /home/docs/docs/stylesheets/ +COPY ./mkdocs/about.md /home/docs/docs/about.md RUN apt-get -y update \ && apt-get install -y python-is-python3 \ diff --git a/workspaces/ansible-terraform-workspace/README.md b/workspaces/ansible-terraform-workspace/README.md index df39416..3574bd9 100644 --- a/workspaces/ansible-terraform-workspace/README.md +++ b/workspaces/ansible-terraform-workspace/README.md @@ -1,11 +1,11 @@

- Alnoda logo + Terraform logo

# Ansible-Terraform Workspace -Dockerized development environment for Ansible and Terraform. Workspace will help to create and manage infrastructures; -visualize planned terraform changes; display ansible hosts plays; schedule and observe executions. +Containerized development, execution and admin environment for Ansible and Terraform. +Create, provision, visualize and manage infrastructures, schedule maintenance tasks.

Collage @@ -47,29 +47,22 @@ and open [localhost:8020](http://localhost:8020) in browser. **Dev tools:** - [**Eclipse Theia**](https://theia-ide.org/docs/) - open source version of popular Visual Studio Code IDE. Theia is trully open-source, has -VS-Code extensions and works in browser. This means it can run inside a docker container on local machine or in cloud. A lot of beautiful color themes and many common plugins are already installed to save time. +VS-Code extensions and works in browser. This means it can run inside a docker container on local machine or in cloud. A lot of beautiful color themes and many common plugins are already installed to save time. - [**Terminal**](https://github.com/tsl0922/ttyd) - secure browser-based terminal. - [**FileBrowser**](https://github.com/filebrowser/filebrowser) - manage files and folders inside the workspace, and exchange data between local environment and the workspace -- [**Cronicle**](https://github.com/jhuckaby/Cronicle) - task scheduler and runner, with a web based front-end UI. It handles both scheduled, repeating and on-demand jobs, targeting any number of worker servers, with real-time stats and live log viewer. -- [**Static File Server**](https://github.com/vercel/serve) - view any static html sites as easy as if you do it on your local machine. Serve static websites easily. - [**Ungit**](https://github.com/FredrikNoren/ungit) - rings user friendliness to git without sacrificing the versatility of it. -- [**MkDocs**](https://squidfunk.github.io/mkdocs-material/) - create awesome documentation for your project with only markdown. -- [**Midnight Commander**](https://midnight-commander.org/) - Feature rich visual file manager with internal text viewer and editor. -- [**Process Monitor**](https://htop.dev/) - Monitor running process and resource utilization. -- Quicklaunch UI with getting started tutorial - -Image is built from **Ubuntu 20.4** with the additional CLI apps - -- [Zsh](https://www.zsh.org/), [Oh my Zsh](https://ohmyz.sh/) -- Python 3, Pip -- Node/nodeenv -- curl, wget, telnet, jq -- **Git:** git, git-flow, lazygit -- **File browsers:** mc, xplr -- **Text editors:** nano, vim, mcedit -- **System monitors:** ncdu, htop, glances, vizex -- **Process Control:** supervisord -- **Job scheduler:** cron +- **Ubuntu 20.4** with the following CLI apps + - [Zsh](https://www.zsh.org/), [Oh my Zsh](https://ohmyz.sh/) + - Python 3, Pip + - Node/nodeenv + - curl, wget, telnet, jq + - **Git:** git, git-flow, lazygit + - **File browsers:** mc + - **Text editors:** nano, vim, mcedit + - **System monitors:** ncdu, htop, glances, vizex + - **Process Control:** supervisord + - **Job scheduler:** cron + - **Terminal multiplexer:** tmux ## Docs diff --git a/workspaces/ansible-terraform-workspace/docs/candidates.md b/workspaces/ansible-terraform-workspace/docs/candidates.md new file mode 100644 index 0000000..dc4236e --- /dev/null +++ b/workspaces/ansible-terraform-workspace/docs/candidates.md @@ -0,0 +1,4 @@ +Tool candidates: + +- [Terraspace](https://github.com/boltops-tools/terraspace) +- [terraform-visual](https://github.com/hieven/terraform-visual) \ No newline at end of file diff --git a/workspaces/ansible-terraform-workspace/examples/ansible-local/terraform-circle.svg b/workspaces/ansible-terraform-workspace/examples/ansible-local/terraform-circle.svg new file mode 100644 index 0000000..e485ccc --- /dev/null +++ b/workspaces/ansible-terraform-workspace/examples/ansible-local/terraform-circle.svg @@ -0,0 +1,27 @@ + + + + + + Go icon + Elixir icon + R icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/ansible-terraform-workspace/img/terraform-circle.svg b/workspaces/ansible-terraform-workspace/img/terraform-circle.svg new file mode 100644 index 0000000..e485ccc --- /dev/null +++ b/workspaces/ansible-terraform-workspace/img/terraform-circle.svg @@ -0,0 +1,27 @@ + + + + + + Go icon + Elixir icon + R icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/ansible-terraform-workspace/mkdocs/Ara.png b/workspaces/ansible-terraform-workspace/mkdocs/Ara.png index 75f4820..a6635a5 100644 Binary files a/workspaces/ansible-terraform-workspace/mkdocs/Ara.png and b/workspaces/ansible-terraform-workspace/mkdocs/Ara.png differ diff --git a/workspaces/ansible-terraform-workspace/mkdocs/about.md b/workspaces/ansible-terraform-workspace/mkdocs/about.md new file mode 100644 index 0000000..eb3d0a4 --- /dev/null +++ b/workspaces/ansible-terraform-workspace/mkdocs/about.md @@ -0,0 +1,2 @@ +Containerized development, execution and admin environment for Ansible and Terraform. +Create, provision, visualize and manage infrastructures, schedule maintenance tasks. \ No newline at end of file diff --git a/workspaces/ansible-terraform-workspace/mkdocs/extra.css b/workspaces/ansible-terraform-workspace/mkdocs/extra.css new file mode 100644 index 0000000..31b0013 --- /dev/null +++ b/workspaces/ansible-terraform-workspace/mkdocs/extra.css @@ -0,0 +1,20 @@ +[data-md-color-scheme="terraform"] { + --md-primary-fg-color: #241B2F; + --md-primary-fg-color--light: #7747A7; + --md-primary-fg-color--dark: #7747A7; + --md-accent-fg-color: #5C41E2; + + --md-default-bg-color: #FFFFFF; + --md-typeset-a-color: #604270; +} + +[data-md-color-scheme="terraform-dark"] { + --md-primary-fg-color: #7747A7; + --md-accent-fg-color: #DF736A; + + --md-default-bg-color: #171520; + --md-default-fg-color--light: #604270; + --md-typeset-color: #FFFFFF; + --md-typeset-a-color: #83698E; +} + diff --git a/workspaces/ansible-terraform-workspace/mkdocs/mkdocs.yml b/workspaces/ansible-terraform-workspace/mkdocs/mkdocs.yml index 7fa9f76..d983602 100644 --- a/workspaces/ansible-terraform-workspace/mkdocs/mkdocs.yml +++ b/workspaces/ansible-terraform-workspace/mkdocs/mkdocs.yml @@ -5,14 +5,14 @@ nav: - Home: README.md - My apps: pages/my-apps.md + - About: about.md - Docs: https://docs.alnoda.org/ansible-terraform-workspace/ - # =========================================================== # CONFIGURATION # =========================================================== -site_name: Infra Workspace +site_name: Ansible-terraform workspace repo_url: https://github.com/bluxmit/alnoda-workspaces site_url: https://docs.alnoda.org edit_uri: "" @@ -23,26 +23,24 @@ edit_uri: "" theme: name: 'material' - favicon: 'assets/favicon.ico' - logo: 'assets/Alnoda-logo.svg' + favicon: 'assets/terraform-circle.svg' + logo: 'assets/terraform-circle-white.svg' custom_dir: overrides + font: + text: PT Sans icon: - repo: fontawesome/brands/git-alt + repo: fontawesome/brands/github features: - navigation.instant palette: - - scheme: default + - scheme: terraform toggle: - icon: material/toggle-switch-off-outline - name: Switch to light mode - primary: red - accent: orange - - scheme: slate - toggle: - icon: material/toggle-switch + icon: material/brightness-7 name: Switch to dark mode - primary: red - accent: orange + - scheme: terraform-dark + toggle: + icon: material/brightness-4 + name: Switch to light mode extra: # Link to open when your logo is clicked @@ -50,21 +48,14 @@ extra: host_url: http://docs.alnoda.org plugins: - - search # Enable Macros and jinja2 templates - macros: module_name: macros/helpers +extra_css: + - stylesheets/extra.css extra_javascript: - javascripts/config.js - https://polyfill.io/v3/polyfill.min.js?features=es6 - - - - - - - - diff --git a/workspaces/ansible-terraform-workspace/mkdocs/terraform-circle-white.svg b/workspaces/ansible-terraform-workspace/mkdocs/terraform-circle-white.svg new file mode 100644 index 0000000..0aa6991 --- /dev/null +++ b/workspaces/ansible-terraform-workspace/mkdocs/terraform-circle-white.svg @@ -0,0 +1,27 @@ + + + + + + Go icon + Elixir icon + R icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/ansible-terraform-workspace/mkdocs/terraform-circle.svg b/workspaces/ansible-terraform-workspace/mkdocs/terraform-circle.svg new file mode 100644 index 0000000..e485ccc --- /dev/null +++ b/workspaces/ansible-terraform-workspace/mkdocs/terraform-circle.svg @@ -0,0 +1,27 @@ + + + + + + Go icon + Elixir icon + R icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/erlang-elixir-workspace/Dockerfile b/workspaces/erlang-elixir-workspace/Dockerfile index 92da880..df86fc8 100644 --- a/workspaces/erlang-elixir-workspace/Dockerfile +++ b/workspaces/erlang-elixir-workspace/Dockerfile @@ -1,10 +1,14 @@ ARG docker_registry=docker.io/alnoda -ARG image_tag=2.2-17 +ARG image_tag=3.0-17 FROM ${docker_registry}/java-workspace:${image_tag} USER root -COPY ./mkdocs/mkdocs.yml /home/docs/mkdocs.yml +COPY ./mkdocs/mkdocs.yml /home/docs/mkdocs.yml +COPY ./mkdocs/elixir-circle.svg /home/docs/docs/assets/ +COPY ./mkdocs/elixir-circle-white.svg /home/docs/docs/assets/ +COPY ./mkdocs/extra.css /home/docs/docs/stylesheets/ +COPY ./mkdocs/about.md /home/docs/docs/about.md RUN apt-get -y update \ && echo "------------------------------------------------------ Erlang requirements" \ diff --git a/workspaces/erlang-elixir-workspace/README.md b/workspaces/erlang-elixir-workspace/README.md index d303cdf..f23ec63 100644 --- a/workspaces/erlang-elixir-workspace/README.md +++ b/workspaces/erlang-elixir-workspace/README.md @@ -1,14 +1,11 @@

- Alnoda logo -

+ Elixir logo +

-# Erlang-Elixir workspace +# Erlang-elixir workspace -Docker image with Erlang, Elixir and browser-based VS-Code version. +Containerized isolated development environment for Erlang and Elixir programming languages. -

- Collage -

## Why this images @@ -32,30 +29,23 @@ and open [localhost:8020](http://localhost:8020) in browser. **Dev tools:** -- [**Code-server**](https://github.com/cdr/code-server) - open source version of popular Visual Studio Code IDE. Codeserver has -VS-Code extensions and works in browser. +- [**Eclipse Theia**](https://theia-ide.org/docs/) - open source version of popular Visual Studio Code IDE. Theia is trully open-source, has +VS-Code extensions and works in browser. This means it can run inside a docker container on local machine or in cloud. A lot of beautiful color themes and many common plugins are already installed to save time. - [**Terminal**](https://github.com/tsl0922/ttyd) - secure browser-based terminal. - [**FileBrowser**](https://github.com/filebrowser/filebrowser) - manage files and folders inside the workspace, and exchange data between local environment and the workspace -- [**Cronicle**](https://github.com/jhuckaby/Cronicle) - task scheduler and runner, with a web based front-end UI. It handles both scheduled, repeating and on-demand jobs, targeting any number of worker servers, with real-time stats and live log viewer. -- [**Static File Server**](https://github.com/vercel/serve) - view any static html sites as easy as if you do it on your local machine. Serve static websites easily. - [**Ungit**](https://github.com/FredrikNoren/ungit) - rings user friendliness to git without sacrificing the versatility of it. -- [**MkDocs**](https://squidfunk.github.io/mkdocs-material/) - create awesome documentation for your project with only markdown. -- [**Midnight Commander**](https://midnight-commander.org/) - Feature rich visual file manager with internal text viewer and editor. -- [**Process Monitor**](https://htop.dev/) - Monitor running process and resource utilization. -- Quicklaunch UI with getting started tutorial - -Image is built from **Ubuntu 20.4** with the additional CLI apps - -- [Zsh](https://www.zsh.org/), [Oh my Zsh](https://ohmyz.sh/) -- Python 3, Pip -- Node/nodeenv -- curl, wget, telnet, jq -- **Git:** git, git-flow, lazygit -- **File browsers:** mc, xplr -- **Text editors:** nano, vim, mcedit -- **System monitors:** ncdu, htop, glances, vizex -- **Process Control:** supervisord -- **Job scheduler:** cron +- **Ubuntu 20.4** with the following CLI apps + - [Zsh](https://www.zsh.org/), [Oh my Zsh](https://ohmyz.sh/) + - Python 3, Pip + - Node/nodeenv + - curl, wget, telnet, jq + - **Git:** git, git-flow, lazygit + - **File browsers:** mc + - **Text editors:** nano, vim, mcedit + - **System monitors:** ncdu, htop, glances, vizex + - **Process Control:** supervisord + - **Job scheduler:** cron + - **Terminal multiplexer:** tmux ## Docs diff --git a/workspaces/erlang-elixir-workspace/img/elixir-circle.svg b/workspaces/erlang-elixir-workspace/img/elixir-circle.svg new file mode 100644 index 0000000..d636e3a --- /dev/null +++ b/workspaces/erlang-elixir-workspace/img/elixir-circle.svg @@ -0,0 +1,26 @@ + + + + + + Go icon + Elixir icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/erlang-elixir-workspace/mkdocs/about.md b/workspaces/erlang-elixir-workspace/mkdocs/about.md new file mode 100644 index 0000000..13eb9ec --- /dev/null +++ b/workspaces/erlang-elixir-workspace/mkdocs/about.md @@ -0,0 +1 @@ +Containerized isolated development environment for Erlang and Elixir programming languages. \ No newline at end of file diff --git a/workspaces/erlang-elixir-workspace/mkdocs/elixir-circle-white.svg b/workspaces/erlang-elixir-workspace/mkdocs/elixir-circle-white.svg new file mode 100644 index 0000000..5b6353d --- /dev/null +++ b/workspaces/erlang-elixir-workspace/mkdocs/elixir-circle-white.svg @@ -0,0 +1,26 @@ + + + + + + Go icon + Elixir icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/erlang-elixir-workspace/mkdocs/elixir-circle.svg b/workspaces/erlang-elixir-workspace/mkdocs/elixir-circle.svg new file mode 100644 index 0000000..d636e3a --- /dev/null +++ b/workspaces/erlang-elixir-workspace/mkdocs/elixir-circle.svg @@ -0,0 +1,26 @@ + + + + + + Go icon + Elixir icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/erlang-elixir-workspace/mkdocs/extra.css b/workspaces/erlang-elixir-workspace/mkdocs/extra.css new file mode 100644 index 0000000..3576c1a --- /dev/null +++ b/workspaces/erlang-elixir-workspace/mkdocs/extra.css @@ -0,0 +1,20 @@ +[data-md-color-scheme="elixir"] { + --md-primary-fg-color: #604270; + --md-primary-fg-color--light: #c9af06; + --md-primary-fg-color--dark: #604270; + --md-accent-fg-color: #07B6AB; + + --md-default-bg-color: #FFFFFF; + --md-typeset-a-color: #604270; +} + +[data-md-color-scheme="elixir-dark"] { + --md-primary-fg-color: #83698E; + --md-accent-fg-color: #07B6AB; + + --md-default-bg-color: #232834; + --md-default-fg-color--light: #604270; + --md-typeset-color: #FFFFFF; + --md-typeset-a-color: #83698E; +} + diff --git a/workspaces/erlang-elixir-workspace/mkdocs/mkdocs.yml b/workspaces/erlang-elixir-workspace/mkdocs/mkdocs.yml index e3682d5..84fe254 100644 --- a/workspaces/erlang-elixir-workspace/mkdocs/mkdocs.yml +++ b/workspaces/erlang-elixir-workspace/mkdocs/mkdocs.yml @@ -5,14 +5,14 @@ nav: - Home: README.md - My apps: pages/my-apps.md + - About: about.md - Docs: https://docs.alnoda.org/erlang-elixir-workspace/ - # =========================================================== # CONFIGURATION # =========================================================== -site_name: Erlang-Elixir workspace +site_name: Erlang-elixir workspace repo_url: https://github.com/bluxmit/alnoda-workspaces site_url: https://docs.alnoda.org edit_uri: "" @@ -23,26 +23,24 @@ edit_uri: "" theme: name: 'material' - favicon: 'assets/favicon.ico' - logo: 'assets/Alnoda-logo.svg' + favicon: 'assets/elixir-circle.svg' + logo: 'assets/elixir-circle-white.svg' custom_dir: overrides + font: + text: PT Sans icon: - repo: fontawesome/brands/git-alt + repo: fontawesome/brands/github features: - navigation.instant palette: - - scheme: default + - scheme: elixir toggle: - icon: material/toggle-switch-off-outline - name: Switch to light mode - primary: deep purple - accent: indigo - - scheme: slate - toggle: - icon: material/toggle-switch + icon: material/brightness-7 name: Switch to dark mode - primary: deep purple - accent: yellow + - scheme: elixir-dark + toggle: + icon: material/brightness-4 + name: Switch to light mode extra: # Link to open when your logo is clicked @@ -50,21 +48,14 @@ extra: host_url: http://docs.alnoda.org plugins: - - search # Enable Macros and jinja2 templates - macros: module_name: macros/helpers +extra_css: + - stylesheets/extra.css extra_javascript: - javascripts/config.js - https://polyfill.io/v3/polyfill.min.js?features=es6 - - - - - - - - diff --git a/workspaces/go-workspace/Dockerfile b/workspaces/go-workspace/Dockerfile index 8b0558d..d15fd0d 100644 --- a/workspaces/go-workspace/Dockerfile +++ b/workspaces/go-workspace/Dockerfile @@ -1,11 +1,15 @@ ARG docker_registry=docker.io/alnoda -ARG image_tag=2.2 +ARG image_tag=3.0 ARG ruby_global_version=3.1.2 -FROM ${docker_registry}/codeserver-workspace:${image_tag} +FROM ${docker_registry}/theia-workspace:${image_tag} USER root COPY ./mkdocs/mkdocs.yml /home/docs/mkdocs.yml +COPY ./mkdocs/go-circle.svg /home/docs/docs/assets/ +COPY ./mkdocs/go-circle-white.svg /home/docs/docs/assets/ +COPY ./mkdocs/extra.css /home/docs/docs/stylesheets/ +COPY ./mkdocs/about.md /home/docs/docs/about.md RUN apt-get -y update \ && echo "------------------------------------------------------ go " \ diff --git a/workspaces/go-workspace/README.md b/workspaces/go-workspace/README.md index e18c4e1..7698513 100644 --- a/workspaces/go-workspace/README.md +++ b/workspaces/go-workspace/README.md @@ -1,14 +1,10 @@

- Alnoda logo + Go logo

# Go workspace -Docker image with Go and browser-based VS-Code version. - -

- Collage -

+Containerized isolated development environment for Go programming language. ## Why this images @@ -29,30 +25,23 @@ and open [localhost:8020](http://localhost:8020) in browser. **Dev tools:** -- [**Code-server**](https://github.com/cdr/code-server) - open source version of popular Visual Studio Code IDE. Codeserver has -VS-Code extensions and works in browser. +- [**Eclipse Theia**](https://theia-ide.org/docs/) - open source version of popular Visual Studio Code IDE. Theia is trully open-source, has +VS-Code extensions and works in browser. This means it can run inside a docker container on local machine or in cloud. A lot of beautiful color themes and many common plugins are already installed to save time. - [**Terminal**](https://github.com/tsl0922/ttyd) - secure browser-based terminal. - [**FileBrowser**](https://github.com/filebrowser/filebrowser) - manage files and folders inside the workspace, and exchange data between local environment and the workspace -- [**Cronicle**](https://github.com/jhuckaby/Cronicle) - task scheduler and runner, with a web based front-end UI. It handles both scheduled, repeating and on-demand jobs, targeting any number of worker servers, with real-time stats and live log viewer. -- [**Static File Server**](https://github.com/vercel/serve) - view any static html sites as easy as if you do it on your local machine. Serve static websites easily. - [**Ungit**](https://github.com/FredrikNoren/ungit) - rings user friendliness to git without sacrificing the versatility of it. -- [**MkDocs**](https://squidfunk.github.io/mkdocs-material/) - create awesome documentation for your project with only markdown. -- [**Midnight Commander**](https://midnight-commander.org/) - Feature rich visual file manager with internal text viewer and editor. -- [**Process Monitor**](https://htop.dev/) - Monitor running process and resource utilization. -- Quicklaunch UI with getting started tutorial - -Image is built from **Ubuntu 20.4** with the additional CLI apps - -- [Zsh](https://www.zsh.org/), [Oh my Zsh](https://ohmyz.sh/) -- Python 3, Pip -- Node/nodeenv -- curl, wget, telnet, jq -- **Git:** git, git-flow, lazygit -- **File browsers:** mc, xplr -- **Text editors:** nano, vim, mcedit -- **System monitors:** ncdu, htop, glances, vizex -- **Process Control:** supervisord -- **Job scheduler:** cron +- **Ubuntu 20.4** with the following CLI apps + - [Zsh](https://www.zsh.org/), [Oh my Zsh](https://ohmyz.sh/) + - Python 3, Pip + - Node/nodeenv + - curl, wget, telnet, jq + - **Git:** git, git-flow, lazygit + - **File browsers:** mc + - **Text editors:** nano, vim, mcedit + - **System monitors:** ncdu, htop, glances, vizex + - **Process Control:** supervisord + - **Job scheduler:** cron + - **Terminal multiplexer:** tmux ## Docs diff --git a/workspaces/go-workspace/img/go-circle.svg b/workspaces/go-workspace/img/go-circle.svg new file mode 100644 index 0000000..d7a112a --- /dev/null +++ b/workspaces/go-workspace/img/go-circle.svg @@ -0,0 +1,25 @@ + + + + + + Go icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/go-workspace/mkdocs/about.md b/workspaces/go-workspace/mkdocs/about.md new file mode 100644 index 0000000..4ff1383 --- /dev/null +++ b/workspaces/go-workspace/mkdocs/about.md @@ -0,0 +1 @@ +Containerized isolated development environment for Go programming language. \ No newline at end of file diff --git a/workspaces/go-workspace/mkdocs/extra.css b/workspaces/go-workspace/mkdocs/extra.css new file mode 100644 index 0000000..adc218c --- /dev/null +++ b/workspaces/go-workspace/mkdocs/extra.css @@ -0,0 +1,20 @@ +[data-md-color-scheme="go"] { + --md-primary-fg-color: #007D9C; + --md-primary-fg-color--light: #c9af06; + --md-primary-fg-color--dark: #DC322F; + --md-accent-fg-color: #c9af06; + + --md-default-bg-color: #FFFFFF; + --md-typeset-a-color: #007D9C; +} + +[data-md-color-scheme="go-dark"] { + --md-primary-fg-color: #007D9C; + --md-accent-fg-color: #c9af06; + + --md-default-bg-color: #010d14; + --md-default-fg-color--light: #c9af06; + --md-typeset-color: #FFFFFF; + --md-typeset-a-color: #79D4FD; +} + diff --git a/workspaces/go-workspace/mkdocs/go-circle-white.svg b/workspaces/go-workspace/mkdocs/go-circle-white.svg new file mode 100644 index 0000000..4065167 --- /dev/null +++ b/workspaces/go-workspace/mkdocs/go-circle-white.svg @@ -0,0 +1,25 @@ + + + + + + Go icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/go-workspace/mkdocs/go-circle.svg b/workspaces/go-workspace/mkdocs/go-circle.svg new file mode 100644 index 0000000..d7a112a --- /dev/null +++ b/workspaces/go-workspace/mkdocs/go-circle.svg @@ -0,0 +1,25 @@ + + + + + + Go icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/go-workspace/mkdocs/mkdocs.yml b/workspaces/go-workspace/mkdocs/mkdocs.yml index 78ad0b1..fadb8b7 100644 --- a/workspaces/go-workspace/mkdocs/mkdocs.yml +++ b/workspaces/go-workspace/mkdocs/mkdocs.yml @@ -5,9 +5,9 @@ nav: - Home: README.md - My apps: pages/my-apps.md + - About: about.md - Docs: https://docs.alnoda.org/go-workspace/ - # =========================================================== # CONFIGURATION # =========================================================== @@ -23,26 +23,24 @@ edit_uri: "" theme: name: 'material' - favicon: 'assets/favicon.ico' - logo: 'assets/Alnoda-logo.svg' + favicon: 'assets/go-circle.svg' + logo: 'assets/go-circle-white.svg' custom_dir: overrides + font: + text: Open Sans icon: - repo: fontawesome/brands/git-alt + repo: fontawesome/brands/github features: - navigation.instant palette: - - scheme: default + - scheme: go toggle: - icon: material/toggle-switch-off-outline - name: Switch to light mode - primary: light blue - accent: light blue - - scheme: slate - toggle: - icon: material/toggle-switch + icon: material/brightness-7 name: Switch to dark mode - primary: light blue - accent: light blue + - scheme: go-dark + toggle: + icon: material/brightness-4 + name: Switch to light mode extra: # Link to open when your logo is clicked @@ -50,21 +48,13 @@ extra: host_url: http://docs.alnoda.org plugins: - - search # Enable Macros and jinja2 templates - macros: module_name: macros/helpers +extra_css: + - stylesheets/extra.css extra_javascript: - javascripts/config.js - https://polyfill.io/v3/polyfill.min.js?features=es6 - - - - - - - - - diff --git a/workspaces/kubespray-workspace/mkdocs/extra.css b/workspaces/kubespray-workspace/mkdocs/extra.css new file mode 100644 index 0000000..5dcfd97 --- /dev/null +++ b/workspaces/kubespray-workspace/mkdocs/extra.css @@ -0,0 +1,20 @@ +[data-md-color-scheme="k8s"] { + --md-primary-fg-color: #316CE6; + --md-primary-fg-color--light: #7747A7; + --md-primary-fg-color--dark: #7747A7; + --md-accent-fg-color: #1040a1; + + --md-default-bg-color: #FFFFFF; + --md-typeset-a-color: #303030; +} + +[data-md-color-scheme="k8s-dark"] { + --md-primary-fg-color: #316CE6; + --md-accent-fg-color: #DF736A; + + --md-default-bg-color: #232834; + --md-default-fg-color--light: #E3EAF2; + --md-typeset-color: #E3EAF2; + --md-typeset-a-color: #E3EAF2; +} + diff --git a/workspaces/kubespray-workspace/mkdocs/mkdocs.yml b/workspaces/kubespray-workspace/mkdocs/mkdocs.yml index 97b2bae..4211903 100644 --- a/workspaces/kubespray-workspace/mkdocs/mkdocs.yml +++ b/workspaces/kubespray-workspace/mkdocs/mkdocs.yml @@ -5,9 +5,9 @@ nav: - Home: README.md - My apps: pages/my-apps.md + - About: about.md - Docs: https://docs.alnoda.org/kubespray-workspace/ - # =========================================================== # CONFIGURATION # =========================================================== @@ -23,26 +23,24 @@ edit_uri: "" theme: name: 'material' - favicon: 'assets/favicon.ico' - logo: 'assets/Alnoda-logo.svg' + favicon: 'assets/k8s-circle.svg' + logo: 'assets/k8s-circle-white.svg' custom_dir: overrides + font: + text: Roboto icon: - repo: fontawesome/brands/git-alt + repo: fontawesome/brands/github features: - navigation.instant palette: - - scheme: default + - scheme: k8s toggle: - icon: material/toggle-switch-off-outline - name: Switch to light mode - primary: indigo - accent: blue - - scheme: slate - toggle: - icon: material/toggle-switch + icon: material/brightness-7 name: Switch to dark mode - primary: indigo - accent: blue + - scheme: k8s-dark + toggle: + icon: material/brightness-4 + name: Switch to light mode extra: # Link to open when your logo is clicked @@ -50,21 +48,14 @@ extra: host_url: http://docs.alnoda.org plugins: - - search # Enable Macros and jinja2 templates - macros: module_name: macros/helpers +extra_css: + - stylesheets/extra.css extra_javascript: - javascripts/config.js - https://polyfill.io/v3/polyfill.min.js?features=es6 - - - - - - - - diff --git a/workspaces/r-workspace/Dockerfile b/workspaces/r-workspace/Dockerfile index d510266..57b5f2d 100644 --- a/workspaces/r-workspace/Dockerfile +++ b/workspaces/r-workspace/Dockerfile @@ -1,15 +1,20 @@ ARG docker_registry=docker.io/alnoda -ARG image_tag=2.2 +ARG image_tag=3.0 FROM ${docker_registry}/base-workspace:${image_tag} USER root -COPY supervisord-rstudio.conf /etc/supervisord/ +# COPY supervisord-rstudio.conf /etc/supervisord/ +COPY rocker_scripts /rocker_scripts COPY ./mkdocs/mkdocs.yml /home/docs/mkdocs.yml COPY ./mkdocs/helpers.py /home/docs/macros COPY ./mkdocs/RStudio.png /home/docs/docs/assets/home/ COPY ./mkdocs/README.md /home/docs/docs/README.md +COPY ./mkdocs/r-circle.svg /home/docs/docs/assets/ +COPY ./mkdocs/r-circle-white.svg /home/docs/docs/assets/ +COPY ./mkdocs/extra.css /home/docs/docs/stylesheets/ +COPY ./mkdocs/about.md /home/docs/docs/about.md ### R ENV R_VERSION=4.2.0 \ @@ -26,18 +31,19 @@ ENV R_VERSION=4.2.0 \ ENV PATH=/usr/local/bin/:$PATH ENV PATH=/usr/lib/rstudio-server/bin:$PATH -RUN cd /tmp && git clone https://github.com/rocker-org/rocker-versioned2.git \ - && mv /tmp/rocker-versioned2/scripts /rocker_scripts \ +RUN echo "------------------------------------------------------ R & R-Studio" \ + && find /rocker_scripts/ -type f -iname "*.sh" -exec chmod +x {} \; \ && bash /rocker_scripts/install_R_source.sh \ && bash /rocker_scripts/setup_R.sh \ && mkdir /var/log/rstudio \ && bash /rocker_scripts/install_rstudio.sh \ - && rstudio-server stop || true \ + && rstudio-server stop \ + && rm -rf /rocker_scripts \ && echo "------------------------------------------------------ user" \ && chown -R abc /etc/rstudio \ && chown -R abc /usr/lib/rstudio-server \ && chown -R abc /var/lib/rstudio-server \ - && chown -R abc /var/log/rstudio \ + && chown -R abc /var/log/rstudio \ && chown -R abc /usr/local/lib/R \ && mkdir /home/abc/.rserver && chown -R abc /home/abc/.rserver \ && find /home -type d | xargs -I{} chown -R abc {} \ @@ -45,7 +51,7 @@ RUN cd /tmp && git clone https://github.com/rocker-org/rocker-versioned2.git \ USER abc -COPY rstudio/database.conf /home/abc/.rserver +COPY rstudio/database.conf /home/abc/.rserver/ ENV USER=abc RUN echo "------------------------------------------------------ some cleaning because Rstudio workdir is /home/abc/" \ diff --git a/workspaces/r-workspace/README.md b/workspaces/r-workspace/README.md index b6994f6..4d016f5 100644 --- a/workspaces/r-workspace/README.md +++ b/workspaces/r-workspace/README.md @@ -1,10 +1,11 @@

- Alnoda logo + R logo

# R workspace -Docker image with R and browser-based RStudio version. +Development and execution environment for R programming language. +Experiment, prototype, code and schedule executions.

Collage @@ -34,26 +35,19 @@ and open [localhost:8020](http://localhost:8020) in browser. - **RStudio server** - open source version of popular R IDE, browser-based. - [**Terminal**](https://github.com/tsl0922/ttyd) - secure browser-based terminal. - [**FileBrowser**](https://github.com/filebrowser/filebrowser) - manage files and folders inside the workspace, and exchange data between local environment and the workspace -- [**Cronicle**](https://github.com/jhuckaby/Cronicle) - task scheduler and runner, with a web based front-end UI. It handles both scheduled, repeating and on-demand jobs, targeting any number of worker servers, with real-time stats and live log viewer. -- [**Static File Server**](https://github.com/vercel/serve) - view any static html sites as easy as if you do it on your local machine. Serve static websites easily. - [**Ungit**](https://github.com/FredrikNoren/ungit) - rings user friendliness to git without sacrificing the versatility of it. -- [**MkDocs**](https://squidfunk.github.io/mkdocs-material/) - create awesome documentation for your project with only markdown. -- [**Midnight Commander**](https://midnight-commander.org/) - Feature rich visual file manager with internal text viewer and editor. -- [**Process Monitor**](https://htop.dev/) - Monitor running process and resource utilization. -- Quicklaunch UI with getting started tutorial - -Image is built from **Ubuntu 20.4** with the additional CLI apps - -- [Zsh](https://www.zsh.org/), [Oh my Zsh](https://ohmyz.sh/) -- Python 3, Pip -- Node/nodeenv -- curl, wget, telnet, jq -- **Git:** git, git-flow, lazygit -- **File browsers:** mc, xplr -- **Text editors:** nano, vim, mcedit -- **System monitors:** ncdu, htop, glances, vizex -- **Process Control:** supervisord -- **Job scheduler:** cron +- **Ubuntu 20.4** with the following CLI apps + - [Zsh](https://www.zsh.org/), [Oh my Zsh](https://ohmyz.sh/) + - Python 3, Pip + - Node/nodeenv + - curl, wget, telnet, jq + - **Git:** git, git-flow, lazygit + - **File browsers:** mc + - **Text editors:** nano, vim, mcedit + - **System monitors:** ncdu, htop, glances, vizex + - **Process Control:** supervisord + - **Job scheduler:** cron + - **Terminal multiplexer:** tmux ## Docs diff --git a/workspaces/r-workspace/img/r-circle.svg b/workspaces/r-workspace/img/r-circle.svg new file mode 100644 index 0000000..0d7d0d0 --- /dev/null +++ b/workspaces/r-workspace/img/r-circle.svg @@ -0,0 +1,27 @@ + + + + + + Go icon + Elixir icon + R icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/r-workspace/mkdocs/about.md b/workspaces/r-workspace/mkdocs/about.md new file mode 100644 index 0000000..acdeabc --- /dev/null +++ b/workspaces/r-workspace/mkdocs/about.md @@ -0,0 +1,2 @@ +Development and execution environment for R programming language. +Experiment, prototype, code and schedule executions. \ No newline at end of file diff --git a/workspaces/r-workspace/mkdocs/extra.css b/workspaces/r-workspace/mkdocs/extra.css new file mode 100644 index 0000000..7d32269 --- /dev/null +++ b/workspaces/r-workspace/mkdocs/extra.css @@ -0,0 +1,20 @@ +[data-md-color-scheme="r"] { + --md-primary-fg-color: #1B5FAF; + --md-default-fg-color--light: #1B5FAF; + --md-default-fg-color--dark: #604270; + --md-accent-fg-color: #1B5FAF; + + --md-default-bg-color: #FFFFFF; + --md-typeset-a-color: #B4B4B7; +} + +[data-md-color-scheme="r-dark"] { + --md-primary-fg-color: #8492BA; + --md-accent-fg-color: #8492BA; + + --md-default-bg-color: #3C3C3C; + --md-default-fg-color--light: #8492BA; + --md-typeset-color: #FFFFFF; + --md-typeset-a-color: #B4B4B7; +} + diff --git a/workspaces/r-workspace/mkdocs/mkdocs.yml b/workspaces/r-workspace/mkdocs/mkdocs.yml index c3c12e4..1a24bf8 100644 --- a/workspaces/r-workspace/mkdocs/mkdocs.yml +++ b/workspaces/r-workspace/mkdocs/mkdocs.yml @@ -5,9 +5,9 @@ nav: - Home: README.md - My apps: pages/my-apps.md + - About: about.md - Docs: https://docs.alnoda.org/r-workspace/ - # =========================================================== # CONFIGURATION # =========================================================== @@ -23,26 +23,24 @@ edit_uri: "" theme: name: 'material' - favicon: 'assets/favicon.ico' - logo: 'assets/Alnoda-logo.svg' + favicon: 'assets/r-circle.svg' + logo: 'assets/r-circle-white.svg' custom_dir: overrides + font: + text: PT Sans icon: - repo: fontawesome/brands/git-alt + repo: fontawesome/brands/github features: - navigation.instant palette: - - scheme: default + - scheme: r toggle: - icon: material/toggle-switch-off-outline - name: Switch to light mode - primary: white - accent: blue - - scheme: slate - toggle: - icon: material/toggle-switch + icon: material/brightness-7 name: Switch to dark mode - primary: white - accent: blue + - scheme: r-dark + toggle: + icon: material/brightness-4 + name: Switch to light mode extra: # Link to open when your logo is clicked @@ -50,21 +48,14 @@ extra: host_url: http://docs.alnoda.org plugins: - - search # Enable Macros and jinja2 templates - macros: module_name: macros/helpers +extra_css: + - stylesheets/extra.css extra_javascript: - javascripts/config.js - https://polyfill.io/v3/polyfill.min.js?features=es6 - - - - - - - - diff --git a/workspaces/r-workspace/mkdocs/r-circle-white.svg b/workspaces/r-workspace/mkdocs/r-circle-white.svg new file mode 100644 index 0000000..0c65949 --- /dev/null +++ b/workspaces/r-workspace/mkdocs/r-circle-white.svg @@ -0,0 +1,27 @@ + + + + + + Go icon + Elixir icon + R icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/r-workspace/mkdocs/r-circle.svg b/workspaces/r-workspace/mkdocs/r-circle.svg new file mode 100644 index 0000000..0d7d0d0 --- /dev/null +++ b/workspaces/r-workspace/mkdocs/r-circle.svg @@ -0,0 +1,27 @@ + + + + + + Go icon + Elixir icon + R icon + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/workspaces/r-workspace/rocker_scripts/.s6_version b/workspaces/r-workspace/rocker_scripts/.s6_version new file mode 100644 index 0000000..f6085b4 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/.s6_version @@ -0,0 +1 @@ +v2.1.0.2 diff --git a/workspaces/r-workspace/rocker_scripts/bin/install2.r b/workspaces/r-workspace/rocker_scripts/bin/install2.r new file mode 100644 index 0000000..bd8e600 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/bin/install2.r @@ -0,0 +1,155 @@ +#!/usr/bin/env r +# +# A second example to install one or more packages, now with option parsing +# +# Copyright (C) 2011 - 2014 Dirk Eddelbuettel +# Copyright (C) 2014 - 2017 Carl Boettiger and Dirk Eddelbuettel +# Copyright (C) 2018 Carl Boettiger, Dirk Eddelbuettel, and Brandon Bertelsen +# +# Released under GPL (>= 2) + +## load docopt package from CRAN +library(docopt) + +## configuration for docopt +doc <- "Usage: install2.r [-l LIBLOC] [-h] [-x] [-s] [-d DEPS] [-n NCPUS] [-r REPOS...] [-m METHOD] [--error] [--skipmissing] [--] [PACKAGES ...] + +-l --libloc LIBLOC location in which to install [default: /usr/local/lib/R/site-library] +-d --deps DEPS install suggested dependencies as well [default: NA] +-n --ncpus NCPUS number of processes to use for parallel install [default: getOption] +-r --repos REPOS repositor(y|ies) to use, or NULL for file [default: getOption] +-e --error throw error and halt instead of a warning [default: FALSE] +--skipmissing use with the --error option, skip the packages missing error [default: FALSE] +-s --skipinstalled skip installing already installed packages [default: FALSE] +-m --method METHOD method to be used for downloading files [default: auto] +-h --help show this help text +-x --usage show help and short example usage" +opt <- docopt(doc) # docopt parsing + +if (opt$usage) { + cat(doc, "\n\n") + cat("where PACKAGES... can be one or more CRAN package names, or local (binary or source) +package files (where extensions .tar.gz, .tgz and .zip are recognised). Optional +arguments understood by R CMD INSTALL can be passed interspersed in the PACKAGES, though +this requires use of '--'. + +Examples: + install2.r -l /tmp/lib Rcpp BH # install into given library + install2.r -- --with-keep.source drat # keep the source + install2.r -- --data-compress=bzip2 stringdist # prefer bz2 compression + install2.r \".\" # install package in current directory + install2.r -n 6 ggplot2 # parallel install: (6 processes) + +install2.r is part of littler which brings 'r' to the command-line. +See http://dirk.eddelbuettel.com/code/littler.html for more information.\n") + q("no") +} + +if (opt$deps == "TRUE" || opt$deps == "FALSE") { + opt$deps <- as.logical(opt$deps) +} else if (opt$deps == "NA") { + opt$deps <- NA +} + +## docopt results are characters, so if we meant NULL we have to set NULL +if (length(opt$repos) == 1 && "NULL" %in% opt$repos) { + opt$repos <- NULL +} + +if ("getOption" %in% opt$repos) { + ## as littler can now read ~/.littler.r and/or /etc/littler.r we can preset elsewhere + opt$repos <- c(opt$repos[which(opt$repos != "getOption")], getOption("repos")) +} + +if (opt$ncpus == "getOption") { + opt$ncpus <- getOption("Ncpus", 1L) +} else if (opt$ncpus == "-1") { + ## parallel comes with R 2.14+ + opt$ncpus <- max(1L, parallel::detectCores()) +} + +## ensure installation is stripped +Sys.setenv("_R_SHLIB_STRIP_"="true") + +install_packages2 <- function(pkgs, ..., error = FALSE, skipmissing = FALSE, skipinstalled = FALSE) { + e <- NULL + capture <- function(e) { + if (error) { + catch <- + grepl("download of package .* failed", e$message) || + (grepl("(dependenc|package).*(is|are) not available", e$message) && !skipmissing) || + grepl("installation of package.*had non-zero exit status", e$message) || + grepl("installation of one or more packages failed", e$message) + if (catch) { + e <<- e + } + } + } + if (skipinstalled) { + pkgs <- setdiff(pkgs, installed.packages()[,1]) + } + if (length(pkgs) > 0) { + withCallingHandlers(install.packages(pkgs, ...), warning = capture) + if (!is.null(e)) { + stop(e$message, call. = FALSE) + } + } +} + +## helper function to for existing files with matching extension +isMatchingFile <- function(f) (file.exists(f) && grepl("(\\.tar\\.gz|\\.tgz|\\.zip)$", f)) || (f == ".") + +## helper function which switches to local (ie NULL) repo if matching file is presented +installArg <- function(f, lib, rep, dep, iopts, error, skipmissing, skipinstalled, ncpus, method) { + install_packages2(pkgs=f, + lib=lib, + repos=if (isMatchingFile(f)) NULL else rep, + dependencies=dep, + INSTALL_opts=iopts, + Ncpus = ncpus, + method = method, + error = error, + skipmissing = skipmissing, + skipinstalled = skipinstalled) +} + +## strip out arguments to be passed to R CMD INSTALL +isArg <- grepl('^--',opt$PACKAGES) +installOpts <- opt$PACKAGES[isArg] +opt$PACKAGES <- opt$PACKAGES[!isArg] + +if (length(opt$PACKAGES)==0 && file.exists("DESCRIPTION") && file.exists("NAMESPACE")) { + ## we are in a source directory, so build it + message("* installing *source* package found in current working directory ...") + opt$PACKAGES <- "." +} + +## helper function to for existing files with matching extension +isMatchingFile <- + function(f) (file.exists(f) && + grepl("(\\.tar\\.gz|\\.tgz|\\.zip)$", f)) || (f == ".") + +## check arguments for local files -- if none, then we can pass vector on +isLocal <- sapply(opt$PACKAGES, isMatchingFile) + +## for any local sources loop explicitly as before, otherwise for remote +## packages pass vector to install_packages2 which does the rest (and +## possibly in parallel using up to ncpus) +if (any(isLocal)) { + sapply(opt$PACKAGES, installArg, opt$libloc, opt$repos, opt$deps, + installOpts, opt$error, opt$skipmissing, opt$skipinstalled, opt$ncpus, opt$method) +} else { + install_packages2(pkgs = opt$PACKAGES, + lib = opt$libloc, + repos = opt$repos, + dependencies = opt$deps, + INSTALL_opts = installOpts, + Ncpus = opt$ncpus, + method = opt$method, + error = opt$error, + skipmissing = opt$skipmissing, + skipinstalled = opt$skipinstalled) +} + +## clean up any temp file containing CRAN directory information +sapply(list.files(path=tempdir(), pattern="^(repos|libloc).*\\.rds$", full.names=TRUE), unlink) diff --git a/workspaces/r-workspace/rocker_scripts/config_R_cuda.sh b/workspaces/r-workspace/rocker_scripts/config_R_cuda.sh new file mode 100644 index 0000000..1322dde --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/config_R_cuda.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -e + +## CUDA environmental variables configuration for RStudio + +## These should be exported as ENV vars too +CUDA_HOME=${CUDA_HOME:-/usr/local/cuda} +PATH={$PATH:-$PATH:$CUDA_HOME/bin} +LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64} +NVBLAS_CONFIG_FILE=${NVBLAS_CONFIG_FILE:-/etc/nvblas.conf} + +## cli R inherits these, but RStudio needs to have these set in as follows: +## (From https://tensorflow.rstudio.com/tools/local_gpu.html#environment-variables) +echo "CUDA_HOME=$CUDA_HOME" >> ${R_HOME}/etc/Renviron.site +echo "PATH=$PATH" >> ${R_HOME}/etc/Renviron.site + +if test -f /etc/rstudio/rserver.conf; then + sed -i '/^rsession-ld-library-path/d' /etc/rstudio/rserver.conf + echo "rsession-ld-library-path=$LD_LIBRARY_PATH" >> /etc/rstudio/rserver.conf +fi + +## nvblas configuration +touch /var/log/nvblas.log && chown :staff /var/log/nvblas.log +chmod a+rw /var/log/nvblas.log + +## Configure R & RStudio to use drop-in CUDA blas +## Allow R to use CUDA for BLAS, with fallback on openblas +## NOTE: NVBLAS_CPU_BLAS_LIB must be correct for UBUNTU_VERSION selected in scripts/install_R.sh#L25 +echo 'NVBLAS_LOGFILE /var/log/nvblas.log +NVBLAS_CPU_BLAS_LIB /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 +NVBLAS_GPU_LIST ALL' > /etc/nvblas.conf + +echo "NVBLAS_CONFIG_FILE=$NVBLAS_CONFIG_FILE" >> ${R_HOME}/etc/Renviron.site + +## We don't want to set LD_PRELOAD globally +##ENV LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so +# +### Instead, we will set it before calling R, Rscript, or RStudio: +#mv /usr/bin/R /usr/bin/R_ +#mv /usr/bin/Rscript /usr/bin/Rscript_ +# +#echo '\#!/bin/sh \ +# \n LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so /usr/bin/R_ "$@"' \ +# > /usr/bin/R && \ +# chmod +x /usr/bin/R && \ +# echo '#!/bin/sh \ +# \n LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so /usr/bin/Rscript_ "$@"' \ +# > /usr/bin/Rscript && \ +# chmod +x /usr/bin/Rscript +# +#echo '#!/usr/bin/with-contenv bash \ +# \n## load /etc/environment vars first: \ +# \n for line in \$( cat /etc/environment ) ; do export $line ; done \ +# \n export LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so \ +# \n exec /usr/lib/rstudio-server/bin/rserver --server-daemonize 0' \ +# > /etc/services.d/rstudio/run diff --git a/workspaces/r-workspace/rocker_scripts/default_user.sh b/workspaces/r-workspace/rocker_scripts/default_user.sh new file mode 100644 index 0000000..61c693c --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/default_user.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -e + +DEFAULT_USER=${1:-${DEFAULT_USER:-"rstudio"}} + +if id -u "${DEFAULT_USER}" >/dev/null 2>&1; then + echo "User ${DEFAULT_USER} already exists" +else + ## Need to configure non-root user for RStudio + useradd -s /bin/bash -m "$DEFAULT_USER" + echo "${DEFAULT_USER}:${DEFAULT_USER}" | chpasswd + addgroup "${DEFAULT_USER}" staff + + ## Rocker's default RStudio settings, for better reproducibility + mkdir -p "/home/${DEFAULT_USER}/.rstudio/monitored/user-settings" + cat <"/home/${DEFAULT_USER}/.rstudio/monitored/user-settings/user-settings" +alwaysSaveHistory="0" +loadRData="0" +saveAction="0" +EOF + chown -R "${DEFAULT_USER}:${DEFAULT_USER}" "/home/${DEFAULT_USER}" +fi + +# If shiny server installed, make the user part of the shiny group +if [ -x "$(command -v shiny-server)" ]; then + adduser "${DEFAULT_USER}" shiny +fi + +## configure git not to request password each time +if [ -x "$(command -v git)" ]; then + git config --system credential.helper 'cache --timeout=3600' + git config --system push.default simple +fi diff --git a/workspaces/r-workspace/rocker_scripts/experimental/batch_user_creation.sh b/workspaces/r-workspace/rocker_scripts/experimental/batch_user_creation.sh new file mode 100644 index 0000000..4e88452 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/experimental/batch_user_creation.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# Batch creation of user accounts in RStudio server. The script reads a list +# of username and password pairs from the `BATCH_USER_CREATION` enviroment +# variable and uses this information to update a group of existing users when +# the container starts. Each pair is of the format: username:password and is +# separated from the next by a semicolon, with no intervening whitespace. +# Usernames may only be up to 32 characters long (required by `useradd`) and +# by default the supplied passwords must be in clear-text (later encrypted by +# `chpasswd`). If an username already exists, the script will deny that +# particular account creation request; if not, the user account will be +# created, the login shell set to Bash and the user's home directory created, +# if it does not exist. By default, a group will be created for each new user +# with the same name as her username. If the groupname already exists, the +# script will deny the group creation request. If the password is not +# specified, it will be assumed that it is equals to the username. All users +# will also be added to the `staff` group (same as rstudio user). A directory +# called .rstudio/monitored/user-settings/user-settings is created in that +# users home directory to store RStudio initial preferences. Users are not +# allowed to read other users' home directory. + +set -e + +# Remove spaces +remove_spaces() { + local var="$*" + # Remove all spaces + var=${var//$' '/''} + echo -e "$var" + return 0 +} + +function create_user() { + local username=$1 + local password=$2 + + echo "Processing user '${username}'." + + if id -u "$username" >/dev/null 2>&1; then + echo "${username} user already exists. Nothing else to do." + else + useradd -s /bin/bash -m "$username" + # invalid user name + if [ "$?" == 3 ]; then + echo "Failed to create user '${username}'." + return + fi + + if [ -z "$password" ]; then + echo "Password not provided. Setting it equals to username." + password=${username} + fi + echo "${username}:${password}" | chpasswd + + addgroup "${username}" staff + + mkdir -p "/home/${username}/.rstudio/monitored/user-settings" + printf "alwaysSaveHistory='0' \ + \nloadRData='0' \ + \nsaveAction='0'" \ + >"/home/${username}/.rstudio/monitored/user-settings/user-settings" + + chown -R "${username}:${username}" "/home/${username}" + # Prevent other users, but the owner, from accessing a home directory + chmod 0700 "/home/${username}" + fi + + # If shiny server installed, make the user part of the shiny group + if [ -x "$(command -v shiny-server)" ]; then + adduser "${username}" shiny + fi + + echo "Done with user ${username}." +} + +if [ -n "$BATCH_USER_CREATION" ]; then + echo "Requested creation of multiple user accounts in batch mode." + + BATCH_USER_CREATION=$(remove_spaces "$BATCH_USER_CREATION") + + for user in $(echo "$BATCH_USER_CREATION" | tr ';' ' '); do + IFS=: read -r username password <<<"${user}" + + if [ -z "$username" ]; then + echo "Failed to create user: username undefined" + continue + else + create_user "$username" "$password" || true + fi + done + echo "Finished creation of multiple user accounts in batch mode." +fi diff --git a/workspaces/r-workspace/rocker_scripts/experimental/cuda10.2-tf.sh b/workspaces/r-workspace/rocker_scripts/experimental/cuda10.2-tf.sh new file mode 100644 index 0000000..4115d08 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/experimental/cuda10.2-tf.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +## not sure why cuda-cudart-dev-10-1 when this is 10.2 and we already have 10.2... + +sudo apt update && \ + sudo apt install \ + libnvinfer-dev \ + cuda-cudart-dev-10-1 + + diff --git a/workspaces/r-workspace/rocker_scripts/experimental/install_R_binary.sh b/workspaces/r-workspace/rocker_scripts/experimental/install_R_binary.sh new file mode 100644 index 0000000..cd79593 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/experimental/install_R_binary.sh @@ -0,0 +1,63 @@ +#!/bin/bash +set -e + +UBUNTU_VERSION=${UBUNTU_VERSION:-focal} +CRAN_LINUX_VERSION=${CRAN_LINUX_VERSION:-cran40} +LANG=${LANG:-en_US.UTF-8} +LC_ALL=${LC_ALL:-en_US.UTF-8} + + +DEBIAN_FRONTEND=noninteractive + +# Set up and install R +R_HOME=${R_HOME:-/usr/lib/R} + +#R_VERSION=${R_VERSION} + + +apt-get update + +apt-get -y install --no-install-recommends \ + ca-certificates \ + less \ + libopenblas-base \ + locales \ + vim-tiny \ + wget \ + dirmngr \ + gpg \ + gpg-agent + +echo "deb http://cloud.r-project.org/bin/linux/ubuntu ${UBUNTU_VERSION}-${CRAN_LINUX_VERSION}/" >> /etc/apt/sources.list + +gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 +gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | apt-key add - + + +# Wildcard * at end of version will grab (latest) patch of requested version +apt-get update && apt-get -y install --no-install-recommends r-base-dev=${R_VERSION}* + + + +rm -rf /var/lib/apt/lists/* + +## Add PPAs: NOTE this will mean that installing binary R packages won't be version stable. +## +## These are required at least for bionic-based images since 3.4 r binaries are + + +echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen +locale-gen en_US.utf8 +/usr/sbin/update-locale LANG=${LANG} + +Rscript -e "install.packages(c('littler', 'docopt'))" + +## By default R_LIBS_SITE is unset, and defaults to this, so this is where `littler` will be. +## We set it here for symlinks, but don't make the env var persist (since it's already the default) +R_LIBS_SITE=/usr/local/lib/R/site-library +ln -s ${R_LIBS_SITE}/littler/examples/install.r /usr/local/bin/install.r +ln -s ${R_LIBS_SITE}/littler/examples/install2.r /usr/local/bin/install2.r +ln -s ${R_LIBS_SITE}/littler/examples/installGithub.r /usr/local/bin/installGithub.r +ln -s ${R_LIBS_SITE}/littler/bin/r /usr/local/bin/r + + diff --git a/workspaces/r-workspace/rocker_scripts/experimental/install_dev_osgeo.sh b/workspaces/r-workspace/rocker_scripts/experimental/install_dev_osgeo.sh new file mode 100644 index 0000000..e256447 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/experimental/install_dev_osgeo.sh @@ -0,0 +1,177 @@ +#!/bin/bash +set -e + +## Install PROJ, GDAL, GEOS from source. +## +## 'latest' means installing the latest release version. + +## build ARGs +NCPUS=${NCPUS:-"-1"} + +PROJ_VERSION=${PROJ_VERSION:-"latest"} +GDAL_VERSION=${GDAL_VERSION:-"latest"} +GEOS_VERSION=${GEOS_VERSION:-"latest"} + +CRAN=${CRAN_SOURCE:-"https://cloud.r-project.org"} +echo "options(repos = c(CRAN = '${CRAN}'))" >>"${R_HOME}/etc/Rprofile.site" + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +function url_latest_gh_released_asset() { + wget -qO- "https://api.github.com/repos/$1/releases/latest" | grep -oP "(?<=\"browser_download_url\":\s\")https.*\.tar.gz(?=\")" +} + +export DEBIAN_FRONTEND=noninteractive +apt_install \ + gdb \ + git \ + libcairo2-dev \ + libcurl4-openssl-dev \ + libexpat1-dev \ + libpq-dev \ + libsqlite3-dev \ + libudunits2-dev \ + make \ + pandoc \ + qpdf \ + sqlite3 \ + subversion \ + valgrind \ + vim \ + tk-dev \ + wget \ + libv8-dev \ + libjq-dev \ + libprotobuf-dev \ + libxml2-dev \ + libprotobuf-dev \ + protobuf-compiler \ + unixodbc-dev \ + libssh2-1-dev \ + libgit2-dev \ + libnetcdf-dev \ + locales \ + libssl-dev \ + libtiff-dev \ + cmake \ + libtiff5-dev + +LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# install geos +# https://libgeos.org/usage/download/ +if [ "$GEOS_VERSION" = "latest" ]; then + GEOS_VERSION=$(wget -qO- "https://api.github.com/repos/libgeos/geos/git/refs/tags" | grep -oP "(?<=\"ref\":\s\"refs/tags/)\d+\.\d+\.\d+" | tail -n -1) +fi + +wget http://download.osgeo.org/geos/geos-"${GEOS_VERSION}".tar.bz2 +bzip2 -d geos-*bz2 +tar xf geos*tar +rm geos*tar +cd geos* +./configure +make +make install +cd .. +ldconfig + +# install proj +# https://download.osgeo.org/proj/ +if [ "$PROJ_VERSION" = "latest" ]; then + PROJ_DL_URL=$(url_latest_gh_released_asset "OSGeo/PROJ") +else + PROJ_DL_URL="http://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz" +fi + +wget "$PROJ_DL_URL" -O proj.tar.gz +tar zxvf proj.tar.gz +rm proj.tar.gz +cd proj-* +mkdir build +cd build +cmake .. +make +make install +cd ../.. +ldconfig + +# install gdal +# https://download.osgeo.org/gdal/ +if [ "$GDAL_VERSION" = "latest" ]; then + GDAL_DL_URL=$(url_latest_gh_released_asset "OSGeo/gdal") +else + GDAL_DL_URL="https://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz" +fi + +wget "$GDAL_DL_URL" -O gdal.tar.gz +tar -xf gdal.tar.gz +rm gdal.tar.gz +cd gdal* +./configure +make +make install +cd .. +ldconfig + +install2.r --error --skipmissing --skipinstalled -n "$NCPUS" \ + sp \ + rgeos \ + rgdal \ + RPostgreSQL \ + RSQLite \ + testthat \ + knitr \ + tidyr \ + geosphere \ + maptools \ + maps \ + microbenchmark \ + raster \ + dplyr \ + tibble \ + units \ + DBI \ + covr \ + protolite \ + tmap \ + mapview \ + odbc \ + pool \ + rmarkdown \ + RPostgres \ + spatstat \ + stars + +git clone --depth 1 https://github.com/r-spatial/sf.git +git clone --depth 1 https://github.com/r-spatial/lwgeom.git +git clone --depth 1 https://github.com/r-spatial/stars.git + +R CMD build lwgeom +R CMD INSTALL lwgeom +rm -rf lwgeom* +R CMD build sf +R CMD INSTALL sf +rm -rf sf* +R CMD build stars +R CMD INSTALL stars +rm -rf stars* + +# Clean up +rm -rf /var/lib/apt/lists/* +rm -r /tmp/downloaded_packages + +# Check the geospatial packages + +echo -e "Check the packages...\n" + +R -q -e "library(lwgeom); library(sf); library(stars)" + +echo -e "\nInstall packages, done!" diff --git a/workspaces/r-workspace/rocker_scripts/experimental/install_geospatial_unstable.sh b/workspaces/r-workspace/rocker_scripts/experimental/install_geospatial_unstable.sh new file mode 100644 index 0000000..8458e32 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/experimental/install_geospatial_unstable.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +CRAN=${CRAN_SOURCE:-"https://cloud.r-project.org"} + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +# always set this for scripts but don't declare as ENV.. +export DEBIAN_FRONTEND=noninteractive +apt_install \ + software-properties-common \ + gnupg2 \ + curl \ + ca-certificates + +# Adding the ubuntugis-unstable PPA +add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable + +## in UNSTABLE, we will install everything from source by default: +echo "options(repos = c(CRAN = '${CRAN}'))" >>"${R_HOME}/etc/Rprofile.site" + +## install geospatial pakages +/rocker_scripts/install_geospatial.sh + +# Clean up +rm -rf /var/lib/apt/lists/* diff --git a/workspaces/r-workspace/rocker_scripts/experimental/install_rl.sh b/workspaces/r-workspace/rocker_scripts/experimental/install_rl.sh new file mode 100644 index 0000000..5433fd8 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/experimental/install_rl.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +python -m venv /opt/venv/rl +. /opt/venv/rl/bin/activate + +pip install wheel +pip install gym tensorflow keras keras-rl + +chown -R :staff /opt/venv/rl +chmod g+rx /opt/venv/rl diff --git a/workspaces/r-workspace/rocker_scripts/init_set_env.sh b/workspaces/r-workspace/rocker_scripts/init_set_env.sh new file mode 100644 index 0000000..51125fb --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/init_set_env.sh @@ -0,0 +1,13 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +## Set our dynamic variables in Renviron.site to be reflected by RStudio Server or Shiny Server +exclude_vars="HOME PASSWORD RSTUDIO_VERSION BATCH_USER_CREATION" +for file in /var/run/s6/container_environment/*; do + sed -i "/^${file##*/}=/d" "${R_HOME}/etc/Renviron.site" + regex="(^| )${file##*/}($| )" + [[ ! $exclude_vars =~ $regex ]] && echo "${file##*/}=$(cat "${file}")" >>"${R_HOME}/etc/Renviron.site" || echo "skipping ${file}" +done + +## only file-owner (root) should read container_environment files: +chmod 600 /var/run/s6/container_environment/* diff --git a/workspaces/r-workspace/rocker_scripts/init_userconf.sh b/workspaces/r-workspace/rocker_scripts/init_userconf.sh new file mode 100644 index 0000000..93b3029 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/init_userconf.sh @@ -0,0 +1,92 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +## Set defaults for environmental variables in case they are undefined +DEFAULT_USER=${DEFAULT_USER:-rstudio} +USER=${USER:=${DEFAULT_USER}} +USERID=${USERID:=1000} +GROUPID=${GROUPID:=1000} +ROOT=${ROOT:=FALSE} +UMASK=${UMASK:=022} +LANG=${LANG:=en_US.UTF-8} +TZ=${TZ:=Etc/UTC} + +if [[ ${DISABLE_AUTH,,} == "true" ]]; then + mv /etc/rstudio/disable_auth_rserver.conf /etc/rstudio/rserver.conf + echo "USER=$USER" >>/etc/environment +fi + +if grep --quiet "auth-none=1" /etc/rstudio/rserver.conf; then + echo "Skipping authentication as requested" +elif [ -z "$PASSWORD" ]; then + PASSWORD=$(pwgen 16 1) + printf "\n\n" + tput bold + printf "The password is set to \e[31m%s\e[39m\n" "$PASSWORD" + printf "If you want to set your own password, set the PASSWORD environment variable. e.g. run with:\n" + printf "docker run -e PASSWORD=\e[92m\e[39m -p 8787:8787 rocker/rstudio\n" + tput sgr0 + printf "\n\n" +fi + +if [ "$USERID" -lt 1000 ]; then # Probably a macOS user, https://github.com/rocker-org/rocker/issues/205 + echo "$USERID is less than 1000" + check_user_id=$(grep -F "auth-minimum-user-id" /etc/rstudio/rserver.conf) + if [[ -n $check_user_id ]]; then + echo "minumum authorised user already exists in /etc/rstudio/rserver.conf: $check_user_id" + else + echo "setting minumum authorised user to 499" + echo auth-minimum-user-id=499 >>/etc/rstudio/rserver.conf + fi +fi + +if [ "$USERID" -ne 1000 ]; then ## Configure user with a different USERID if requested. + echo "deleting the default user" + userdel "$DEFAULT_USER" + echo "creating new $USER with UID $USERID" + useradd -m "$USER" -u $USERID + mkdir -p /home/"$USER" + chown -R "$USER" /home/"$USER" + usermod -a -G staff "$USER" +elif [ "$USER" != "$DEFAULT_USER" ]; then + ## cannot move home folder when it's a shared volume, have to copy and change permissions instead + cp -r /home/"$DEFAULT_USER" /home/"$USER" + ## RENAME the user + usermod -l "$USER" -d /home/"$USER" "$DEFAULT_USER" + groupmod -n "$USER" "$DEFAULT_USER" + usermod -a -G staff "$USER" + chown -R "$USER":"$USER" /home/"$USER" + echo "USER is now $USER" +fi + +if [ "$GROUPID" -ne 1000 ]; then ## Configure the primary GID (whether rstudio or $USER) with a different GROUPID if requested. + echo "Modifying primary group $(id "${USER}" -g -n)" + groupmod -g $GROUPID "$(id "${USER}" -g -n)" + echo "Primary group ID is now custom_group $GROUPID" +fi + +## Add a password to user +echo "$USER:$PASSWORD" | chpasswd + +# Use Env flag to know if user should be added to sudoers +if [[ ${ROOT,,} == "true" ]]; then + adduser "$USER" sudo && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers + echo "$USER added to sudoers" +fi + +## Change Umask value if desired +if [ "$UMASK" -ne 022 ]; then + echo "server-set-umask=false" >>/etc/rstudio/rserver.conf + echo "Sys.umask(mode=$UMASK)" >>/home/"$USER"/.Rprofile +fi + +## Next one for timezone setup +if [ "$TZ" != "Etc/UTC" ]; then + ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone +fi + +## Update Locale if needed +if [ "$LANG" != "en_US.UTF-8" ]; then + /usr/sbin/locale-gen --lang $LANG + /usr/sbin/update-locale --reset LANG=$LANG +fi diff --git a/workspaces/r-workspace/rocker_scripts/install_R_ppa.sh b/workspaces/r-workspace/rocker_scripts/install_R_ppa.sh new file mode 100644 index 0000000..e8a3e08 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_R_ppa.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -e + +UBUNTU_VERSION=${UBUNTU_VERSION:-focal} +CRAN_LINUX_VERSION=${CRAN_LINUX_VERSION:-cran40} +LANG=${LANG:-en_US.UTF-8} +LC_ALL=${LC_ALL:-en_US.UTF-8} +DEBIAN_FRONTEND=noninteractive + +# Set up and install R +R_HOME=${R_HOME:-/usr/lib/R} + +#R_VERSION=${R_VERSION} + +apt-get update + +apt-get -y install --no-install-recommends \ + ca-certificates \ + less \ + libopenblas-base \ + locales \ + vim-tiny \ + wget \ + dirmngr \ + gpg \ + gpg-agent + +echo "deb http://cloud.r-project.org/bin/linux/ubuntu ${UBUNTU_VERSION}-${CRAN_LINUX_VERSION}/" >> /etc/apt/sources.list + +gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 +gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | apt-key add - + + +# Wildcard * at end of version will grab (latest) patch of requested version +apt-get update && apt-get -y install --no-install-recommends r-base-dev=${R_VERSION}* + +rm -rf /var/lib/apt/lists/* + +## Add PPAs: NOTE this will mean that installing binary R packages won't be version stable. +## +## These are required at least for bionic-based images since 3.4 r binaries are + +echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen +locale-gen en_US.utf8 +/usr/sbin/update-locale LANG=${LANG} + +Rscript -e "install.packages(c('littler', 'docopt'))" + +## By default R_LIBS_SITE is unset, and defaults to this, so this is where `littler` will be. +## We set it here for symlinks, but don't make the env var persist (since it's already the default) +R_LIBS_SITE=/usr/local/lib/R/site-library +ln -s ${R_LIBS_SITE}/littler/examples/install.r /usr/local/bin/install.r +ln -s ${R_LIBS_SITE}/littler/examples/install2.r /usr/local/bin/install2.r +ln -s ${R_LIBS_SITE}/littler/examples/installGithub.r /usr/local/bin/installGithub.r +ln -s ${R_LIBS_SITE}/littler/bin/r /usr/local/bin/r diff --git a/workspaces/r-workspace/scripts/install_R_source.sh b/workspaces/r-workspace/rocker_scripts/install_R_source.sh similarity index 98% rename from workspaces/r-workspace/scripts/install_R_source.sh rename to workspaces/r-workspace/rocker_scripts/install_R_source.sh index 26d2675..33f3e00 100644 --- a/workspaces/r-workspace/scripts/install_R_source.sh +++ b/workspaces/r-workspace/rocker_scripts/install_R_source.sh @@ -161,4 +161,4 @@ echo -e "Check the R info...\n" R -q -e "sessionInfo()" -echo -e "\nInstall R from source, done!" \ No newline at end of file +echo -e "\nInstall R from source, done!" diff --git a/workspaces/r-workspace/rocker_scripts/install_binder.sh b/workspaces/r-workspace/rocker_scripts/install_binder.sh new file mode 100644 index 0000000..e74ec1c --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_binder.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -e + +## build ARGs +NCPUS=${NCPUS:-"-1"} + +NB_USER=${NB_USER:-${DEFAULT_USER:-"rstudio"}} + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install \ + sudo \ + libzmq3-dev + +# set up the default user if it does not exist +if ! id -u "${NB_USER}" >/dev/null 2>&1; then + /rocker_scripts/default_user.sh "${NB_USER}" +fi + +# install python +/rocker_scripts/install_python.sh + +PYTHON_VENV_PATH=${PYTHON_VENV_PATH:-/opt/venv/reticulate} +WORKDIR=${WORKDIR:-/home/${NB_USER}} +# Create a venv dir owned by unprivileged user & set up notebook in it +# This allows non-root to install python libraries if required +mkdir -p "${PYTHON_VENV_PATH}" +chown -R "${NB_USER}" "${PYTHON_VENV_PATH}" + +# to use pyenv in a RStudio session, we need to include the PATH in the .profile file +# https://github.com/rocker-org/rocker-versioned2/issues/428 +PATH=/opt/pyenv/bin:${PATH} +echo "export PATH=${PATH}" >>"${WORKDIR}/.profile" + +cd "${WORKDIR}" +## This gets run as user +sudo -u "${NB_USER}" python3 -m venv "${PYTHON_VENV_PATH}" + +python3 -m pip install --no-cache-dir jupyter-rsession-proxy notebook jupyterlab + +install2.r --error --skipmissing --skipinstalled -n "$NCPUS" remotes + +R --quiet -e "remotes::install_github('IRkernel/IRkernel')" +R --quiet -e "IRkernel::installspec(prefix='${PYTHON_VENV_PATH}')" + +# Clean up +rm -rf /var/lib/apt/lists/* +rm -rf /tmp/downloaded_packages diff --git a/workspaces/r-workspace/rocker_scripts/install_cuda-10.1.sh b/workspaces/r-workspace/rocker_scripts/install_cuda-10.1.sh new file mode 100644 index 0000000..027a1ca --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_cuda-10.1.sh @@ -0,0 +1,101 @@ +#!/bin/bash +set -e + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install \ + gnupg2 \ + curl \ + ca-certificates + +apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub +apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub +echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" >/etc/apt/sources.list.d/cuda.list +echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" >/etc/apt/sources.list.d/nvidia-ml.list +apt-get update + +CUDA_VERSION=${CUDA_VERSION:-10.1.243} +CUDA_PKG_VERSION=${CUDA_PKG_VERSION:-10-1=$CUDA_VERSION-1} + +# For libraries in the cuda-compat-* package: https://docs.nvidia.com/cuda/eula/index.html#attachment-a +apt_install \ + "cuda-cudart-${CUDA_PKG_VERSION}" \ + cuda-compat-10-1 + +ln -s cuda-10.1 /usr/local/cuda + +# Required for nvidia-docker v1 +echo "/usr/local/nvidia/lib" >>/etc/ld.so.conf.d/nvidia.conf && + echo "/usr/local/nvidia/lib64" >>/etc/ld.so.conf.d/nvidia.conf + +## PATH & LD_LIBRARY_PATH are wrong? +PATH=${PATH:-/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}} +LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-/usr/local/nvidia/lib:/usr/local/nvidia/lib64} + +# nvidia-container-runtime +NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES:-all} +NVIDIA_DRIVER_CAPABILITIES=${NVIDIA_DRIVER_CAPABILITIES:-"compute,utility"} +NVIDIA_REQUIRE_CUDA=${NVIDIA_REQUIRE_CUDA:-"cuda>=10.1 brand=tesla,driver>=384,driver<385 brand=tesla,driver>=396,driver<397 brand=tesla,driver>=410,driver<411"} + +## Tensorflow config for cuda runtime. +## Adapted from: + +CUDA=10.1 +CUDNN=7.6.4.38-1 +LIBNVINFER=6.0.1-1 +LIBNVINFER_MAJOR_VERSION=6 + +#SHELL ["/bin/bash", "-c"] +# Pick up some TF dependencies +# There appears to be a regression in libcublas10=10.2.2.89-1 which +# prevents cublas from initializing in TF. See +# https://github.com/tensorflow/tensorflow/issues/9489#issuecomment-562394257 +apt_install \ + build-essential \ + cuda-command-line-tools-10-1 \ + libcublas10=10.2.1.243-1 \ + cuda-nvrtc-10-1 \ + cuda-cufft-10-1 \ + cuda-curand-10-1 \ + cuda-cusolver-10-1 \ + cuda-cusparse-10-1 \ + curl \ + libcudnn7=${CUDNN}+cuda10.1 \ + libfreetype6-dev \ + libhdf5-serial-dev \ + libzmq3-dev \ + pkg-config \ + software-properties-common \ + unzip + +# Install TensorRT if not building for PowerPC +apt_install \ + libnvinfer${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \ + libnvinfer-plugin${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} +apt-get clean + +# For CUDA profiling, TensorFlow requires CUPTI. +LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:$LD_LIBRARY_PATH} + +# Link the libcuda stub to the location where tensorflow is searching for it and reconfigure +# dynamic linker run-time bindings +ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 +echo "/usr/local/cuda/lib64/stubs" >/etc/ld.so.conf.d/z-cuda-stubs.conf +ldconfig + +## Add nvtop +#/rocker_scripts/install_nvtop.sh + +## Add tensorflow-gpu==1.15 dependencies on the CUDA 10.0 libraries: +/rocker_scripts/install_tf1_cuda_10_0.sh + +# Clean up +rm -rf /var/lib/apt/lists/* diff --git a/workspaces/r-workspace/rocker_scripts/install_cuda-11.1.sh b/workspaces/r-workspace/rocker_scripts/install_cuda-11.1.sh new file mode 100644 index 0000000..1d3c087 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_cuda-11.1.sh @@ -0,0 +1,76 @@ +#!/bin/bash +set -e + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install \ + gnupg2 \ + curl \ + ca-certificates + +apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub +apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub +echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 /" >/etc/apt/sources.list.d/cuda.list +echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64 /" >/etc/apt/sources.list.d/nvidia-ml.list +apt-get update + +CUDA_VERSION=${CUDA_VERSION:-11.1.1} + +# For libraries in the cuda-compat-* package: https://docs.nvidia.com/cuda/eula/index.html#attachment-a +apt_install \ + cuda-cudart-11-1=11.1.74-1 \ + cuda-compat-11-1 + +ln -s cuda-11.1 /usr/local/cuda + +# Required for nvidia-docker v1 +echo "/usr/local/nvidia/lib" >>/etc/ld.so.conf.d/nvidia.conf +echo "/usr/local/nvidia/lib64" >>/etc/ld.so.conf.d/nvidia.conf + +## Set all of these as global ENV +# PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH} +# LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 + +# NVIDIA_VISIBLE_DEVICES=all +#NVIDIA_DRIVER_CAPABILITIES="compute,utility" +# NVIDIA_REQUIRE_CUDA="cuda>=11.1 brand=tesla,driver>=418,driver<419 brand=tesla,driver>=440,driver<441 brand=tesla,driver>=450,driver<451" + +## runtime #################################################### +##FROM ${IMAGE_NAME}:11.1-base-ubuntu20.04 + +NCCL_VERSION=${NCCL_VERSION:-2.7.8} + +apt_install \ + cuda-libraries-11-1=11.1.1-1 \ + libnpp-11-1=11.1.2.301-1 \ + cuda-nvtx-11-1=11.1.74-1 \ + libcublas-11-1=11.3.0.106-1 \ + "libnccl2=$NCCL_VERSION-1+cuda11.1" + +apt-mark hold libnccl2 + +## devel ####################################################### + +apt_install \ + cuda-nvml-dev-11-1=11.1.74-1 \ + cuda-command-line-tools-11-1=11.1.1-1 \ + cuda-nvprof-11-1=11.1.105-1 \ + libnpp-dev-11-1=11.1.2.301-1 \ + cuda-libraries-dev-11-1=11.1.1-1 \ + cuda-minimal-build-11-1=11.1.1-1 \ + libnccl-dev=2.7.8-1+cuda11.1 \ + libcublas-dev-11-1=11.3.0.106-1 \ + libcusparse-11-1=11.3.0.10-1 \ + libcusparse-dev-11-1=11.3.0.10-1 +apt-mark hold libnccl-dev + +# Clean up +rm -rf /var/lib/apt/lists/* diff --git a/workspaces/r-workspace/rocker_scripts/install_geospatial.sh b/workspaces/r-workspace/rocker_scripts/install_geospatial.sh new file mode 100644 index 0000000..773c45a --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_geospatial.sh @@ -0,0 +1,86 @@ +#!/bin/bash +set -e + +# always set this for scripts but don't declare as ENV.. +export DEBIAN_FRONTEND=noninteractive + +## build ARGs +NCPUS=${NCPUS:--1} + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install \ + gdal-bin \ + lbzip2 \ + libfftw3-dev \ + libgdal-dev \ + libgeos-dev \ + libgsl0-dev \ + libgl1-mesa-dev \ + libglu1-mesa-dev \ + libhdf4-alt-dev \ + libhdf5-dev \ + libjq-dev \ + libpq-dev \ + libproj-dev \ + libprotobuf-dev \ + libnetcdf-dev \ + libsqlite3-dev \ + libssl-dev \ + libudunits2-dev \ + lsb-release \ + netcdf-bin \ + postgis \ + protobuf-compiler \ + sqlite3 \ + tk-dev \ + unixodbc-dev + +install2.r --error --skipmissing --skipinstalled -n "$NCPUS" \ + RColorBrewer \ + RandomFields \ + RNetCDF \ + classInt \ + deldir \ + gstat \ + hdf5r \ + lidR \ + mapdata \ + maptools \ + mapview \ + ncdf4 \ + proj4 \ + raster \ + rgdal \ + rgeos \ + rlas \ + sf \ + sp \ + spacetime \ + spatstat \ + spatialreg \ + spdep \ + stars \ + terra \ + tidync \ + tmap \ + geoR \ + geosphere \ + BiocManager + +R -e "BiocManager::install('rhdf5')" + +## install wgrib2 for NOAA's NOMADS / rNOMADS forecast files +/rocker_scripts/install_wgrib2.sh + +# Clean up +rm -rf /var/lib/apt/lists/* +rm -r /tmp/downloaded_packages diff --git a/workspaces/r-workspace/rocker_scripts/install_julia.sh b/workspaces/r-workspace/rocker_scripts/install_julia.sh new file mode 100644 index 0000000..a38a204 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_julia.sh @@ -0,0 +1,58 @@ +#!/bin/bash +set -e + +## build ARGs +NCPUS=${NCPUS:--1} + +JULIA_VERSION=${1:-${JULIA_VERSION:-latest}} + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +ARCH_LONG=$(uname -p) +ARCH_SHORT=$ARCH_LONG + +if [ "$ARCH_LONG" = "x86_64" ]; then + ARCH_SHORT="x64" +fi + +apt_install wget + +install2.r --error --skipmissing --skipinstalled -n "$NCPUS" \ + yaml \ + JuliaCall \ + JuliaConnectoR + +# Get the latest Julia version by using R and the R yaml package. +if [ "$JULIA_VERSION" = "latest" ]; then + # shellcheck disable=SC2016 + JULIA_VERSION=$(Rscript -e ' +js <- yaml::read_yaml("https://julialang-s3.julialang.org/bin/versions.json") +versions <- names(js) +is_stable <- unlist(Map(function(x) x$stable, js)) +latest_version <- sort(versions[is_stable], decreasing = TRUE)[1] +cat(latest_version) +') +fi + +JULIA_MINOR_VERSION=${JULIA_VERSION%.*} + +# Download Julia and create a symbolic link. +wget "https://julialang-s3.julialang.org/bin/linux/${ARCH_SHORT}/${JULIA_MINOR_VERSION}/julia-${JULIA_VERSION}-linux-${ARCH_LONG}.tar.gz" +mkdir /opt/julia +tar zxvf "julia-${JULIA_VERSION}-linux-${ARCH_LONG}.tar.gz" -C /opt/julia --strip-components 1 +rm -f "julia-${JULIA_VERSION}-linux-${ARCH_LONG}.tar.gz" +ln -s /opt/julia/bin/julia /usr/local/bin/julia + +julia --version + +# Clean up +rm -rf /var/lib/apt/lists/* +rm -rf /tmp/downloaded_packages diff --git a/workspaces/r-workspace/rocker_scripts/install_nvtop.sh b/workspaces/r-workspace/rocker_scripts/install_nvtop.sh new file mode 100644 index 0000000..267df03 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_nvtop.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +apt-get update && apt-get -y install cmake libncurses5-dev libncursesw5-dev git +git clone https://github.com/Syllo/nvtop.git +mkdir -p nvtop/build && cd nvtop/build +cmake .. -DNVML_RETRIEVE_HEADER_ONLINE=True +make +make install + +# Clean up +rm -rf /var/lib/apt/lists/* diff --git a/workspaces/r-workspace/rocker_scripts/install_pandoc.sh b/workspaces/r-workspace/rocker_scripts/install_pandoc.sh new file mode 100644 index 0000000..32b7bc9 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_pandoc.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +## Install pandoc or symlinks pandoc, pandoc-citeproc so they are available system-wide. +## +## In order of preference, first argument of the script, the PANDOC_VERSION variable. +## ex. latest, default +## +## 'default' means the version bundled with RStudio if RStudio is installed, but 'latest' otherwise. +## 'latest' means installing the latest release version. + +set -e + +PANDOC_VERSION=${1:-${PANDOC_VERSION:-"default"}} +ARCH=$(dpkg --print-architecture) + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install wget + +if [ -x "$(command -v pandoc)" ]; then + INSTALLED_PANDOC_VERSION=$(pandoc --version 2>/dev/null | head -n 1 | grep -oP '[\d\.]+$') +fi + +if [ -f "/usr/lib/rstudio-server/bin/pandoc/pandoc" ]; then + BUNDLED_PANDOC="/usr/lib/rstudio-server/bin/pandoc/pandoc" +elif [ -f "/usr/lib/rstudio-server/bin/quarto/bin/pandoc" ]; then + BUNDLED_PANDOC="/usr/lib/rstudio-server/bin/quarto/bin/pandoc" +elif [ -f "/usr/lib/rstudio-server/bin/quarto/bin/tools/pandoc" ]; then + BUNDLED_PANDOC="/usr/lib/rstudio-server/bin/quarto/bin/tools/pandoc" +fi + +if [ -n "$BUNDLED_PANDOC" ]; then + BUNDLED_PANDOC_VERSION="$($BUNDLED_PANDOC --version | head -n 1 | grep -oP '[\d\.]+$')" +fi + +if [ "$PANDOC_VERSION" != "$INSTALLED_PANDOC_VERSION" ]; then + + if [ "$PANDOC_VERSION" = "default" ] && [ -z "$BUNDLED_PANDOC" ]; then + PANDOC_VERSION="latest" + fi + + if [ "$PANDOC_VERSION" = "$BUNDLED_PANDOC_VERSION" ] || [ "$PANDOC_VERSION" = "default" ]; then + ln -fs "$BUNDLED_PANDOC" /usr/local/bin + if [ -f "${BUNDLED_PANDOC}-citeproc" ]; then + ln -fs "${BUNDLED_PANDOC}-citeproc" /usr/local/bin + fi + else + if [ -L "/usr/local/bin/pandoc" ]; then + unlink /usr/local/bin/pandoc + fi + if [ -L "/usr/local/bin/pandoc-citeproc" ]; then + unlink /usr/local/bin/pandoc-citeproc + fi + + if [ "$PANDOC_VERSION" = "latest" ]; then + PANDOC_DL_URL=$(wget -qO- https://api.github.com/repos/jgm/pandoc/releases/latest | grep -oP "(?<=\"browser_download_url\":\s\")https.*${ARCH}\.deb") + else + PANDOC_DL_URL="https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-1-${ARCH}.deb" + fi + wget "$PANDOC_DL_URL" -O pandoc.deb + dpkg -i pandoc.deb + rm pandoc.deb + fi + + ## Symlink pandoc & standard pandoc templates for use system-wide + PANDOC_TEMPLATES_VERSION=$(pandoc -v | grep -oP "(?<=pandoc\s)[0-9\.]+$") + wget "https://github.com/jgm/pandoc-templates/archive/${PANDOC_TEMPLATES_VERSION}.tar.gz" -O pandoc-templates.tar.gz + rm -fr /opt/pandoc/templates + mkdir -p /opt/pandoc/templates + tar xvf pandoc-templates.tar.gz + cp -r pandoc-templates*/* /opt/pandoc/templates && rm -rf pandoc-templates* + rm -fr /root/.pandoc + mkdir /root/.pandoc && ln -s /opt/pandoc/templates /root/.pandoc/templates +fi + +# Clean up +rm -rf /var/lib/apt/lists/* + +# Check the pandoc version +echo -e "Check the pandoc version...\n" +pandoc --version +echo -e "\nInstall pandoc, done!" diff --git a/workspaces/r-workspace/rocker_scripts/install_pyenv.sh b/workspaces/r-workspace/rocker_scripts/install_pyenv.sh new file mode 100644 index 0000000..272cb07 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_pyenv.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +## Install pyenv, to facilitate installation of different python versions +## Allows users to do things like: +## pyenv install 3.7.9 # install python 3.7.9; e.g. for tensorflow 1.15.x +## pyenv global 3.7.9 # activate as the default python +## + +set -e + +PYTHON_CONFIGURE_OPTS=${PYTHON_CONFIGURE_OPTS:-"--enable-shared"} + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +echo "PYTHON_CONFIGURE_OPTS=${PYTHON_CONFIGURE_OPTS}" >>"${R_HOME}/etc/R_environ" + +apt_install \ + curl \ + python3-pip + +python3 -m pip --no-cache-dir install --upgrade --ignore-installed pipenv + +# consider a version-stable alternative for the installer? +curl https://pyenv.run | bash +mv /root/.pyenv /opt/pyenv + +# pipenv requires ~/.local/bin to be on the path... +echo "PATH=/opt/pyenv/bin:~/.local/bin:$PATH" >>"${R_HOME}/etc/Renviron.site" +cat <<"EOF" >>/etc/bash.bashrc +PATH=/opt/pyenv/bin:~/.local/bin:$PATH +eval "$(pyenv init --path)" +eval "$(pyenv virtualenv-init -)" +EOF + +# Clean up +rm -rf /var/lib/apt/lists/* diff --git a/workspaces/r-workspace/rocker_scripts/install_python.sh b/workspaces/r-workspace/rocker_scripts/install_python.sh new file mode 100644 index 0000000..bc2be5a --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_python.sh @@ -0,0 +1,77 @@ +#!/bin/bash +set -e + +## build ARGs +NCPUS=${NCPUS:--1} + +WORKON_HOME=${WORKON_HOME:-/opt/venv} +PYTHON_VENV_PATH=${PYTHON_VENV_PATH:-${WORKON_HOME}/reticulate} +RETICULATE_MINICONDA_ENABLED=${RETICULATE_MINICONDA_ENABLED:-FALSE} + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install \ + git \ + libpng-dev \ + libpython3-dev \ + python3-dev \ + python3-pip \ + python3-virtualenv \ + python3-venv \ + swig + +python3 -m pip --no-cache-dir install --upgrade \ + pip \ + setuptools \ + virtualenv + +# Some TF tools expect a "python" binary +if [ ! -e /usr/local/bin/python ]; then + ln -s "$(which python3)" /usr/local/bin/python +fi + +mkdir -p "${WORKON_HOME}" +python3 -m venv "${PYTHON_VENV_PATH}" + +install2.r --error --skipmissing --skipinstalled -n "$NCPUS" reticulate + +## Ensure RStudio inherits this env var +cat <>"${R_HOME}/etc/Renviron.site" + +WORKON_HOME=${WORKON_HOME} +RETICULATE_MINICONDA_ENABLED=${RETICULATE_MINICONDA_ENABLED} +EOF + +## symlink these so that these are available when switching to a new venv +## -f check for file, -L for link, -e for either +if [ ! -e /usr/local/bin/python ]; then + ln -s "$(which python3)" /usr/local/bin/python +fi + +if [ ! -e /usr/local/bin/pip ]; then + ln -s "${PYTHON_VENV_PATH}/bin/pip" /usr/local/bin/pip +fi + +if [ ! -e /usr/local/bin/virtualenv ]; then + ln -s "${PYTHON_VENV_PATH}/bin/virtualenv" /usr/local/bin/virtualenv +fi + +## Allow staff-level users to modify the shared environment +chown -R :staff "${WORKON_HOME}" +chmod g+wx "${WORKON_HOME}" +chown :staff "${PYTHON_VENV_PATH}" + +## Enable pyenv +/rocker_scripts/install_pyenv.sh + +# Clean up +rm -rf /var/lib/apt/lists/* +rm -rf /tmp/downloaded_packages diff --git a/workspaces/r-workspace/rocker_scripts/install_quarto.sh b/workspaces/r-workspace/rocker_scripts/install_quarto.sh new file mode 100644 index 0000000..d9692a1 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_quarto.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +## Install quarto cli or symlink quarto cli so they are available system-wide. +## +## In order of preference, first argument of the script, the QUARTO_VERSION variable. +## ex. latest, default, 0.9.16 +## +## 'default' means the version bundled with RStudio if RStudio is installed, but 'latest' otherwise. +## 'latest' means installing the latest release version. + +set -e + +## build ARGs +NCPUS=${NCPUS:--1} + +QUARTO_VERSION=${1:-${QUARTO_VERSION:-"latest"}} +# Only amd64 build can be installed now +ARCH=$(dpkg --print-architecture) + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install wget + +if [ -x "$(command -v quarto)" ]; then + INSTALLED_QUARTO_VERSION=$(quarto --version) +fi + +# Check RStudio bundled quarto cli +if [ -f "/usr/lib/rstudio-server/bin/quarto/bin/quarto" ]; then + BUNDLED_QUARTO="/usr/lib/rstudio-server/bin/quarto/bin/quarto" +fi + +if [ -n "$BUNDLED_QUARTO" ]; then + BUNDLED_QUARTO_VERSION="$($BUNDLED_QUARTO --version)" +fi + +# Install quarto cli +if [ "$QUARTO_VERSION" != "$INSTALLED_QUARTO_VERSION" ]; then + + # Check RStudio bundled quarto cli + if [ "$QUARTO_VERSION" = "default" ] && [ -z "$BUNDLED_QUARTO" ]; then + QUARTO_VERSION="latest" + fi + + if [ "$QUARTO_VERSION" = "$BUNDLED_QUARTO_VERSION" ] || [ "$QUARTO_VERSION" = "default" ]; then + ln -fs "$BUNDLED_QUARTO" /usr/local/bin + else + if [ "$QUARTO_VERSION" = "latest" ]; then + QUARTO_DL_URL=$(wget -qO- https://api.github.com/repos/quarto-dev/quarto-cli/releases/latest | grep -oP "(?<=\"browser_download_url\":\s\")https.*${ARCH}\.deb") + else + QUARTO_DL_URL="https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-${ARCH}.deb" + fi + wget "$QUARTO_DL_URL" -O quarto.deb + dpkg -i quarto.deb + rm quarto.deb + fi + + quarto check install + +fi + +# Install the quarto R package +install2.r --error --skipmissing --skipinstalled -n "$NCPUS" \ + knitr \ + quarto + +# Clean up +rm -rf /var/lib/apt/lists/* +rm -rf /tmp/downloaded_packages diff --git a/workspaces/r-workspace/scripts/install_rstudio.sh b/workspaces/r-workspace/rocker_scripts/install_rstudio.sh similarity index 98% rename from workspaces/r-workspace/scripts/install_rstudio.sh rename to workspaces/r-workspace/rocker_scripts/install_rstudio.sh index 679bc9c..c4b9389 100644 --- a/workspaces/r-workspace/scripts/install_rstudio.sh +++ b/workspaces/r-workspace/rocker_scripts/install_rstudio.sh @@ -118,6 +118,7 @@ EOF /rocker_scripts/default_user.sh "${DEFAULT_USER}" # install user config initiation script +mkdir -p /etc/cont-init.d cp /rocker_scripts/init_set_env.sh /etc/cont-init.d/01_set_env cp /rocker_scripts/init_userconf.sh /etc/cont-init.d/02_userconf cp /rocker_scripts/pam-helper.sh /usr/lib/rstudio-server/bin/pam-helper @@ -130,4 +131,4 @@ echo -e "Check the RStudio Server version...\n" /usr/lib/rstudio-server/bin/rstudio-server version -echo -e "\nInstall RStudio Server, done!" \ No newline at end of file +echo -e "\nInstall RStudio Server, done!" diff --git a/workspaces/r-workspace/rocker_scripts/install_s6init.sh b/workspaces/r-workspace/rocker_scripts/install_s6init.sh new file mode 100644 index 0000000..593e51e --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_s6init.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -e + +### Sets up S6 supervisor. + +S6_VERSION=${1:-${S6_VERSION:-"v2.1.0.2"}} + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +ARCH=$(dpkg --print-architecture) + +if [ "$ARCH" = "arm64" ]; then + ARCH=aarch64 +fi + +DOWNLOAD_FILE=s6-overlay-${ARCH}.tar.gz + +apt_install wget + +## Set up S6 init system +if [ -f "/rocker_scripts/.s6_version" ] && [ "$S6_VERSION" = "$(cat /rocker_scripts/.s6_version)" ]; then + echo "S6 already installed" +else + wget -P /tmp/ "https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/${DOWNLOAD_FILE}" + + ## need the modified double tar now, see https://github.com/just-containers/s6-overlay/issues/288 + tar hzxf /tmp/$DOWNLOAD_FILE -C / --exclude=usr/bin/execlineb + tar hzxf /tmp/$DOWNLOAD_FILE -C /usr ./bin/execlineb + + echo "$S6_VERSION" >/rocker_scripts/.s6_version +fi + +# Clean up +rm -rf /var/lib/apt/lists/* +rm -f /tmp/$DOWNLOAD_FILE diff --git a/workspaces/r-workspace/rocker_scripts/install_shiny_server.sh b/workspaces/r-workspace/rocker_scripts/install_shiny_server.sh new file mode 100644 index 0000000..ddbbfd5 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_shiny_server.sh @@ -0,0 +1,74 @@ +#!/bin/bash +set -e + +SHINY_SERVER_VERSION=${1:-${SHINY_SERVER_VERSION:-latest}} + +## build ARGs +NCPUS=${NCPUS:--1} + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install \ + sudo \ + gdebi-core \ + libcurl4-openssl-dev \ + libcairo2-dev \ + libxt-dev \ + xtail \ + wget + +# Run dependency scripts +/rocker_scripts/install_s6init.sh +/rocker_scripts/install_pandoc.sh + +# Install Shiny server + +if [ "$SHINY_SERVER_VERSION" = "latest" ]; then + SHINY_SERVER_VERSION=$(wget -qO- https://download3.rstudio.org/ubuntu-14.04/x86_64/VERSION) +fi + +wget --no-verbose "https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-${SHINY_SERVER_VERSION}-amd64.deb" -O ss-latest.deb +gdebi -n ss-latest.deb +rm ss-latest.deb + +# Get R packages +install2.r --error --skipinstalled -n "$NCPUS" shiny rmarkdown + +# Set up directories and permissions +if [ -x "$(command -v rstudio-server)" ]; then + DEFAULT_USER=${DEFAULT_USER:-rstudio} + adduser "${DEFAULT_USER}" shiny +fi + +cp -R /usr/local/lib/R/site-library/shiny/examples/* /srv/shiny-server/ +chown shiny:shiny /var/lib/shiny-server +mkdir -p /var/log/shiny-server +chown shiny:shiny /var/log/shiny-server + +# create init scripts +mkdir -p /etc/services.d/shiny-server +cat <<"EOF" >/etc/services.d/shiny-server/run +#!/usr/bin/with-contenv bash +## load /etc/environment vars first: +for line in $( cat /etc/environment ) ; do export $line > /dev/null; done +if [ "$APPLICATION_LOGS_TO_STDOUT" != "false" ]; then + exec xtail /var/log/shiny-server/ & +fi +exec shiny-server 2>&1 +EOF +chmod +x /etc/services.d/shiny-server/run + +# install init script +cp /rocker_scripts/init_set_env.sh /etc/cont-init.d/01_set_env + +# Clean up +rm -rf /var/lib/apt/lists/* +rm -rf /tmp/downloaded_packages diff --git a/workspaces/r-workspace/rocker_scripts/install_tensorflow.sh b/workspaces/r-workspace/rocker_scripts/install_tensorflow.sh new file mode 100644 index 0000000..b3f790b --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_tensorflow.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +## build ARGs +NCPUS=${NCPUS:--1} + +TENSORFLOW_VERSION=${1:-${TENSORFLOW_VERSION:-default}} +KERAS_VERSION=${2:-${KERAS_VERSION:-default}} + +## Install python dependency +# . /rocker_scripts/install_python.sh + +## To support different version of TF, install to different virtualenvs +TENSORFLOW_VENV=$PYTHON_VENV_PATH +install2.r --error --skipinstalled -n $NCPUS keras +#Rscript -e "keras::install_keras(version = \"$KERAS_VERSION\", \ +# tensorflow = \"$TENSORFLOW_VERSION\", \ +# envname =\"$TENSORFLOW_VENV\")" + +rm -r /tmp/downloaded_packages + +chown -R 1000:1000 /opt/venv +chmod -R 777 /opt/venv diff --git a/workspaces/r-workspace/rocker_scripts/install_texlive.sh b/workspaces/r-workspace/rocker_scripts/install_texlive.sh new file mode 100644 index 0000000..41d796c --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_texlive.sh @@ -0,0 +1,72 @@ +#!/bin/bash +set -e + +CTAN_REPO=${1:-${CTAN_REPO:-"https://mirror.ctan.org/systems/texlive/tlnet"}} + +ARCH=$(uname -m) + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +cat </tmp/texlive-profile.txt +selected_scheme scheme-infraonly +TEXDIR /usr/local/texlive +TEXMFCONFIG /opt/texlive/texmf-config +TEXMFHOME /opt/texlive/texmf +TEXMFLOCAL /opt/texlive/texmf-local +TEXMFSYSCONFIG /opt/texlive/texmf-config +TEXMFSYSVAR /opt/texlive/texmf-var +TEXMFVAR /opt/texlive/texmf-var +option_doc 0 +option_src 0 +EOF + +export PATH="${PATH}:/usr/local/texlive/bin/${ARCH}-linux/" + +mkdir -p /opt/texlive +# set up packages +apt_install \ + wget \ + perl \ + xzdec + +wget "${CTAN_REPO}/install-tl-unx.tar.gz" +tar -xzf install-tl-unx.tar.gz +cd ./install-tl-20* +./install-tl --profile=/tmp/texlive-profile.txt --repository "$CTAN_REPO" +cd .. +rm -rf install-tl-* +rm /tmp/texlive-profile.txt + +tlmgr update --self +tlmgr install latex-bin luatex xetex +tlmgr install ae bibtex context inconsolata listings makeindex metafont mfware parskip pdfcrop tex tools url xkeyval + +## do not add to /usr/local/bin +# tlmgr path add +# instead, we keep binaries separate and add to PATH +echo "PATH=${PATH}" >>"${R_HOME}"/etc/Renviron.site + +## open permissions to avoid needless warnings +NON_ROOT_USER=$(getent passwd "1000" | cut -d: -f1) +if [ -n "$NON_ROOT_USER" ]; then + chown -R "${NON_ROOT_USER}":staff /opt/texlive + chown -R "${NON_ROOT_USER}":staff /usr/local/texlive +fi +chmod -R 777 /opt/texlive +chmod -R 777 /usr/local/texlive + +# Clean up +rm -rf /var/lib/apt/lists/* + +# Check the tlmgr version +echo -e "Check the tlmgr version...\n" +tlmgr --version +echo -e "\nInstall texlive, done!" diff --git a/workspaces/r-workspace/rocker_scripts/install_tf1_cuda_10_0.sh b/workspaces/r-workspace/rocker_scripts/install_tf1_cuda_10_0.sh new file mode 100644 index 0000000..b6f85ab --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_tf1_cuda_10_0.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e + +# Tensorflow 1.x is required for numerous projects. +# Even the most recent of the 1.x, 1.15.5 is compatible only +# with CUDA 10.0 versions of the following libraries. + +# Fortunately, these are available from the NVIDIA Ubuntu debian PPA repos added in 10.1 images + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install \ + cuda-cudart-10-0 \ + cuda-cufft-10-0 \ + cuda-cusolver-10-0 \ + cuda-curand-10-0 \ + cuda-cusparse-10-0 \ + cuda-cublas-10-0 + +# Clean up +rm -rf /var/lib/apt/lists/* diff --git a/workspaces/r-workspace/rocker_scripts/install_tidyverse.sh b/workspaces/r-workspace/rocker_scripts/install_tidyverse.sh new file mode 100644 index 0000000..f29b8f8 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_tidyverse.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +set -e + +## build ARGs +NCPUS=${NCPUS:--1} + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install \ + libxml2-dev \ + libcairo2-dev \ + libgit2-dev \ + default-libmysqlclient-dev \ + libpq-dev \ + libsasl2-dev \ + libsqlite3-dev \ + libssh2-1-dev \ + libxtst6 \ + libcurl4-openssl-dev \ + unixodbc-dev + +install2.r --error --skipinstalled -n "$NCPUS" \ + tidyverse \ + devtools \ + rmarkdown \ + BiocManager \ + vroom \ + gert + +## dplyr database backends +install2.r --error --skipmissing --skipinstalled -n "$NCPUS" \ + arrow \ + dbplyr \ + DBI \ + dtplyr \ + duckdb \ + nycflights13 \ + Lahman \ + RMariaDB \ + RPostgres \ + RSQLite \ + fst + +## a bridge to far? -- brings in another 60 packages +# install2.r --error --skipinstalled -n "$NCPUS" tidymodels + +# Clean up +rm -rf /var/lib/apt/lists/* +rm -rf /tmp/downloaded_packages + +# Check the tidyverse core packages' version +echo -e "Check the tidyverse package...\n" + +R -q -e "library(tidyverse)" + +echo -e "\nInstall tidyverse package, done!" diff --git a/workspaces/r-workspace/rocker_scripts/install_verse.sh b/workspaces/r-workspace/rocker_scripts/install_verse.sh new file mode 100644 index 0000000..062df96 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_verse.sh @@ -0,0 +1,95 @@ +#!/bin/bash +set -e + +## build ARGs +NCPUS=${NCPUS:--1} + +# always set this for scripts but don't declare as ENV.. +export DEBIAN_FRONTEND=noninteractive + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install \ + cmake \ + curl \ + default-jdk \ + fonts-roboto \ + ghostscript \ + hugo \ + less \ + libbz2-dev \ + libglpk-dev \ + libgmp3-dev \ + libfribidi-dev \ + libharfbuzz-dev \ + libhunspell-dev \ + libicu-dev \ + liblzma-dev \ + libmagick++-dev \ + libopenmpi-dev \ + libpcre2-dev \ + libssl-dev \ + libv8-dev \ + libxml2-dev \ + libxslt1-dev \ + libzmq3-dev \ + lsb-release \ + qpdf \ + texinfo \ + software-properties-common \ + vim \ + wget + +# libgit2-dev also depends on the libcurl4-gnutils in bionic but not on focal +# cran PPA is a super-stable solution to this +UBUNTU_VERSION=$(lsb_release -sc) +if [ "${UBUNTU_VERSION}" == "bionic" ]; then + add-apt-repository -y ppa:cran/travis +fi + +# librdf0-dev depends on libcurl4-gnutils-dev instead of libcurl4-openssl-dev... +# So: we can build the redland package bindings and then swap back to libcurl-openssl-dev... (ick) +# explicitly install runtime library sub-deps of librdf0-dev so they are not auto-removed. +apt_install librdf0-dev +install2.r --error --skipinstalled -n "$NCPUS" redland +apt_install \ + libcurl4-openssl-dev \ + libgit2-dev \ + libxslt-dev \ + librdf0 \ + redland-utils \ + rasqal-utils \ + raptor2-utils + +apt-get remove -y systemd +apt-get -y autoremove + +## Add LaTeX, rticles and bookdown support +wget "https://travis-bin.yihui.name/texlive-local.deb" +dpkg -i texlive-local.deb +rm texlive-local.deb + +## Install texlive +/rocker_scripts/install_texlive.sh + +install2.r --error --skipinstalled -n "$NCPUS" tinytex +install2.r --error --skipmissing --deps TRUE --skipinstalled -n "$NCPUS" \ + blogdown \ + bookdown \ + distill \ + rticles \ + rmdshower \ + rJava \ + xaringan + +# Clean up +rm -rf /tmp/downloaded_packages +rm -rf /var/lib/apt/lists/* diff --git a/workspaces/r-workspace/rocker_scripts/install_wgrib2.sh b/workspaces/r-workspace/rocker_scripts/install_wgrib2.sh new file mode 100644 index 0000000..36c3d42 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/install_wgrib2.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +## https://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/ + +# a function to install apt packages only if they are not installed +function apt_install() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + apt-get update + fi + apt-get install -y --no-install-recommends "$@" + fi +} + +apt_install wget + +cd /opt +wget https://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz +tar -xvf wgrib2.tgz +rm -rf wgrib2.tgz +cd grib2 + +## arm64: need to rewrite the makefile to compile wgrib2 to use NetCDF4, but it is not supported in 8/2020. +## https://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/index.html +## set USE_NETCDF4=1, USE_JASPER=0 +# if [ $(dpkg --print-architecture) = "arm64" ]; then +# sed -i -e 's/^USE_NETCDF4=0/USE_NETCDF4=1/' makefile +# sed -i -e 's/^USE_NETCDF3=1/USE_NETCDF3=0/' makefile +# sed -i -e 's/^USE_JASPER=1/USE_JASPER=0/' makefile +# fi + +## really someone needs to learn proper packaging conventions, but whatever +CC=gcc FC=gfortran make +ln -s /opt/grib2/wgrib2/wgrib2 /usr/local/bin/wgrib2 + +# Clean up +rm -rf /var/lib/apt/lists/* diff --git a/workspaces/r-workspace/rocker_scripts/pam-helper.sh b/workspaces/r-workspace/rocker_scripts/pam-helper.sh new file mode 100644 index 0000000..be98a8f --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/pam-helper.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -o nounset + +## Enforces the custom password specified in the PASSWORD environment variable +## The accepted RStudio username is the same as the USER environment variable (i.e., local user name). + + +IFS='' read -r password + +[ "${USER}" = "${1}" ] && [ "${PASSWORD}" = "${password}" ] diff --git a/workspaces/r-workspace/rocker_scripts/rsession.sh b/workspaces/r-workspace/rocker_scripts/rsession.sh new file mode 100644 index 0000000..67c2891 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/rsession.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +R_DOC_DIR=$R_HOME/doc +R_INCLUDE_DIR=$R_HOME/include +R_SHARE_DIR=$R_HOME/share +RSTUDIO_DEFAULT_R_VERSION_HOME=$R_HOME +RSTUDIO_DEFAULT_R_VERSION=$R_VERSION +PATH=$PATH:/usr/lib/rstudio-server/bin +rsession --standalone=1 \ + --program-mode=server \ + --session-timeout-minutes=0 \ + --user-identity=rstudio \ + --www-port=8787 diff --git a/workspaces/r-workspace/scripts/setup_R.sh b/workspaces/r-workspace/rocker_scripts/setup_R.sh similarity index 98% rename from workspaces/r-workspace/scripts/setup_R.sh rename to workspaces/r-workspace/rocker_scripts/setup_R.sh index cb09ae0..2d02938 100644 --- a/workspaces/r-workspace/scripts/setup_R.sh +++ b/workspaces/r-workspace/rocker_scripts/setup_R.sh @@ -89,10 +89,10 @@ rm -rf /var/lib/apt/lists/* # Check the R info echo -e "Check the littler info...\n" -r --version +R --version echo -e "Check the R info...\n" R -q -e "sessionInfo()" -echo -e "Setup R, done!" \ No newline at end of file +echo -e "Setup R, done!" diff --git a/workspaces/r-workspace/rocker_scripts/tests/examples_tf.R b/workspaces/r-workspace/rocker_scripts/tests/examples_tf.R new file mode 100644 index 0000000..ca3f933 --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/tests/examples_tf.R @@ -0,0 +1,36 @@ + +## Tensorflow: +install.packages('keras', repos='http://cran.us.r-project.org') +library(keras) +mnist <- dataset_mnist() +x_train <- mnist$train$x +y_train <- mnist$train$y +x_test <- mnist$test$x +y_test <- mnist$test$y +# reshape +x_train <- array_reshape(x_train, c(nrow(x_train), 784)) +x_test <- array_reshape(x_test, c(nrow(x_test), 784)) +# rescale +x_train <- x_train / 255 +x_test <- x_test / 255 +y_train <- to_categorical(y_train, 10) +y_test <- to_categorical(y_test, 10) +model <- keras_model_sequential() +model %>% + layer_dense(units = 256, activation = 'relu', input_shape = c(784)) %>% + layer_dropout(rate = 0.4) %>% + layer_dense(units = 128, activation = 'relu') %>% + layer_dropout(rate = 0.3) %>% + layer_dense(units = 10, activation = 'softmax') + + model %>% compile( + loss = 'categorical_crossentropy', + optimizer = optimizer_rmsprop(), + metrics = c('accuracy') + ) + history <- model %>% fit( + x_train, y_train, + epochs = 30, batch_size = 128, + validation_split = 0.2 + ) +model %>% evaluate(x_test, y_test) diff --git a/workspaces/r-workspace/rocker_scripts/tests/nvblas.R b/workspaces/r-workspace/rocker_scripts/tests/nvblas.R new file mode 100644 index 0000000..c0bbbda --- /dev/null +++ b/workspaces/r-workspace/rocker_scripts/tests/nvblas.R @@ -0,0 +1,11 @@ +install.packages("callr") + + +callr::r(function(){ + system.time({ + N <- 2^14 + M <- matrix(rnorm(N*N), nrow=N, ncol=N) + M %*% M + }) + }, env = c(LD_PRELOAD="libnvblas.so") +)