Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 90a90b8

Browse files
committed
experiement with docker-compose
1 parent 268d86c commit 90a90b8

4 files changed

Lines changed: 116 additions & 24 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,14 @@
66
FROM rocker/r-ver:4.1.3
77

88
# Options for setup script
9-
ARG INSTALL_ZSH="false"
10-
ARG INSTALL_FISH="true"
11-
ARG UPGRADE_PACKAGES="true"
129
ARG USERNAME
1310
ARG QUARTO_VERSION=latest
14-
ARG USER_UID=1000
15-
ARG USER_GID=$USER_UID
16-
17-
# Remove the docker user since I don't need it for VSCode containers
18-
#RUN groupmod docker --gid 1005 \
19-
# && usermod --uid 1005 docker
20-
21-
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
22-
COPY library-scripts/*.sh /tmp/library-scripts/
23-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
24-
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${INSTALL_FISH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \
25-
&& apt-get -y install libzip-dev \
26-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
2711

2812
# [Optional] Uncomment this section to install additional OS packages.
2913
# key dependencies for certain R packages
3014
RUN apt-get update \
3115
&& export DEBIAN_FRONTEND=noninteractive \
32-
&& apt-get -y install --no-install-recommends software-properties-common libssl-dev libxml2-dev libcurl4-openssl-dev python3-pip pandoc \
16+
&& apt-get -y install --no-install-recommends software-properties-common wget libssl-dev libxml2-dev libcurl4-openssl-dev python3-pip pandoc libzip-dev \
3317
&& apt-get -y install --no-install-recommends libfreetype6-dev libfontconfig1-dev tk \
3418
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
3519

@@ -55,15 +39,11 @@ RUN apt-get update \
5539
RUN echo "RENV_PATHS_CACHE=/renv/cache" >> /usr/local/lib/R/etc/Renviron
5640

5741
# copy the modified .Rprofile template to the renv cache
58-
COPY library-scripts/.Rprofile-vscode /renv/.Rprofile-vscode
42+
#COPY library-scripts/.Rprofile-vscode /renv/.Rprofile-vscode
5943

6044
# [Optional] Uncomment this section to add Quarto to the container
61-
# customize version number as appropriate
6245
RUN /rocker_scripts/install_quarto.sh
6346

64-
#RUN curl -L https://github.com/quarto-dev/quarto-cli/releases/download/v0.9.201/quarto-0.9.201-linux-amd64.deb -o /tmp/quarto.deb
65-
#RUN apt-get -y install ./tmp/quarto.deb
66-
6747
# [Optional] Uncomment this section to add Hugo to the container
6848
# Customize version number as appropriate
6949
#RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.87.0/hugo_extended_0.87.0_Linux-64bit.deb -o /tmp/hugo.deb

.devcontainer/devcontainer.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// https://github.com/microsoft/vscode-dev-containers/tree/v0.134.1/containers/r
33
{
44
"name": "R",
5+
//"dockerComposeFile": "docker-compose.yml",
6+
//"workspaceFolder": "/workspace",
7+
//"service": "vscode",
58
"build": {
69
"dockerfile": "Dockerfile",
710
"args": {
@@ -21,6 +24,18 @@
2124
//"source=/media/media_drive1/obs_files/audio_assets/soundboard_files,target=/soundboard_files,type=bind,consistency=cached",
2225
"source=/opt/local/renv/cache,target=/renv/cache,type=bind,consistency=cached"
2326
],
27+
"features": {
28+
"common": {
29+
"username": "${localEnv:USER}",
30+
"uid": "1000",
31+
"gid": "1000",
32+
"installZsh": false,
33+
"installOhMyZsh": false,
34+
"upgradePackages": true,
35+
"nonFreePackages": true
36+
},
37+
"fish": "latest"
38+
},
2439
// Configure environment variables for audio sound server if needed
2540
// You can leave these commented out or delete if you are not linking the contianer to a linux sound system
2641
//"containerEnv": {

.devcontainer/docker-compose.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
version: '3.4'
22

33
services:
4+
vscode:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
args:
9+
USERNAME: ${USER}
10+
QUARTO_VERSION: ${QUARTO_VERSION}
11+
user: ${USER}
12+
volumes:
13+
- ..:/workspace:cached
14+
- ${RENV_PATHS_CACHE_HOST}:/renv/cache
15+
cap_add:
16+
- SYS_PTRACE
17+
security_opt:
18+
- seccomp:unconfined
19+
command: sleep infinity
20+
env_file: .env
21+
422
rstudioquarto:
523
build:
624
context: ./rstudio_docker
25+
args:
26+
S6_VERSION: ${S6_VERSION}
27+
RSTUDIO_VERSION: ${RSTUDIO_VERSION}
28+
QUARTO_VERSION: ${QUARTO_VERSION}
729
container_name: ${CONTAINER_NAME}
830
volumes:
931
- ${VOLUME_PATH}:${VOLUME_PATH}
@@ -14,5 +36,4 @@ services:
1436
unless-stopped
1537
ports:
1638
- ${LOCAL_PORT}:8787
17-
env_file: .env
18-
39+
env_file: .env
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
###################################################################################################################
2+
# Adapted from https://github.com/microsoft/vscode-dev-containers/blob/master/containers/r/.devcontainer/Dockerfile
3+
# licence: MIT
4+
###################################################################################################################
5+
6+
FROM rocker/r-ver:4.1.3
7+
8+
# Options for setup script
9+
ARG USERNAME
10+
ARG QUARTO_VERSION=latest
11+
12+
# [Optional] Uncomment this section to install additional OS packages.
13+
# key dependencies for certain R packages
14+
RUN apt-get update \
15+
&& export DEBIAN_FRONTEND=noninteractive \
16+
&& apt-get -y install --no-install-recommends software-properties-common wget libssl-dev libxml2-dev libcurl4-openssl-dev python3-pip pandoc libzip-dev \
17+
&& apt-get -y install --no-install-recommends libfreetype6-dev libfontconfig1-dev tk \
18+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
19+
20+
# install R packages needed for VSCode interaction and package management
21+
RUN install2.r languageserver renv remotes httpgd
22+
23+
# install radian via python and pip3
24+
RUN apt-get update \
25+
&& export DEBIAN_FRONTEND=noninteractive \
26+
&& apt-get -y install --no-install-recommends python3-setuptools
27+
28+
RUN pip3 install radian
29+
30+
# install dot net core runtime for the R Tools plugin
31+
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O /tmp/packages-microsoft-prod.deb \
32+
&& dpkg -i /tmp/packages-microsoft-prod.deb
33+
34+
RUN apt-get update \
35+
&& apt-get -y install --no-install-recommends apt-transport-https \
36+
&& apt-get -y install --no-install-recommends dotnet-sdk-3.1
37+
38+
# ensure that the renv package cache env var is accessible in default R installation
39+
RUN echo "RENV_PATHS_CACHE=/renv/cache" >> /usr/local/lib/R/etc/Renviron
40+
41+
# copy the modified .Rprofile template to the renv cache
42+
COPY library-scripts/.Rprofile-vscode /renv/.Rprofile-vscode
43+
44+
# [Optional] Uncomment this section to add Quarto to the container
45+
RUN /rocker_scripts/install_quarto.sh
46+
47+
# [Optional] Uncomment this section to add Hugo to the container
48+
# Customize version number as appropriate
49+
#RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.87.0/hugo_extended_0.87.0_Linux-64bit.deb -o /tmp/hugo.deb
50+
#RUN apt-get -y install ./tmp/hugo.deb
51+
52+
# [Optional] Uncomment this section to add addtional system dependencies needed for project
53+
# RUN apt-get update \
54+
# && export DEBIAN_FRONTEND=noninteractive \
55+
# && apt-get -y install --no-install-recommends ---packages list----
56+
57+
# [Optional] Uncomment this section for linking a local pusleaudio sound system on a linux host
58+
# to the container.
59+
#RUN apt-get update \
60+
# && export DEBIAN_FRONTEND=noninteractive \
61+
# && apt-get -y install --no-install-recommends libpulse0 libasound2 libasound2-plugins pulseaudio-utils
62+
63+
# install obs-cli (Go version)
64+
# https://github.com/muesli/obs-cli/releases
65+
#ADD https://github.com/muesli/obs-cli/releases/download/v0.4.0/obs-cli_0.4.0_linux_x86_64.tar.gz /obs-cli-linux.tar.gz
66+
#RUN tar -zxvf obs-cli-linux.tar.gz
67+
#RUN cp /obs-cli /usr/local/bin/obs-cli
68+
#RUN chmod 755 /usr/local/bin/obs-cli
69+
70+
# install obs-cli (Javascript version)
71+
# https://github.com/leafac/obs-cli/releases
72+
#ADD https://github.com/leafac/obs-cli/releases/download/v2.2.3/obs-cli-linux /usr/local/bin/obs-cli-js
73+
#RUN chmod 755 /usr/local/bin/obs-cli-js
74+
75+
# [Optional] Set the default user. Omit if you want to keep the default as root.
76+
USER $USERNAME

0 commit comments

Comments
 (0)