diff --git a/Dockerfile b/Dockerfile index 6a98f8c..0261f58 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,11 @@ # rocker/tidyverse に日本語設定と頻用パッケージ、および TinyTeX, Radian を追加 -# CRAN snapshot: https://packagemanager.rstudio.com/cran/__linux__/focal/2021-10-29 +# 2022-06-02 の rocker/tidyverse:4.2.0 および RSPM を使用 -FROM rocker/tidyverse:4.1.1 +#FROM rocker/tidyverse:4.2.0 +FROM rocker/tidyverse@sha256:3ff87598467da673421880dc24ffc7270a9e10147620003a35db8193636066fe + +# RSPM を latest から 2022-06-02 に固定 +RUN sed -i.bak -e 's%focal/latest%focal/2022-06-02%' /usr/local/lib/R/etc/Rprofile.site # Ubuntuミラーサイトの設定(自動選択) RUN sed -i.bak -e 's%http://[^ ]\+%mirror://mirrors.ubuntu.com/mirrors.txt%g' /etc/apt/sources.list @@ -11,7 +15,6 @@ RUN set -x \ && apt-get update \ && apt-get install -y --no-install-recommends \ language-pack-ja-base \ - # fonts-ipaexfont \ libxt6 \ ssh \ && /usr/sbin/update-locale LANG=ja_JP.UTF-8 LANGUAGE="ja_JP:ja" \ @@ -25,9 +28,8 @@ RUN set -x \ COPY my_scripts /my_scripts RUN chmod 775 my_scripts/* RUN /my_scripts/install_r_packages.sh -RUN /my_scripts/install_pandas.sh +RUN /my_scripts/install_quarto.sh RUN /my_scripts/install_radian.sh -#RUN /my_scripts/install_notocjk.sh RUN /my_scripts/install_notojp.sh RUN /my_scripts/install_coding_fonts.sh diff --git a/README.md b/README.md index 43b3cb8..85f6940 100644 --- a/README.md +++ b/README.md @@ -16,44 +16,46 @@ - Ubuntu の `language-pack-ja`, `language-pack-ja-base` - 環境変数で `ja_JP.UTF-8` ロケールとタイムゾーン `Asia/Tokyo` を指定 -- グラフ、PDF出力用フォントとして Noto Sans/Serif JP ("CJK" なし)を追加 - - Ubuntu の `fonts-noto-cjk` パッケージのみでは XeLaTeX + BXjscls で日本語PDFを作成するのに不足するウェイトがある - - `fonts-noto-cjk-extra` は KR, SC, TC のフォントも含むので用途に対して大きすぎる(インストールサイズ 300MBほど) - - 現在、[Noto Home - Google Fonts](https://fonts.google.com/noto) で配布されているのは "CJK" なしの Noto Sans/Serif JP のみ - - Google Fonts からダウンロードして、XeLaTeX + BXjscls で "noto-jp" を指定する場合に必要な 7フォントを手動でインストールする - - 過去コードの文字化け回避のため、Noto Sans/Serif CJK JP を Noto Sans/Serif JP の別名として登録しておく -- RStudioのエディタで使用するコーディング用フォントとして以下を追加 - - [JetBrains Mono](https://www.jetbrains.com/ja-jp/lp/mono/) : リガチャで `->` や native pipe `|>` が特別な記号になる - - [PlemolJP](https://qiita.com/tawara_/items/0a7b8c50a48ea86b2d91) : IBM Plex Sans JP + IBM Plex Mono。3:5版ではなく1:2のConsole版を使用 - -### radian: A 21 century R console +- 以下の日本語フォントを導入 + - **Noto Sans/Serif JP**("CJK"なし) + - `fonts-noto-cjk-extra` は KR, SC, TC のフォントも含むので用途に対して大きすぎる(インストールサイズ 300MBほど) + - [Google Fonts](https://fonts.google.com/) からダウンロードして、XeLaTeX + BXjscls で "noto-jp" を指定する場合に必要な 7フォントを手動でインストール + - serif/sans の標準日本語フォントとして設定 + - 過去コードの文字化け回避のため、Noto Sans/Serif CJK JP を Noto Sans/Serif JP の別名として登録しておく + - **[UDEV Gothic](https://github.com/yuru7/udev-gothic)** + - BIZ UD Gothic + JetBrains Mono の合成フォント + - 半角:全角 3:5版ではなく、通常の1:2でリガチャ有効のバージョン(UDEVGothicLG-*.ttf)を使用 + - RStudio Serverのエディタ用カスタムフォントとして導入 + - **[原ノ味フォント](https://github.com/trueroad/HaranoAjiFonts)** + - TinyTeX (LuaLaTeX, XeLaTeX) で日本語PDFを作成するために `tinytex::tlmgr_install("haranoaji")` で導入 + - 予めインストールしておかないと、[Knit to PDF] 時の自動インストールで躓く -- https://github.com/randy3k/radian -- インストールには、Python 3用の pip が必要 -- コード補完のためには `jedi` が必要なのであわせてインストール(radian の新しい版では jedi のバージョン縛りはなくなったよう) +### R の頻用パッケージ + +- これまでインストールしていたものを整理して利用頻度が少ない大物を中心に削除 +- 容量節約のため、`--deps TRUE`指定(依存関係 Suggestsまで含める)は外し、インストール後にDLしたアーカイブは削除 -### Python +### Quarto +- https://quarto.org/ +- CRANレポジトリに合わせて、2022-06-02時点の最新版 Preview v0.9 Build 504 を使用 +- Rパッケージ `quarto` もインストール -- radian で使うために python をセットアップするので、R とも連携できるようにする -- そのままでは、Python共有ライブラリや Pandas がないので `reticulate` は動かない -- rocker project で用意されている `/rocker_scripts/install_python.sh` を利用する -- `Pandas` と `Seaborn` (`matplotlib`) をシステム側に入れておく +### Python3 & radian: A 21 century R console + +- https://github.com/randy3k/radian +- rocker project で用意されている `/rocker_scripts/install_python.sh` を利用して Python3 をインストール +- R から Python を使えるよう、`reticulate` に必要な Pandas などもインストール(`Seaborn` も含む) +- radian のコード補完のためには `jedi` が必要なのであわせてインストール ### TinyTeX -- 2021年3月末で TeX Live 2020 が更新終了(frozen)となったので、日本語 TeX 開発コミュニティ texjp.org のサーバにあるTeX Live 2020 のアーカイブを利用するようにする -- TinyTeX はそれに合わせて "2021.03" をインストールする -- TinyTeX のセットアップまで行い、日本語PDFを作成するのに必要なパッケージは必要時にインストールすることにした +- 2022年3月末で TeX Live 2021 が更新終了(frozen)となったので、日本語 TeX 開発コミュニティ texjp.org のサーバにあるTeX Live 2021 のアーカイブを利用する +- TinyTeX はそれに合わせて "2022.03" をインストール +- TinyTeX のセットアップまで行い、その他に必要なパッケージは自動インストールに任せる - 初回に日本語PDFを作成するときに自動でインストールされる(XeLaTeX + BXjscls の文書で約50個) + - LuaLaTeXの場合、原ノ味フォントはインストールしておかないと進まなくなるので `haranoaji` だけ手動で入れておく - `/my_scripts/install_tex_packages.sh` をユーザー rstudio 権限で実行してインストールすることも可能 -### R の頻用パッケージ - -- いつものものに、Causal Inference Slack で勧められたものをいくつか追加 -- https://docs.google.com/spreadsheets/d/175Q_lzNG7P6TT2k9rUzzweoaKdJS_OJZ3lWpUuTfcvc/edit#gid=0 -- Bioconductor のパッケージも RSPM から入手できるようになったが、出自が分かりにくくなるので本家からインストール -- 容量節約のため、インストール後にDLしたアーカイブは削除する - ### 環境変数 PASSWORD の仮設定 - Docker Desktop など `-e PASSWORD=...` が設定できないGUIでも起動テストできるように仮のパスワードを埋め込んでおく @@ -72,4 +74,4 @@ - **2021-08-30** :bookmark:[4.1.0_2021Aug](https://github.com/mokztk/RStudio_docker/releases/tag/4.1.0_2021Aug) : `rocker/tidyverse:4.1.0` にあわせて更新。coding font 追加 - **2021-09-22** :bookmark:[4.1.0_2021Aug_r2](https://github.com/mokztk/RStudio_docker/releases/tag/4.1.0_2021Aug_r2) : PlemolJP フォントを最新版に差し替え(記号のズレ対策) - **2021-11-11** :bookmark:[4.1.1_2021Oct](https://github.com/mokztk/RStudio_docker/releases/tag/4.1.1_2021Oct) : `rocker/tidyverse:4.1.1` にあわせて更新。フォント周りを中心に整理 - +- **2022-06-07** :bookmark:[4.2.0_2022Jun](https://github.com/mokztk/RStudio_docker/releases/tag/4.2.0_2022Jun) : ベースを `rocker/tidyverse:4.2.0` (2022-06-02版)に更新。Quartoの導入、フォントの変更など diff --git a/my_scripts/install_coding_fonts.sh b/my_scripts/install_coding_fonts.sh index c2beac2..d0008ed 100644 --- a/my_scripts/install_coding_fonts.sh +++ b/my_scripts/install_coding_fonts.sh @@ -1,27 +1,16 @@ # Install coding fonts (for RStudio Server) -## JetBrains Mono -mkdir -p /home/rstudio/.config/rstudio/fonts/JetBrainsMono/italic -wget -q https://download.jetbrains.com/fonts/JetBrainsMono-2.242.zip -unzip JetBrainsMono-2.242.zip -d JetBrainsMono -cp JetBrainsMono/fonts/variable/JetBrainsMono[wght].ttf /home/rstudio/.config/rstudio/fonts/JetBrainsMono/JetBrainsMono.ttf -cp JetBrainsMono/fonts/variable/JetBrainsMono-Italic[wght].ttf /home/rstudio/.config/rstudio/fonts/JetBrainsMono/italic/JetBrainsMono-Italic.ttf -mv /home/rstudio/.config/rstudio/fonts/JetBrainsMono/ /home/rstudio/.config/rstudio/fonts/JetBrains\ Mono/ -rm JetBrainsMono-2.242.zip -rm -rf JetBrainsMono - -## PlemolJP (IBM Plex Sans JP + IBM Plex Mono) -## https://qiita.com/tawara_/items/0a7b8c50a48ea86b2d91 -mkdir -p /home/rstudio/.config/rstudio/fonts/PlemolJP/400/italic -mkdir -p /home/rstudio/.config/rstudio/fonts/PlemolJP/700/italic -wget -q https://github.com/yuru7/PlemolJP/releases/download/v1.2.0/PlemolJP_v1.2.0.zip -unzip PlemolJP_v1.2.0.zip -cp PlemolJP_v1.2.0/PlemolJPConsole/PlemolJPConsole-Regular.ttf /home/rstudio/.config/rstudio/fonts/PlemolJP/400 -cp PlemolJP_v1.2.0/PlemolJPConsole/PlemolJPConsole-Italic.ttf /home/rstudio/.config/rstudio/fonts/PlemolJP/400/italic -cp PlemolJP_v1.2.0/PlemolJPConsole/PlemolJPConsole-Bold.ttf /home/rstudio/.config/rstudio/fonts/PlemolJP/700 -cp PlemolJP_v1.2.0/PlemolJPConsole/PlemolJPConsole-BoldItalic.ttf /home/rstudio/.config/rstudio/fonts/PlemolJP/700/italic -mv /home/rstudio/.config/rstudio/fonts/PlemolJP/ /home/rstudio/.config/rstudio/fonts/PlemolJP\ Console/ -rm PlemolJP_v1.2.0.zip -rm -rf PlemolJP_v1.2.0 +## UDEV Gothic LG (BIZ UD Gothic + JetBrains Mono) +## https://github.com/yuru7/udev-gothic +mkdir -p /home/rstudio/.config/rstudio/fonts/UDEVGothicLG/400/italic +mkdir -p /home/rstudio/.config/rstudio/fonts/UDEVGothicLG/700/italic +wget -q https://github.com/yuru7/udev-gothic/releases/download/v1.0.0/UDEVGothic_v1.0.0.zip +unzip UDEVGothic_v1.0.0.zip +cp UDEVGothic_v1.0.0/UDEVGothicLG-Regular.ttf /home/rstudio/.config/rstudio/fonts/UDEVGothicLG/400 +cp UDEVGothic_v1.0.0/UDEVGothicLG-Italic.ttf /home/rstudio/.config/rstudio/fonts/UDEVGothicLG/400/italic +cp UDEVGothic_v1.0.0/UDEVGothicLG-Bold.ttf /home/rstudio/.config/rstudio/fonts/UDEVGothicLG/700 +cp UDEVGothic_v1.0.0/UDEVGothicLG-BoldItalic.ttf /home/rstudio/.config/rstudio/fonts/UDEVGothicLG/700/italic +mv /home/rstudio/.config/rstudio/fonts/UDEVGothicLG/ /home/rstudio/.config/rstudio/fonts/UDEV\ Gothic\ LG/ +rm -rf UDEVGothic* chown -R rstudio:rstudio /home/rstudio/.config/rstudio diff --git a/my_scripts/install_pandas.sh b/my_scripts/install_pandas.sh index eaadba2..22b992d 100644 --- a/my_scripts/install_pandas.sh +++ b/my_scripts/install_pandas.sh @@ -12,4 +12,4 @@ apt-get clean rm -rf /var/lib/apt/lists/* # グローバルに pandas と matplotlib/seaborn を入れておく -pip install --no-cache-dir pandas seaborn +python3 -m pip --no-cache-dir install pandas seaborn diff --git a/my_scripts/install_quarto.sh b/my_scripts/install_quarto.sh new file mode 100644 index 0000000..ae7e7ac --- /dev/null +++ b/my_scripts/install_quarto.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -x + +# Quarto のインストール + +apt-get update + +QUARTO_DEB="quarto-0.9.504-linux-amd64.deb" +wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v0.9.504/${QUARTO_DEB} +gdebi -n $QUARTO_DEB +rm $QUARTO_DEB + +apt-get clean +rm -rf /var/lib/apt/lists/* + +install2.r --error --ncpus -1 --skipinstalled quarto diff --git a/my_scripts/install_r_packages.sh b/my_scripts/install_r_packages.sh index a694aa0..5296749 100644 --- a/my_scripts/install_r_packages.sh +++ b/my_scripts/install_r_packages.sh @@ -7,43 +7,22 @@ set -x # 依存ライブラリの追加 apt-get update apt-get install -y --no-install-recommends \ - default-jdk \ - default-libmysqlclient-dev \ - gdal-bin \ - gsfonts \ - imagemagick \ - imagemagick-6-common \ - libarchive13 \ - libcairo2 \ - libcurl4 \ - libfontconfig1 \ - libfreetype6 \ - libgdal26 \ - libgeos-c1v5 \ - libgit2-28 \ - libgl1-mesa-dri \ - libglpk40 \ - libglu1-mesa \ + gdebi-core \ + libcairo2-dev \ + libcurl4-openssl-dev \ + libfontconfig1-dev \ + libfreetype6-dev \ + libgl1-mesa-dev \ + libglpk-dev \ + libglu1-mesa-dev \ libgmp3-dev \ - libjpeg8 \ - libmagick++-6.q16-8 \ - libnode64 \ - libpng16-16 \ - libpq5 \ - libproj15 \ - librsvg2-2 \ - libsasl2-2 \ - libsqlite3-0 \ - libssh2-1 \ - libtbb2 \ - libtcl8.6 \ - libtk8.6 \ - libudunits2-0 \ - libxft2 \ - libxml2 \ - libxtst6 \ - libxslt1.1\ - unixodbc-dev + libjpeg-dev \ + libpng-dev \ + libssl-dev \ + libv8-dev \ + libxft-dev \ + libxml2-dev \ + zlib1g-dev apt-get clean rm -rf /var/lib/apt/lists/* @@ -54,11 +33,10 @@ R CMD javareconf # RSPMのcheckpointが変わった場合に対応するため、まずcheckpointの状態まで更新する Rscript -e "update.packages(ask = FALSE)" -# Bioconductor のパッケージ -Rscript -e "BiocManager::install(c('graph', 'Rgraphviz'))" - # CRANパッケージをRSPMからインストール -install2.r --error --deps TRUE --ncpus -1 --skipinstalled \ +# --deps TRUE をつけると依存関係 Suggests までインストールされ膨大になる +install2.r --error --ncpus -1 --skipinstalled \ + here \ pacman \ tidylog \ furrr \ @@ -69,8 +47,6 @@ install2.r --error --deps TRUE --ncpus -1 --skipinstalled \ clinfun \ car \ survminer \ - prophet \ - Deducer \ GGally \ ggfortify \ gghighlight \ @@ -86,10 +62,8 @@ install2.r --error --deps TRUE --ncpus -1 --skipinstalled \ minidown \ DiagrammeR \ palmerpenguins \ - styler - -# installGithub.r rstudio/webshot2 -Rscript -e "remotes::install_github('rstudio/webshot2')" + styler \ + svglite # R.cache (imported by styler) で使用するキャッシュディレクトリを準備 mkdir -p /home/rstudio/.cache/R/R.cache @@ -97,7 +71,7 @@ chown -R rstudio:rstudio /home/rstudio/.cache # since package "export" was removed from CRAN on 2020-02-21, # install dev version from GitHub repo (commit 1afc8e2 / 2021-03-09) -install2.r --error --deps TRUE --ncpus -1 --skipinstalled \ +install2.r --error --ncpus -1 --skipinstalled \ officer \ rvg \ openxlsx \ diff --git a/my_scripts/install_radian.sh b/my_scripts/install_radian.sh index 26acb6a..7c0aba0 100644 --- a/my_scripts/install_radian.sh +++ b/my_scripts/install_radian.sh @@ -10,7 +10,7 @@ if [ ! -e "/usr/bin/pip3" ]; then fi # radianのインストール -pip install --no-cache-dir radian jedi +python3 -m pip --no-cache-dir install radian jedi # radianの設定 cat > /home/rstudio/.radian_profile << EOF diff --git a/my_scripts/install_tinytex.sh b/my_scripts/install_tinytex.sh index c8f8ba9..da753c3 100644 --- a/my_scripts/install_tinytex.sh +++ b/my_scripts/install_tinytex.sh @@ -1,9 +1,12 @@ #!/bin/bash # TinyTex本体のインストール -# 当面、FREEZEとなった TeXLive 2020 アーカイブを利用する +# 当面、FREEZEとなった TeXLive 2021 アーカイブを利用する -Rscript -e 'tinytex::install_tinytex(dir = "/home/rstudio/.TinyTeX/", version = "2021.03", repository = "https://texlive.texjp.org/2020/tlnet")' +Rscript -e 'tinytex::install_tinytex(dir = "/home/rstudio/.TinyTeX/", version = "2022.03", repository = "https://texlive.texjp.org/2021/tlnet")' + +# 原ノ味フォントをインストールしておく(その他は、必要時に tlmgr で自動的にインストールされる) +Rscript -e 'tinytex::tlmgr_install("haranoaji")' # 一部の package 用にLaTeXコンパイラの場所を指定 echo "R_LATEXCMD=/home/rstudio/.TinyTeX/bin/x86_64-linux/platex" >> /home/rstudio/.Renviron