-
Notifications
You must be signed in to change notification settings - Fork 104
/
Dockerfile
176 lines (145 loc) · 4.9 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
FROM ubuntu:17.04
MAINTAINER William Stein <[email protected]>
USER root
# See https://github.com/sagemathinc/cocalc/issues/921
ENV LC_ALL C.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV TERM screen
# So we can source (see http://goo.gl/oBPi5G)
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Ubuntu software that are used by CoCalc (latex, pandoc, sage, jupyter)
RUN \
apt-get update \
&& apt-get install -y \
software-properties-common \
texlive \
texlive-latex-extra \
texlive-xetex \
tmux \
flex \
bison \
libreadline-dev \
htop \
screen \
pandoc \
aspell \
poppler-utils \
net-tools \
wget \
git \
python \
python-pip \
make \
g++ \
sudo \
psmisc \
haproxy \
nginx \
vim \
bup \
inetutils-ping \
lynx \
telnet \
git \
emacs \
subversion \
ssh \
m4 \
latexmk \
libpq5 \
libpq-dev \
build-essential \
gfortran \
automake \
dpkg-dev \
libssl-dev \
imagemagick \
libcairo2-dev \
libcurl4-openssl-dev \
graphviz \
smem \
python3-yaml \
locales \
locales-all
# Jupyter from pip (since apt-get jupyter is ancient)
RUN \
pip install "ipython<6" jupyter
# Install Node.js
RUN \
wget -qO- https://deb.nodesource.com/setup_6.x | bash - && \
apt-get install -y nodejs
# Build and install Sage -- see https://github.com/sagemath/docker-images
COPY scripts/ /tmp/scripts
RUN chmod -R +x /tmp/scripts
RUN adduser --quiet --shell /bin/bash --gecos "Sage user,101,," --disabled-password sage \
&& chown -R sage:sage /home/sage/
# make source checkout target, then run the install script
# see https://github.com/docker/docker/issues/9547 for the sync
RUN mkdir -p /usr/local/ \
&& /tmp/scripts/install_sage.sh /usr/local/ master \
&& sync
RUN /tmp/scripts/post_install_sage.sh && rm -rf /tmp/* && sync
# Build and install PostgreSQL
RUN \
cd /tmp \
&& wget https://ftp.postgresql.org/pub/source/v9.6.1/postgresql-9.6.1.tar.bz2 \
&& tar xf postgresql-9.6.1.tar.bz2 \
&& cd postgresql-9.6.1 \
&& ./configure --with-openssl --prefix=/usr/ \
&& make -j16 install \
&& cd /tmp \
&& rm -rf /tmp/postgresql-9.6.1 /tmp/postgresql-9.6.1.tar.bz2
# Which commit to checkout and build.
ARG commit=HEAD
# Pull latest source code for SMC and checkout requested commit (or HEAD)
RUN \
git clone https://github.com/sagemathinc/cocalc.git && \
cd /cocalc && git pull && git fetch origin && git checkout ${commit:-HEAD}
# Build and install all deps
RUN \
cd /cocalc/src \
&& . ./smc-env \
&& ./install.py all --compute --web \
&& rm -rf /root/.npm /root/.node-gyp/
# Install code into Sage
RUN cd /cocalc/src && sage -pip install --upgrade smc_sagews/
# Install sage scripts system-wide
RUN echo "install_scripts('/usr/local/bin/')" | sage
# Install SageTex
RUN \
sudo -H -E -u sage sage -p sagetex \
&& cp -rv /usr/local/sage/local/share/texmf/tex/latex/sagetex/ /usr/share/texmf/tex/latex/ \
&& texhash
RUN echo "umask 077" >> /etc/bash.bashrc
# Install R Jupyter Kernel package into R itself (so R kernel works)
RUN echo "install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'httr', 'devtools', 'uuid', 'digest'), repos='http://cran.us.r-project.org'); devtools::install_github('IRkernel/IRkernel')" | sage -R --no-save
# Install Jupyter kernels definitions
COPY kernels /usr/local/share/jupyter/kernels
# Configure so that R kernel actually works -- see https://github.com/IRkernel/IRkernel/issues/388
COPY kernels/ir/Rprofile.site /usr/local/sage/local/lib/R/etc/Rprofile.site
# Build a UTF-8 locale, so that tmux works -- see https://unix.stackexchange.com/questions/277909/updated-my-arch-linux-server-and-now-i-get-tmux-need-utf-8-locale-lc-ctype-bu
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
# Install Julia
RUN cd /tmp \
&& wget https://julialang-s3.julialang.org/bin/linux/x64/0.6/julia-0.6.0-linux-x86_64.tar.gz \
&& echo 3a27ea78b06f46701dc4274820d9853789db205bce56afdc7147f7bd6fa83e41 julia-0.6.0-linux-x86_64.tar.gz | sha256sum -c \
&& tar xf julia-0.6.0-linux-x86_64.tar.gz -C /opt \
&& rm -f julia-0.6.0-linux-x86_64.tar.gz \
&& ln -s /opt/julia-903644385b/bin/julia /usr/local/bin
# Install IJulia kernel
RUN echo '\
ENV["JUPYTER"] = "/usr/local/bin/jupyter"; \
ENV["JULIA_PKGDIR"] = "/opt/julia-903644385b/share/julia/site"; \
Pkg.init(); \
Pkg.add("IJulia");' | julia \
&& mv -i "$HOME/.local/share/jupyter/kernels/julia-0.6" "/usr/local/share/jupyter/kernels/"
### Configuration
COPY login.defs /etc/login.defs
COPY login /etc/defaults/login
COPY nginx.conf /etc/nginx/sites-available/default
COPY haproxy.conf /etc/haproxy/haproxy.cfg
COPY run.py /root/run.py
COPY bashrc /root/.bashrc
CMD /root/run.py
EXPOSE 80 443