diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7f0ad21..08d61ee 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -65,11 +65,12 @@ }, // Python "jupyter.notebookFileRoot": "${workspaceFolder}", - "python.pythonPath": "/usr/bin/python3", + "python.pythonPath": "/opt/venv/python", + "python.defaultInterpreterPath": "/opt/venv/python", "python.dataScience.interactiveWindowMode": "perFile", "python.dataScience.sendSelectionToInteractiveWindow": true, // R - "r.rterm.linux": "/usr/local/bin/radian", + "r.rterm.linux": "/opt/venv/radian", "r.bracketedPaste": true, "r.sessionWatcher": true, "r.plot.useHttpgd": true, diff --git a/Dockerfile b/Dockerfile index 092061d..e2f7bc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,25 @@ -FROM ubuntu:jammy@sha256:58b87898e82351c6cf9cf5b9f3c20257bb9e2dcf33af051e12ce532d7f94e3fe +FROM ubuntu:noble@sha256:b359f1067efa76f37863778f7b6d0e8d911e3ee8efa807ad01fbf5dc1ef9006b + SHELL ["/bin/bash", "-c"] ENV DISPLAY=:0 \ TZ=Europe/Berlin -ARG USERNAME=vscode +ARG USERNAME=ubuntu +ENV R_LIBS_USER=/home/$USERNAME/R/library +ARG VIRTUAL_ENV=/home/$USERNAME/python/venv ARG USER_UID=1000 ARG USER_GID=$USER_UID ARG DEBIAN_FRONTEND=noninteractive -# Add non root user -RUN groupadd --gid $USER_GID $USERNAME \ - && useradd -rm -d /home/$USERNAME -s /bin/bash -g root --uid $USER_UID --gid $USER_GID $USERNAME \ - && addgroup $USERNAME staff +# Add ubuntu user to ubuntu and staff groups +RUN usermod -a -G staff,$USERNAME $USERNAME # Create folders to mount extensions RUN mkdir -p /home/$USERNAME/.vscode-server/extensions \ /home/$USERNAME/.vscode-server-insiders/extensions \ + /home/$USERNAME/R/library \ workspaces \ && chown -R $USERNAME \ /home/$USERNAME/.vscode-server \ @@ -36,6 +38,7 @@ RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula sele ccache \ gfortran \ netbase \ + cargo \ zip \ unzip \ xclip \ @@ -47,6 +50,9 @@ RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula sele ssh-client \ fontconfig \ pkg-config \ + python3-pip \ + python3-dev \ + python3-venv \ default-libmysqlclient-dev \ ttf-mscorefonts-installer \ locales &&\ @@ -56,6 +62,10 @@ RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula sele git clone --depth=1 https://github.com/sindresorhus/pure.git /home/$USERNAME/.zsh/pure \ && rm -rf /home/$USERNAME/.zsh/pure/.git \ && apt-get autoclean -y \ + && apt-get clean \ + && rm -rf /var/cache/* \ + && rm -rf /tmp/* \ + && rm -rf /var/tmp/* \ && rm -rf /var/lib/apt/lists/* ENV LC_ALL=en_US.UTF-8 \ @@ -67,7 +77,6 @@ COPY .misc/lmroman10-regular-webfont.ttf /usr/share/fonts/truetype/. COPY .misc/lmroman10-italic-webfont.ttf /usr/share/fonts/truetype/. COPY .misc/lmroman10-bolditalic-webfont.ttf /usr/share/fonts/truetype/. COPY .misc/lmroman10-bold-webfont.ttf /usr/share/fonts/truetype/. - RUN fc-cache -f -v # Install quarto @@ -107,23 +116,6 @@ RUN git clone --depth=1 https://github.com/RUrlus/carma.git /usr/local/carma \ && cmake --build . --config Release --target install \ && rm -rf /usr/local/carma -# Install Python -COPY package_lists/python_packages.txt /package_lists/python_packages.txt - -RUN apt-get update &&\ - apt-get -y --no-install-recommends install \ - python3-pip \ - python3-dev \ - python3-venv && \ - # Python packages - pip3 install -U --no-cache-dir \ - $(grep -o '^[^#]*' package_lists/python_packages.txt | tr '\n' ' ') \ - && apt-get autoclean -y \ - && rm -rf /var/lib/apt/lists/* - -# Set PATH for user installed python packages -ENV PATH="/home/vscode/.local/bin:${PATH}" - # Install Latex COPY install_scripts/install_latex.sh /tmp/install_latex.sh COPY package_lists/latex_packages.txt /tmp/latex_packages.txt @@ -138,15 +130,15 @@ RUN chmod +x /tmp/install_latex.sh &&\ $(grep -o '^[^#]*' /tmp/latex_packages.txt | tr '\n' ' ') \ && chown --recursive $USERNAME:$USERNAME /usr/local/texlive -# Set Latex Path +# Set Latex Paths ENV PATH="/usr/local/texlive/bin/x86_64-linux:${PATH}" # Install R ENV R_VERSION=4.4.1 # Set RSPM snapshot see: -# https://packagemanager.posit.co/client/#/repos/cran/setup?r_environment=other&snapshot=2023-10-04&distribution=ubuntu-22.04 -ENV R_REPOS=https://packagemanager.posit.co/cran/__linux__/jammy/2024-10-01 +# https://packagemanager.posit.co/client/#/repos/cran/setup?r_environment=other&snapshot=2024-10-01&distribution=ubuntu-22.04 +ENV R_REPOS=https://packagemanager.posit.co/cran/__linux__/noble/2024-10-01 COPY install_scripts/install_r.sh /tmp/install_r.sh COPY package_lists/r_packages.txt /tmp/r_packages.txt @@ -155,6 +147,9 @@ COPY package_lists/r_packages_github.txt /tmp/r_packages_github.txt RUN chmod +x /tmp/install_r.sh &&\ /tmp/install_r.sh +RUN chown -R $USERNAME /usr/local/lib +RUN chown -R $USERNAME /usr/local/include + COPY --chown=$USERNAME .misc/.zshrc /home/$USERNAME/. COPY --chown=$USERNAME .misc/.Rprofile /home/$USERNAME/. @@ -165,11 +160,20 @@ COPY --chown=$USERNAME .misc/Makevars /home/$USERNAME/.R/. RUN mkdir /home/$USERNAME/.ccache && chown -R $USERNAME /home/$USERNAME/.ccache COPY --chown=$USERNAME .misc/ccache.conf /home/$USERNAME/.ccache/. -RUN chown -R $USERNAME /usr/local/lib -RUN chown -R $USERNAME /usr/local/include - # Switch to non-root user USER $USERNAME +# Install Python Packages +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" +COPY package_lists/python_packages.txt /package_lists/python_packages.txt + +RUN pip install --upgrade pip \ + && pip --no-cache-dir install \ + $(grep -o '^[^#]*' package_lists/python_packages.txt | tr '\n' ' ') + +RUN cargo install tex-fmt +ENV PATH="/home/ubuntu/.cargo/bin:${PATH}" + # Start zsh CMD [ "zsh" ] \ No newline at end of file diff --git a/install_scripts/install_r.sh b/install_scripts/install_r.sh index 6f018ed..c819d02 100644 --- a/install_scripts/install_r.sh +++ b/install_scripts/install_r.sh @@ -1,9 +1,14 @@ #!/bin/bash -echo "deb http://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" >> /etc/apt/sources.list -gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 -gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | apt-key add - -apt-get update +apt update -qq +# install two helper packages we need +apt install -y --no-install-recommends software-properties-common dirmngr +# add the signing key (by Michael Rutter) for these repos +# To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc +# Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9 +wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc +# add the R 4.X repo from CRAN +add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu noble-cran40/" apt-get update @@ -16,7 +21,6 @@ RUNDEPS="ca-certificates \ libxml2-dev \ vim-tiny \ wget \ - dirmngr \ libmagick++-dev \ libpoppler-cpp-dev \ libudunits2-dev \ @@ -28,7 +32,6 @@ RUNDEPS="ca-certificates \ libfribidi-dev \ curl \ libgit2-dev \ - pandoc-citeproc \ qpdf" # Install R amd dependencies @@ -58,9 +61,6 @@ echo 'options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRv # Install docopt which is used by littler to install packages Rscript -e "install.packages('docopt', repos= '$R_REPOS')" -# Install alternative r console -pip3 install -U --no-cache-dir radian - # R packages on RSPM install2.r --error --skipinstalled --ncpus 32 \ $(grep -o '^[^#]*' tmp/r_packages.txt | tr '\n' ' ') @@ -70,10 +70,13 @@ installGithub.r \ $(grep -o '^[^#]*' tmp/r_packages_github.txt | tr '\n' ' ') # Miniconda for Refinitiv and resp. python dependenies -R -e "Refinitiv::install_eikon()" - -chown --recursive $USERNAME:$USERNAME /usr/local/lib/R/site-library +# R -e "Refinitiv::install_eikon()" -apt-get autoclean -y -rm -rf /var/lib/apt/lists/* +chown --recursive $USERNAME:$USERNAME /home/$USERNAME/R/library +apt-get autoclean -y +apt-get clean +rm -rf /var/cache/* +rm -rf /tmp/* +rm -rf /var/tmp/* +rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/package_lists/python_packages.txt b/package_lists/python_packages.txt index 235bffe..5bdc970 100644 --- a/package_lists/python_packages.txt +++ b/package_lists/python_packages.txt @@ -31,6 +31,7 @@ Pyarrow pylint pyparsing==2.4.7 pytest +radian redis requests ruff diff --git a/package_lists/r_packages.txt b/package_lists/r_packages.txt index f517b6e..24aac25 100644 --- a/package_lists/r_packages.txt +++ b/package_lists/r_packages.txt @@ -30,6 +30,7 @@ fontawesome foreach forecast gamlss.dist +MixGHD gamlss.lasso GAS gdata @@ -51,6 +52,7 @@ gt Hmisc htmltools htmlwidgets +httpgd igraph inline inspectdf diff --git a/package_lists/r_packages_github.txt b/package_lists/r_packages_github.txt index 33428a7..a93dfa8 100644 --- a/package_lists/r_packages_github.txt +++ b/package_lists/r_packages_github.txt @@ -2,6 +2,5 @@ BerriJ/strsplit.fix GreenGrassBlueOcean/RefinitivR jhelvy/renderthis ManuelHentschel/vscDebugger@*release -nx10/httpgd sjp/grConvert stenevang/sftp