Browse Source

add R dev container

liuyuqi-dellpc 2 years ago
parent
commit
a1bd3109cf
3 changed files with 77 additions and 0 deletions
  1. 40 0
      R/.devcontainer/Dockerfile
  2. 37 0
      R/.devcontainer/devcontainer.json
  3. 0 0
      R/.github/workflows/build.yml

+ 40 - 0
R/.devcontainer/Dockerfile

@@ -0,0 +1,40 @@
+# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/java-8/.devcontainer/base.Dockerfile
+
+# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
+ARG VARIANT="bullseye"
+FROM mcr.microsoft.com/vscode/devcontainers/java:0-8-${VARIANT}
+
+WORKDIR /home/vscode
+ENV CRAN_URL=https://cloud.r-project.org/
+ENV R_LIBS_USER=/workspaces/RStudio-container/tools/RPackages
+
+# install R
+RUN apt-get update \
+&& apt install -y r-base-core r-base-dev
+
+# install RStudio-server
+RUN apt install -y wget  \
+&& wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2022.02.2-485-amd64.deb  \
+&& apt-get install -y gdebi-core  \
+&& gdebi -n rstudio-server-2022.02.2-485-amd64.deb \
+&& rm rstudio-server-2022.02.2-485-amd64.deb
+
+# set user and pwd: rstudio/rstudio
+WORKDIR /workspaces
+# RUN set -eo pipefail \
+#       && ln -s /dev/stdout /var/log/syslog \
+RUN echo "r-cran-repos=${CRAN_URL}" >> /etc/rstudio/rsession.conf \
+      && useradd -m -d /home/rstudio rstudio \
+      && usermod -a -G vscode rstudio \
+      && echo rstudio:rstudio | chpasswd  \
+      && mkdir -p /home/rstudio/workspaces \
+      && ln -s /workspaces/RStudio-container /home/rstudio/workspaces
+
+RUN apt-get -y autoremove \
+&& apt-get clean \
+&& rm -rf /var/lib/apt/lists/*
+
+EXPOSE 8787
+
+ENTRYPOINT ["/usr/lib/rstudio-server/bin/rserver"]
+CMD ["--server-daemonize=0", "--server-app-armor-enabled=0"]

+ 37 - 0
R/.devcontainer/devcontainer.json

@@ -0,0 +1,37 @@
+// java8 + android env
+// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
+// https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/java-8
+{
+	"name": "Java 8",
+	"build": {
+		"dockerfile": "Dockerfile",
+		"args": {
+			// Use the VARIANT arg to pick a Debian OS version: buster, bullseye
+			// Use bullseye when running on local arm64/Apple Silicon.
+			"VARIANT": "buster"
+			// Options
+		}
+	},
+
+	// Set *default* container specific settings.json values on container create.
+	"settings": {
+
+	},
+
+	// Add the IDs of extensions you want installed when the container is created.
+	"extensions": [
+
+	],
+
+	// Use 'forwardPorts' to make a list of ports inside the container available locally.
+	"forwardPorts": [8787],
+
+	// Use 'postCreateCommand' to run commands after the container is created.
+	// "postCreateCommand": "java -version",
+
+	// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
+	"remoteUser": "vscode",
+	"features": {
+		"docker-in-docker": "latest"
+	}
+}

+ 0 - 0
R/build.yml → R/.github/workflows/build.yml