Skip to content

Commit

Permalink
Merge pull request #58 from BerriJ/noble
Browse files Browse the repository at this point in the history
Upgrade Ubuntu to 24.04. Noble
  • Loading branch information
BerriJ authored Oct 9, 2024
2 parents aaec00c + a77185d commit f41df94
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 47 deletions.
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
64 changes: 34 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -36,6 +38,7 @@ RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula sele
ccache \
gfortran \
netbase \
cargo \
zip \
unzip \
xclip \
Expand All @@ -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 &&\
Expand All @@ -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 \
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/.
Expand All @@ -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" ]
31 changes: 17 additions & 14 deletions install_scripts/install_r.sh
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -16,7 +21,6 @@ RUNDEPS="ca-certificates \
libxml2-dev \
vim-tiny \
wget \
dirmngr \
libmagick++-dev \
libpoppler-cpp-dev \
libudunits2-dev \
Expand All @@ -28,7 +32,6 @@ RUNDEPS="ca-certificates \
libfribidi-dev \
curl \
libgit2-dev \
pandoc-citeproc \
qpdf"

# Install R amd dependencies
Expand Down Expand Up @@ -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' ' ')
Expand All @@ -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/*
1 change: 1 addition & 0 deletions package_lists/python_packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Pyarrow
pylint
pyparsing==2.4.7
pytest
radian
redis
requests
ruff
Expand Down
2 changes: 2 additions & 0 deletions package_lists/r_packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fontawesome
foreach
forecast
gamlss.dist
MixGHD
gamlss.lasso
GAS
gdata
Expand All @@ -51,6 +52,7 @@ gt
Hmisc
htmltools
htmlwidgets
httpgd
igraph
inline
inspectdf
Expand Down
1 change: 0 additions & 1 deletion package_lists/r_packages_github.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ BerriJ/strsplit.fix
GreenGrassBlueOcean/RefinitivR
jhelvy/renderthis
ManuelHentschel/vscDebugger@*release
nx10/httpgd
sjp/grConvert
stenevang/sftp

0 comments on commit f41df94

Please sign in to comment.