-
Notifications
You must be signed in to change notification settings - Fork 0
/
explore.Dockerfile
514 lines (439 loc) · 16.3 KB
/
explore.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
ARG UBUNTU_VERSION=22.04
ARG DEBIAN_FRONTEND="noninteractive"
# ********************************************************************************
#
# satge 0
# ********************************************************************************
FROM ubuntu:${UBUNTU_VERSION} AS builder0
ARG DEBIAN_FRONTEND
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
autoconf \
texinfo \
binutils \
flex \
bison \
libmpc-dev \
libmpfr-dev \
libgmp-dev \
coreutils \
make \
libtinfo5 \
texinfo \
libxpm-dev \
libgtk-3-dev \
libgnutls28-dev \
libncurses5-dev \
libxml2-dev \
libxt-dev \
libjansson4 \
gcc-multilib \
libcanberra-gtk3-module \
libjansson-dev \
librsvg2-dev \
libsqlite3-dev \
libgccjit-11-dev \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN git config --global http.sslVerify false
# ============================================================
# https://www.masteringemacs.org/article/speed-up-emacs-libjansson-native-elisp-compilation
# https://gitlab.com/koral/emacs-nativecomp-dockerfile/-/blob/master/Dockerfile
RUN apt-get update \
&& apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common \
# other package needed
wget \
unzip
# install tree-sitter
# https://www.reddit.com/r/emacs/comments/z25iyx/comment/ixll68j/?utm_source=share&utm_medium=web2x&context=3
ENV CC="gcc-11" CFLAGS="-O3 -Wall -Wextra"
RUN git clone --depth 1 https://github.com/tree-sitter/tree-sitter.git /opt/tree-sitter && \
cd /opt/tree-sitter && \
# NOTE: update version in Makefile to 0.20.7
sed -i 's/^VERSION := 0\.6\.3$/VERSION := 0.20.7/' Makefile && \
make -j4 && \
make install
RUN ldconfig
ENV CFLAGS="-O2"
RUN git clone --depth 1 --branch emacs-29 https://github.com/emacs-mirror/emacs /opt/emacs && \
cd /opt/emacs && \
./autogen.sh && \
./configure --build="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
--with-modules \
--with-native-compilation \
--with-tree-sitter \
--with-json \
--with-sqlite3 \
--with-gif=ifavailable \
--prefix=/usr/local && \
make NATIVE_FULL_AOT=1 -j30 && \
make install-strip
# ============================================================
# tree-sitter-language
# https://github.com/orzechowskid/emacs-docker/blob/main/src/build-ts-modules.sh
# https://github.com/emacs-mirror/emacs/tree/master/admin/notes/tree-sitter
# https://emacs-china.org/t/treesit-master/22862/69
RUN apt-get update && \
apt-get install -y g++ && \
git clone https://github.com/casouri/tree-sitter-module /opt/tree-sitter-module && \
cd /opt/tree-sitter-module && \
./batch.sh && \
mv ./dist/* /usr/local/lib/ && \
cd /opt/
# ============================================================
# https://github.com/nodejs/docker-node
ENV NODE_VERSION 18.15.0
RUN curl -fsSLOk --compressed "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" \
&& tar -xJf "node-v${NODE_VERSION}-linux-x64.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm /usr/local/*.md /usr/local/LICENSE \
&& rm "node-v${NODE_VERSION}-linux-x64.tar.xz" \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
# smoke tests
&& node --version \
&& npm --version \
# install some LSP servers
# && npm config set registry https://registry.npm.taobao.org \
&& npm i --location=global typescript typescript-language-server \
&& npm i --location=global bash-language-server \
&& npm i --location=global pyright \
&& npm i --location=global dockerfile-language-server-nodejs \
&& npm i --location=global vscode-langservers-extracted \
&& npm i --location=global yaml-language-server \
&& npm i --location=global markdownlint-cli
# ============================================================
# https://hub.docker.com/r/rikorose/gcc-cmake/dockerfile
ENV CMAKE_VERSION 3.25.3
RUN wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-x86_64.sh \
--no-check-certificate \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& /tmp/cmake-install.sh --skip-license --prefix=/usr/local \
&& rm /tmp/cmake-install.sh
# ============================================================
# ninja
ENV NINJA_VERSION 1.11.1
RUN wget https://github.com/ninja-build/ninja/releases/download/v$NINJA_VERSION/ninja-linux.zip \
--no-check-certificate \
&& unzip ninja-linux.zip \
&& cp ninja /usr/local/bin
# ============================================================
# https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
# install latest protobuf
ARG PROTOBUF_VERSION=3.20.2
RUN apt-get install -y autoconf automake libtool curl make g++ unzip && \
git clone --depth 1 --recursive --branch v${PROTOBUF_VERSION} https://github.com/protocolbuffers/protobuf.git && \
cd protobuf && \
./autogen.sh && \
./configure && \
make -j10 && \
make install && \
ldconfig
# ============================================================
# Build EAR (BEAR)
ENV BEAR_VERSION 3.1.1
RUN apt-get install -y libssl-dev && \
ldconfig
RUN git clone --depth 1 --branch $BEAR_VERSION https://github.com/rizsotto/Bear.git /opt/bear && \
cd /opt/bear && \
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local \
-DPYTHON_EXECUTABLE=/usr/bin/python3 \
-DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF && \
make all -j4 && \
make install
# ============================================================
# Build Aspell
# https://github.com/Starefossen/docker-aspell
ENV ASPELL_SERVER https://ftp.gnu.org/gnu/aspell
ENV ASPELL_VERSION 0.60.8
ENV ASPELL_EN 2020.12.07-0
RUN apt-get install -y bzip2 && \
ldconfig
RUN wget "${ASPELL_SERVER}/aspell-${ASPELL_VERSION}.tar.gz" \
&& wget "${ASPELL_SERVER}/dict/en/aspell6-en-${ASPELL_EN}.tar.bz2" \
&& tar -xzf "aspell-${ASPELL_VERSION}.tar.gz" \
&& tar -xjf "aspell6-en-${ASPELL_EN}.tar.bz2" \
# build
&& cd "/aspell-${ASPELL_VERSION}" \
&& ./configure \
&& make -j4 \
&& make install \
&& ldconfig \
# copy
&& cd "/aspell6-en-${ASPELL_EN}" \
&& ./configure \
&& make -j4 \
&& make install \
# cleanup
&& rm -rf /aspell* /var/lib/apt/lists/*
# ============================================================
# https://hub.docker.com/r/peccu/rg/dockerfile
# build ripgrep
ENV RG_VERSION=13.0.0
RUN set -x \
&& wget https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-x86_64-unknown-linux-musl.tar.gz \
--no-check-certificate \
&& tar xzf ripgrep-${RG_VERSION}-x86_64-unknown-linux-musl.tar.gz \
&& mv ripgrep-${RG_VERSION}-x86_64-unknown-linux-musl/rg /usr/local/bin/
# ============================================================
# build fd-find
ENV FD_VERSION=8.7.0
RUN set -x \
&& wget https://github.com/sharkdp/fd/releases/download/v${FD_VERSION}/fd-v${FD_VERSION}-x86_64-unknown-linux-gnu.tar.gz \
--no-check-certificate \
&& tar xzf fd-v${FD_VERSION}-x86_64-unknown-linux-gnu.tar.gz \
&& mv fd-v${FD_VERSION}-x86_64-unknown-linux-gnu/fd /usr/local/bin/
# ============================================================
# https://github.com/Valian/docker-git-lfs
# build git-lfs
ENV GITLFS_VERSION=3.0.2
RUN wget https://github.com/git-lfs/git-lfs/releases/download/v$GITLFS_VERSION/git-lfs-linux-amd64-v$GITLFS_VERSION.tar.gz \
-c --retry-connrefused --tries=0 --timeout=180 --no-check-certificate \
&& tar -zxf git-lfs-linux-amd64-v$GITLFS_VERSION.tar.gz \
&& mv git-lfs /usr/local/bin/ \
&& rm -rf git-lfs-* \
&& rm -rf install.sh
# ============================================================
# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/dockerfiles/partials/ubuntu/bazelbuild.partial.Dockerfile
# Install bazel
ARG BAZEL_VERSION=5.3.0
RUN mkdir /bazel && \
wget --no-check-certificate \
-O /bazel/installer.sh "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh" && \
chmod +x /bazel/installer.sh && \
/bazel/installer.sh && \
rm -f /bazel/installer.sh
# ============================================================
# https://github.com/vincent-picaud/Bazel_and_CompileCommands
# install Bazel_and_CompileCommands :) // really great and helpful
RUN cd "${INSTALL_DIR}" \
&& curl -SLOk "https://github.com/vincent-picaud/Bazel_and_CompileCommands/archive/master.zip" \
&& unzip master.zip && rm master.zip \
&& ln -f -s "${INSTALL_DIR}/Bazel_and_CompileCommands-master/create_compile_commands.sh" /usr/local/bin/bazel-create-cc \
&& ln -f -s "${INSTALL_DIR}/Bazel_and_CompileCommands-master/setup_compile_commands.sh" /usr/local/bin/bazel-setup-cc
COPY scripts/legalize_compile_commands.sh /usr/local/lib/Bazel_and_CompileCommands-master/
RUN ln -f -s "${INSTALL_DIR}/Bazel_and_CompileCommands-master/legalize_compile_commands.sh" /usr/local/bin/bazel-legalize-cc
# ============================================================
# other scripts
RUN mkdir /usr/local/share/bash-color
COPY scripts/terminfo-24bit.src /usr/local/share/bash-color/
# ============================================================
# download latest clangd
# use lastversion
RUN apt-get update && \
apt-get install -y \
python3-pip && \
pip3 install -U setuptools pip && \
pip3 install lastversion && \
lastversion --assets --filter clangd-linux download https://github.com/clangd/clangd/releases && \
unzip clangd-linux*.zip && \
cp -r ./clangd*/* /usr/local
# ============================================================
# download latest shfmt
RUN lastversion --assets --filter _linux_amd64 download https://github.com/mvdan/sh/releases && \
mv shfmt*linux_amd64 shfmt && \
chmod +x ./shfmt && \
cp ./shfmt /usr/local/bin/
# ============================================================
# download flatbuffer-compiler
RUN lastversion --assets --filter Linux.flatc.binary.g download https://github.com/google/flatbuffers/releases && \
unzip Linux.flatc.binary*.zip && \
chmod +x ./flatc && \
cp ./flatc /usr/local/bin/
# ===========================================================
# install ccache
RUN git clone https://github.com/ccache/ccache --branch=1 --branch v4.6 && \
cd ccache && \
mkdir build && \
cd build && \
cmake -DZSTD_FROM_INTERNET=ON \
-DHIREDIS_FROM_INTERNET=ON \
-DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release .. && \
make && make install
# ===========================================================
# install fuz (fuzzy match scoring/matching functions for Emacs)
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
apt-get update && apt-get install -y clang llvm && \
git clone https://github.com/rustify-emacs/fuz.el fuz
ENV PATH="/root/.cargo/bin:${PATH}"
RUN cd fuz && \
cargo build --release && \
cp target/release/libfuz_core.so /usr/local/lib/
# ==========================================================
# install rust-analyzer
RUN curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > /usr/local/bin/rust-analyzer \
&& chmod +x /usr/local/bin/rust-analyzer
# ==========================================================
# install groovy-lsp
RUN apt-get update && \
apt-get install -y default-jre && \
git clone https://github.com/GroovyLanguageServer/groovy-language-server && \
cd groovy-language-server && \
./gradlew build && \
cp build/libs/* /usr/local/lib/
# ==========================================================
# install mosh
RUN apt-get update && \
apt-get install -y \
pkg-config libutempter-dev zlib1g-dev libncurses5-dev \
libssl-dev bash-completion tmux less && \
git clone --branch=mosh-1.4.0 https://github.com/mobile-shell/mosh && \
cd mosh && \
./autogen.sh && \
./configure && \
make && make install
# ********************************************************************************
#
# stage 1
# ********************************************************************************
FROM ubuntu:${UBUNTU_VERSION} AS base
ARG DEBIAN_FRONTEND
# ================================================================================
# dependency of Emacs
RUN apt-get update && rm /usr/local/man && \
apt-get install -y --no-install-recommends \
libmpc3 \
libmpfr6 \
libgmp10 \
coreutils \
libjpeg-turbo8 \
libtiff5 \
libgif7 \
libxpm4 \
libgtk-3-0 \
libgnutlsxx28 \
libncurses5 \
libxml2 \
libxt6 \
libjansson4 \
libcanberra-gtk3-module \
libx11-xcb1 \
binutils \
libc6-dev \
librsvg2-2 \
libgccjit-11-dev \
# for vterm
libtool \
libtool-bin \
# for monkeytype
fortune \
fortunes \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# See http://bugs.python.org/issue19846
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
RUN apt-get update && \
apt-get install -y \
python3 \
python3-pip \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN python3 -m pip --no-cache-dir install --upgrade \
pip \
setuptools
# Some TF tools expect a "python" binary
RUN ln -s $(which python3) /usr/local/bin/python
# ================================================================================
# some others
RUN apt-get update && \
apt-get install -y \
build-essential \
git \
valgrind \
python3-dev \
python3-venv \
virtualenv \
swig \
openssh-client \
gdb g++ \
# g++12 header for clangd
libstdc++-12-dev \
# onnx-mlir
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
libffi-dev \
liblzma-dev \
# tectonic
libfreetype6-dev \
libssl-dev \
libfontconfig1-dev \
# dev needed
parallel \
rsync \
graphviz \
# for groovy
default-jre \
# for mosh-server
libutempter-dev \
# ping network
iputils-ping \
# smb
smbclient \
# SQL
sqlite3 postgresql-client \
# tools
wget curl \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# DOCKER CLI
RUN apt-get update && apt-get install -y \
ca-certificates gnupg && \
install -m 0755 -d /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
chmod a+r /etc/apt/keyrings/docker.gpg && \
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && apt-get install -y \
docker-ce-cli \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# ================================================================================
# tailscale
RUN curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/bionic.gpg | apt-key add - && \
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/bionic.list | tee /etc/apt/sources.list.d/tailscale.list && \
apt-get update && \
# mosh-server config locales
apt-get install -y tailscale openssh-server locales && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
# setup SSH server
sed -i /etc/ssh/sshd_config \
-e 's/#PermitRootLogin.*/PermitRootLogin no/' \
-e 's/#RSAAuthentication.*/RSAAuthentication yes/' \
-e 's/#PasswordAuthentication.*/PasswordAuthentication no/' \
-e 's/#SyslogFacility.*/SyslogFacility AUTH/' \
-e 's/#LogLevel.*/LogLevel INFO/' && \
mkdir /var/run/sshd
# ================================================================================
COPY --from=builder0 /usr/local /usr/local
# emacs bug
RUN find /usr/local/lib/emacs/ -name native-lisp | xargs -I{} ln -s {} /usr/
ENV SHELL "/bin/bash"
# https://askubuntu.com/a/1060694
RUN ldconfig && \
locale-gen "en_US.UTF-8" && \
update-locale LC_ALL="en_US.UTF-8"
# start SSH server
COPY scripts/start.sh /usr/bin/start.sh
RUN chmod +x /usr/bin/start.sh
CMD "start.sh"
WORKDIR /workspace