DockerでRstanが使えるJupyterLabのサーバーを建てる

Rstanの環境構築でコケるので。

Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
FROM jupyter/datascience-notebook

RUN pip install jupyterlab
RUN jupyter serverextension enable --py jupyterlab
RUN jupyter labextension install @jupyterlab/git
RUN pip install jupyterlab-git
RUN jupyter serverextension enable --py jupyterlab_git

FROM rocker/tidyverse

# Change environment to Japanese(Character and DateTime)
ENV LANG ja_JP.UTF-8
ENV LC_ALL ja_JP.UTF-8
RUN sed -i '$d' /etc/locale.gen \
&& echo "ja_JP.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen ja_JP.UTF-8 \
&& /usr/sbin/update-locale LANG=ja_JP.UTF-8 LANGUAGE="ja_JP:ja"
RUN /bin/bash -c "source /etc/default/locale"
RUN ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

# Install Japanese fonts
RUN apt-get update && apt-get install -y \
fonts-ipaexfont

# Install packages
RUN Rscript -e "install.packages(c('githubinstall','rstan','ggmcmc','bayesplot','brms'))"

RUN jupyter lab --no-browser --port=8888

References