Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
492 lines (455 loc) · 20.7 KB
/
Copy pathDockerfile
File metadata and controls
492 lines (455 loc) · 20.7 KB
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
FROM ubuntu:26.04
# pip may install into the system Python (PEP 668), this image has no other use for it
ENV DEBIAN_FRONTEND=noninteractive PIP_BREAK_SYSTEM_PACKAGES=1
# Python 2.7 and GNU Smalltalk are no longer part of Ubuntu 26.04. They come from
# the archives of 22.04 and 24.04; the low pin priority keeps all other packages on 26.04.
RUN printf 'Types: deb\nURIs: http://archive.ubuntu.com/ubuntu\nSuites: noble noble-updates jammy jammy-updates\nComponents: main universe\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n\nTypes: deb\nURIs: http://security.ubuntu.com/ubuntu\nSuites: noble-security jammy-security\nComponents: main universe\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' \
> /etc/apt/sources.list.d/older.sources && \
printf 'Package: *\nPin: release n=noble*\nPin-Priority: 100\n\nPackage: *\nPin: release n=jammy*\nPin-Priority: 90\n' \
> /etc/apt/preferences.d/older && \
apt-get update && \
apt-get install -y --no-install-recommends \
firejail \
apt-utils \
curl \
git \
make \
cmake \
software-properties-common \
tar \
xz-utils \
python3-dev \
pkg-config \
build-essential \
# Python 2 (from 22.04)
python2.7 \
# Python3
python3 \
python3-pip \
ninja-build \
ffmpeg \
libcairo2-dev \
libpango1.0-dev \
# MONO
mono-devel \
# Java (OpenJDK 25)
default-jdk-headless \
# GO
golang-go \
# RUST
rustc \
# Haskell
ghc \
# .NET 10
dotnet10 apt-transport-https \
# Perl
perl \
# Ruby
ruby-full \
# Assembly
nasm \
# ADA
gnat \
# Elixir
erlang-dev elixir \
# Latex
# texlive-latex-base alone is not enough for Manim's Tex/MathTex:
# - texlive-latex-extra provides standalone.cls + preview.sty
# (Manim's default \documentclass[preview]{standalone})
# - dvisvgm converts the compiled DVI/PDF to SVG (Manim calls it last)
# - fonts-recommended / science avoid follow-up font & amsmath errors
texlive-latex-base \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-science \
dvisvgm \
# COBOL
gnucobol \
# Fortran
gfortran \
# Algol
algol68g \
# Prolog
swi-prolog \
# Forth
gforth \
# Pascal
# without fpc-source, fp-docs, fp-ide, fp-utils (~300 MB), all units stay
fp-compiler fp-units-rtl fp-units-base fp-units-db fp-units-fcl fp-units-fv \
fp-units-gfx fp-units-gtk2 fp-units-math fp-units-misc fp-units-multimedia fp-units-net \
# OCaml
ocaml \
# Scheme
guile-3.0 \
# Smalltalk (from 24.04)
gnu-smalltalk \
# Groovy
groovy \
# Scala
scala \
# Racket
racket \
# Tcl
tcl \
# PostScript
ghostscript \
# Lua
lua5.4 \
# D
gdc \
# Verilog
iverilog \
# VHDL
ghdl \
# Octave
octave \
# COQ
coq \
# VALA
valac \
# Standard ML
smlnj \
# PHP
php \
# NodeJS
nodejs \
npm \
# AWK
gawk \
# REXX
regina-rexx \
# Haxe
haxe \
# Modula-2
gm2 \
libgm2-15-dev \
# Objective-C
gobjc \
# Objective-C++
gobjc++ \
# Basic
bwbasic \
# Inform
inform6-compiler \
inform6-library \
frotz \
ncurses-bin \
musl \
# R
r-base \
r-cran-car \
r-cran-mapdata \
r-cran-reshape && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
##################################################################################
### Julia
# Plain release tarball in /opt: launchers like juliaup look in $HOME, which is not /root
# on Heroku (non-root user).
ARG JULIA_VERSION=1.13.4
RUN curl -fsSL "https://julialang-s3.julialang.org/bin/linux/x64/${JULIA_VERSION%.*}/julia-${JULIA_VERSION}-linux-x86_64.tar.gz" \
| tar -xz -C /opt \
&& mv /opt/julia-${JULIA_VERSION} /opt/julia \
&& chmod -R a+rX /opt/julia \
&& ln -s /opt/julia/bin/julia /usr/local/bin/julia
### Zig
RUN curl -fLO https://ziglang.org/download/0.14.0/zig-linux-x86_64-0.14.0.tar.xz \
&& tar -xf zig-linux-x86_64-0.14.0.tar.xz \
&& rm zig-linux-x86_64-0.14.0.tar.xz \
&& mv zig-linux-x86_64-0.14.0/ /opt/ \
&& ln -s /opt/zig-linux-x86_64-0.14.0/zig /usr/local/bin/zig
### Nim (release tarball in /opt, same reason as Julia)
ARG NIM_VERSION=2.4.2
RUN curl -fsSL "https://nim-lang.org/download/nim-${NIM_VERSION}-linux_x64.tar.xz" | tar -xJ -C /opt \
&& mv /opt/nim-${NIM_VERSION} /opt/nim \
&& rm -rf /opt/nim/doc /opt/nim/tests \
&& chmod -R a+rX /opt/nim \
&& ln -s /opt/nim/bin/nim /usr/local/bin/nim
## V-lang
ARG V_COMMIT=90a23fabda5cd0d1942029579bce1f5e6e0ede34
RUN git init v && \
cd v && \
git fetch --depth 1 https://github.com/vlang/v ${V_COMMIT} && \
git checkout FETCH_HEAD && \
make && \
./v symlink && \
rm -rf .git vc
### Python3
# pip cannot replace Python packages that apt installed, so it installs its own copy next to them
ENV PIP_IGNORE_INSTALLED=1
# Install the latest version of meson
RUN pip3 install --no-cache-dir --upgrade meson \
&& pip3 install --no-cache-dir \
matplotlib \
numpy \
opencv-contrib-python \
pyarrow \
pandas \
scipy \
sympy \
pyyaml \
pycairo \
manim \
mistralai \
# Q#, run by tools/qsharp
qdk
### Clojure
# Config and Maven repository outside of $HOME, otherwise every run downloads the jars again.
ARG CLOJURE_VERSION=1.12.7.1681
ENV CLJ_CONFIG=/opt/clojure
RUN mkdir -p /opt/clojure \
&& echo '{:mvn/local-repo "/opt/m2"}' > /opt/clojure/deps.edn \
&& curl -fL -O https://github.com/clojure/brew-install/releases/download/${CLOJURE_VERSION}/linux-install.sh \
&& chmod +x linux-install.sh \
&& ./linux-install.sh \
&& rm linux-install.sh \
&& clojure -e "(println \"First run clojure to install libs...\")" \
&& chmod -R a+rwX /opt/clojure /opt/m2
### APL
RUN curl -fL -o dyalog.deb "https://www.dyalog.com/uploads/php/download.dyalog.com/download.php?file=19.0/linux_64_19.0.50027_unicode.x86_64.deb" \
&& dpkg -i dyalog.deb \
&& rm dyalog.deb \
&& cd /opt/mdyalog/19.0/64/unicode \
&& rm -rf libcef.so libGLESv2.so libEGL.so libvk_swiftshader.so help locales RIDEapp
### IO
# Install dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libffi-dev \
libxml2-dev \
libssl-dev \
zlib1g-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Clone the Io language repository with submodules (native branch for CMake build)
RUN git clone --recurse-submodules --branch native https://github.com/IoLanguage/io.git && \
cd io && \
mkdir build && \
cd build && \
# GCC 15 defaults to C23 and rejects the loose pointer types of this code base
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-std=gnu17 -fpermissive" && \
make -j"$(nproc)" && \
make install && \
cd ../.. && \
rm -rf io
# Solidity
RUN npm install --global solc && \
npm cache clean --force
# Q# (Quantum)
#RUN dotnet tool install -g Microsoft.Quantum.IQSharp
# SelectScript
RUN curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein \
-o /usr/local/bin/lein \
&& chmod +x /usr/local/bin/lein \
&& git clone --recursive https://github.com/andre-dietrich/SelectScriptC.git \
&& cd SelectScriptC \
&& make \
&& make install \
&& cd / \
&& rm -rf SelectScriptC
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libobjc-15-dev \
gnustep \
gnustep-devel \
libgnustep-base-dev \
libblocksruntime-dev \
clang && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
### Kotlin (modern release, compatible with JDK 25)
ARG KOTLIN_VERSION=2.4.21
RUN curl -fL "https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/kotlin-compiler-${KOTLIN_VERSION}.zip" \
-o /tmp/kotlin.zip \
&& python3 -c "import zipfile; zipfile.ZipFile('/tmp/kotlin.zip').extractall('/opt/')" \
&& rm /tmp/kotlin.zip \
&& chmod +x /opt/kotlinc/bin/* \
&& ln -sf /opt/kotlinc/bin/kotlinc /usr/local/bin/kotlinc \
&& ln -sf /opt/kotlinc/bin/kotlin /usr/local/bin/kotlin
### .NET (C#, F#)
# NuGet packages outside of $HOME and restored once, so a build needs no network.
# NuGetAudit (an MSBuild property set from the environment) is off, otherwise every
# restore fetches the vulnerability database from nuget.org.
# The projects match the @LIA.dotnet and @LIA.fsharp templates in README.md (net10.0).
# Older courses still send net8.0 projects: their targeting pack is restored as well, and
# DOTNET_ROLL_FORWARD lets them run on the installed .NET 10 runtime.
ENV NUGET_PACKAGES=/opt/nuget NuGetAudit=false DOTNET_CLI_TELEMETRY_OPTOUT=1 DOTNET_NOLOGO=1 \
DOTNET_ROLL_FORWARD=LatestMajor
RUN for framework in net10.0 net8.0; do \
mkdir -p /tmp/cs /tmp/fs \
&& cd /tmp/cs \
&& printf 'Console.WriteLine("warm-up");\n' > Program.cs \
&& printf '<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>%s</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup></Project>\n' "$framework" > project.csproj \
&& dotnet build -nologo \
&& cd /tmp/fs \
&& printf 'printfn "warm-up"\n' > Program.fs \
&& printf '<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>%s</TargetFramework></PropertyGroup><ItemGroup><Compile Include="Program.fs" /></ItemGroup></Project>\n' "$framework" > project.fsproj \
&& dotnet build -nologo \
&& cd / && rm -rf /tmp/cs /tmp/fs \
|| exit 1; \
done \
&& rm -rf /root/.dotnet /root/.local/share/NuGet \
&& chmod -R a+rwX /opt/nuget
### Gleam (JavaScript target, executed with Bun)
# Bun is a single binary with its own name, so it does not touch the system node
# or erlang that other languages (Elixir, NodeJS, Solidity) depend on.
# Binaries go to /usr/local/bin, because firejail --private hides /root.
# The baseline Bun build is used, because the standard x64 build needs AVX2,
# which older servers, VMs with a default CPU type and Rosetta do not offer.
ARG GLEAM_VERSION=v1.19.0
ARG BUN_VERSION=v1.4.5
RUN curl -fsSL "https://github.com/gleam-lang/gleam/releases/download/${GLEAM_VERSION}/gleam-${GLEAM_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
| tar -xz -C /usr/local/bin gleam \
&& curl -fsSL -o /tmp/bun.zip "https://github.com/oven-sh/bun/releases/download/bun-${BUN_VERSION}/bun-linux-x64-baseline.zip" \
&& python3 -c "import zipfile; zipfile.ZipFile('/tmp/bun.zip').extractall('/tmp/bun')" \
&& install -m 755 /tmp/bun/bun-linux-x64-baseline/bun /usr/local/bin/bun \
&& rm -rf /tmp/bun /tmp/bun.zip
# Template project with gleam_stdlib downloaded and precompiled, so a build
# neither contacts Hex nor compiles the standard library for every new project.
# compiler/gleam.py copies this into every working directory before `gleam build`.
ENV GLEAM_TEMPLATE=/opt/gleam-template
RUN mkdir -p /opt/gleam-template/src && cd /opt/gleam-template \
&& printf 'name = "main"\nversion = "1.0.0"\ntarget = "javascript"\n\n[javascript]\nruntime = "bun"\n\n[dependencies]\ngleam_stdlib = ">= 0.44.0 and < 2.0.0"\n' > gleam.toml \
&& printf 'import gleam/io\n\npub fn main() {\n io.println("warm-up")\n}\n' > src/main.gleam \
&& gleam build \
&& gleam run --no-print-progress \
&& rm -rf src build/dev/javascript/main \
&& chmod -R a+rX /opt/gleam-template
### Less CPU and memory for the same work, each setting is measured
# (512 MB, 8 CPUs; see "Tuning" in CLAUDE.md)
# numpy starts one BLAS thread per CPU, and they spin while they wait: a plot with
# matplotlib took 1.7 s of CPU time for 0.3 s of work. One thread: 0.3 s.
# The Erlang VM (Erlang, Elixir) lets its schedulers spin as well: 0.5 s -> 0.2 s.
# Coq sets the minor heap of OCaml to 256 MB, unless OCAMLRUNPARAM is set, and fills
# it before the first collection: 290 MB for a small proof. With 8 MB (1M words) it
# is 146 MB, for a quarter more CPU time (0.19 -> 0.24 s). Programs in OCaml get
# 8 MB instead of their default of 2 MB.
# The Q# package reports its usage to Microsoft and waits for that at the end of
# every run: 0.83 s instead of 0.12 s.
ENV OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 \
ERL_AFLAGS="+sbwt none +sbwtdcpu none +sbwtdio none" \
OCAMLRUNPARAM=s=1M \
QSHARP_PYTHON_TELEMETRY=none
# Not a tuning, a fix: Nim keeps the C files and objects of a build in a cache that is
# named after the source file, ~/.cache/nim/main_d for every main.nim. Users who
# compile at the same moment overwrite the files of each other there: of 48 builds by
# 8 users 25 failed and 17 produced the program of somebody else. So every run gets
# a cache in its own folder, which is removed with it. It costs 0.2 s of CPU time per
# build (0.4 -> 0.6 s), because the standard library is compiled every time.
RUN printf '\n# CodeRunner: one cache per run, see the Dockerfile\nswitch("nimcache", projectDir() & "/nimcache")\n' >> /opt/nim/config/config.nims
# The compilers on the JVM are short runs. Two things make them cheaper, both only for
# the compilers: programs of the users keep the defaults of the JVM.
# - The serial GC and only the fast JIT (C1) halve their CPU time, and kotlinc gets a
# heap of 256 MB instead of 512 MB.
# - An AOT cache (JDK 25, -XX:AOTCache): a file with the classes of the compiler as
# they are in memory after loading and linking. One training run each writes it
# here, every later start maps it instead of reading the classes from the jar, and
# runs at the same time share it. A cache that does not fit a start (another
# class path, like Clojure with a deps.edn of the course, or other options) is not
# used. The JVM says so in the output of the program, hence -Xlog:aot=off.
# kotlinc is started directly, not through its script: that loads the compiler with a
# preloader, which reads the whole jar into memory and uses a class loader of its own
# that the cache does not cover. Without the preloader alone: 396 -> 203 MB.
# shortcut: the options -J... and -D... of the script of kotlinc do not reach the JVM,
# upgrade when a course needs them (JAVA_OPTS works).
# Clojure and SelectScript run the program of the user in the same JVM: Clojure only
# gets the cache, SelectScript (S2c) only the flags, which also help its programs
# (the example of the README: 3.5 -> 2.6 s of CPU time), a cache does nothing for it.
# --enable-native-access keeps JDK 25 from printing four lines of warning about JNA
# into the output of every SelectScript program.
#
# one compile CPU time memory cache in the image
# kotlinc 2.7 -> 1.3 s 396 -> 197 MB 93 MB
# scalac 1.2 -> 0.9 s 173 -> 141 MB 48 MB
# javac 0.4 -> 0.2 s 75 -> 58 MB 23 MB
# clojure 0.5 -> 0.2 s 71 -> 67 MB 25 MB
# S2c 0.9 -> 0.5 s 84 -> 77 MB -
RUN JVM="-XX:+UseSerialGC -XX:TieredStopAtLevel=1" AOT=/opt/aot \
&& KOTLIN="--enable-native-access=ALL-UNNAMED --sun-misc-unsafe-memory-access=allow -Dkotlin.home=/opt/kotlinc -cp /opt/kotlinc/lib/kotlin-compiler.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler" \
# the training runs, with the options of the start scripts below
&& mkdir $AOT /tmp/train && cd /tmp/train \
&& printf 'fun main() { println((0..9).map { it * it }.joinToString(" ")) }\n' > main.kt \
&& printf 'public class Main { public static void main(String[] a) { System.out.println("hi"); } }\n' > Main.java \
&& printf 'object HelloWorld { def main(a: Array[String]): Unit = println((0 to 9).map(i => i * i).mkString(" ")) }\n' > HelloWorld.scala \
&& printf '(println (clojure.string/join " " (map inc (range 10))))\n' > main.clj \
&& java -Xmx256M -Xms32M $JVM -XX:AOTCacheOutput=$AOT/kotlinc.aot $KOTLIN main.kt -include-runtime -d main.jar \
&& JAVA_OPTS="-Xmx256M -Xms32M $JVM -XX:AOTCacheOutput=$AOT/scalac.aot" /usr/bin/scalac HelloWorld.scala \
&& /usr/bin/javac -J-XX:+UseSerialGC -J-XX:TieredStopAtLevel=1 -J-XX:AOTCacheOutput=$AOT/javac.aot Main.java \
&& clojure -J-XX:AOTCacheOutput=$AOT/clojure.aot -M main.clj \
&& cd / && rm -rf /tmp/train \
&& ls -l $AOT/kotlinc.aot $AOT/scalac.aot $AOT/javac.aot $AOT/clojure.aot \
# the start scripts
&& rm /usr/local/bin/kotlinc \
&& printf '#!/bin/sh\nexec java ${JAVA_OPTS:--Xmx256M -Xms32M %s -XX:AOTCache=%s/kotlinc.aot -Xlog:aot=off} %s "$@"\n' "$JVM" $AOT "$KOTLIN" > /usr/local/bin/kotlinc \
&& printf '#!/bin/sh\nexport JAVA_OPTS="${JAVA_OPTS:--Xmx256M -Xms32M %s -XX:AOTCache=%s/scalac.aot -Xlog:aot=off}"\nexec /usr/bin/scalac "$@"\n' "$JVM" $AOT > /usr/local/bin/scalac \
&& printf '#!/bin/sh\nexec /usr/bin/javac -J-XX:+UseSerialGC -J-XX:TieredStopAtLevel=1 -J-XX:AOTCache=%s/javac.aot -J-Xlog:aot=off "$@"\n' $AOT > /usr/local/bin/javac \
&& printf '#!/bin/sh\nexec java %s --enable-native-access=ALL-UNNAMED -jar /usr/local/bin/S2c.jar "$@"\n' "$JVM" > /usr/local/bin/S2c \
# clojure: only where it starts the program, not where it computes the class path
&& sed -i 's|-XX:-OmitStackTraceInFastThrow $JAVA_OPTS|-XX:-OmitStackTraceInFastThrow -XX:AOTCache=/opt/aot/clojure.aot -Xlog:aot=off $JAVA_OPTS|' /usr/local/bin/clojure \
&& test "$(grep -c 'AOTCache=/opt/aot/clojure.aot' /usr/local/bin/clojure)" = 2 \
&& chmod +x /usr/local/bin/kotlinc /usr/local/bin/scalac /usr/local/bin/javac /usr/local/bin/S2c
# g++ spends most of a small compile on reading <iostream>. A precompiled header next
# to it is used when `#include <iostream>` is the first include of the file and the
# command has no options that change the language (-std=, -O2, -g, -pthread; -Wall is
# fine), like `g++ main.cpp -o a.out` of @LIA.cpp: 0.14 -> 0.08 s of CPU time and
# 79 -> 64 MB. In every other case g++ ignores it and reads the header. 27 MB.
RUN g++ -x c++-header /usr/include/c++/$(g++ -dumpversion)/iostream -o /usr/include/c++/$(g++ -dumpversion)/iostream.gch
# Go keeps its build cache in $HOME, which is empty after every start of the server. The
# first build then compiles the standard library: 3.1 s and 313 MB instead of 0.1 s and
# 93 MB. The cache is filled here and stays writable for the user of the server.
# (The same for Zig does not pay off: a cache filled here is only hit in part.)
ENV GOCACHE=/opt/go-cache
RUN mkdir /tmp/warm && cd /tmp/warm \
&& printf 'package main\n\nimport (\n\t"bufio"\n\t"errors"\n\t"fmt"\n\t"math"\n\t"math/rand"\n\t"os"\n\t"sort"\n\t"strconv"\n\t"strings"\n\t"sync"\n\t"time"\n)\n\nfunc main() {\n\tvar wg sync.WaitGroup\n\twg.Wait()\n\tr := bufio.NewReader(os.Stdin)\n\t_ = r\n\tfmt.Println(math.Sqrt(2), rand.Intn(2), strconv.Itoa(1), strings.ToUpper("x"), time.Now(), errors.New("x"))\n\tsort.Ints([]int{2, 1})\n}\n' > main.go \
&& go build main.go \
&& cd / && rm -rf /tmp/warm \
&& chmod -R a+rwX /opt/go-cache
#############################################################################################
COPY . /coderunner
WORKDIR "/coderunner"
RUN pip3 install --no-cache-dir -r requirements.txt \
&& install -m 755 tools/qsharp /usr/local/bin/qsharp
# served by the `versions` websocket service, see versions.py
RUN python3 versions.py > versions.json
RUN chmod u+s /usr/bin/firejail
# For some reasons firejail needs to be run multiple times to work
RUN firejail || true
RUN firejail || true
RUN firejail || true
RUN firejail || true
RUN firejail || true
RUN firejail || true
RUN firejail || true
RUN firejail || true
RUN firejail || true
RUN firejail || true
# The terminal of a running program answers no queries. Without these settings `python3 -i`
# prints a warning, and irb (Ruby 3.3) waits forever for the cursor position.
ENV PYTHON_BASIC_REPL=1 IRBRC=/etc/irbrc
RUN echo 'IRB.conf[:USE_SINGLELINE] = false' > /etc/irbrc
# Modula 2 requirement
ENV GM2PATH=/usr/share/gm2
RUN mv /usr/bin/gm2 /usr/bin/gm2.real && \
printf '#!/bin/sh\nexec /usr/bin/gm2.real -g -I. -flibs=pim,iso,cor "$@"\n' > /usr/bin/gm2 && \
chmod +x /usr/bin/gm2
# Create Objective-C compiler script with GNUstep configuration
RUN printf '#!/bin/bash\n\
if [ $# -lt 1 ]; then\n\
echo "Usage: gobjc source_file [output_name]"\n\
exit 1\n\
fi\n\
\n\
SOURCEFILE="$1"\n\
FILENAME=$(basename -- "$SOURCEFILE")\n\
BASENAME="${FILENAME%%.*}"\n\
\n\
# Use second argument as output name if provided, otherwise use source basename\n\
OUTPUT="${2:-$BASENAME}"\n\
\n\
. /usr/share/GNUstep/Makefiles/GNUstep.sh\n\
gcc -std=gnu11 -x objective-c $(gnustep-config --objc-flags) -o "$OUTPUT" "$SOURCEFILE" $(gnustep-config --base-libs)\n\
' > /usr/local/bin/gobjc && \
chmod +x /usr/local/bin/gobjc
EXPOSE 4000
##ENTRYPOINT ["python3","-m","server","--host","0.0.0.0","--port","4000"]
CMD python3 -m server --host 0.0.0.0 --port $PORT