Compare commits

...

25 Commits

Author SHA1 Message Date
Manuel eb2040f2fe
What am I doing 2021-06-05 23:50:13 +02:00
Manuel 7822e6ad17
Merge branch 'hipfbf' into docker 2021-06-05 23:36:51 +02:00
Manuel b7ae9a1551
Change to high performance brainfuck interpreter 2021-06-05 23:35:52 +02:00
Manuel 459c2dd158
Reduce logging further 2021-06-05 23:34:12 +02:00
Manuel 6c153d6bf1
Fix tsc missing, was not merged from master 2021-06-05 23:21:29 +02:00
Manuel 8e04bd9726
Merge branch 'fix/node-run-time' into docker 2021-06-05 21:17:15 +02:00
Manuel d9156c574a
Merge master to revert swcs lack of type checking 2021-06-05 21:16:40 +02:00
Manuel 2dbc049f99
Change node base image for improved performance 2021-06-05 21:16:04 +02:00
Manuel 5a9a107cb4
Merge branch 'esolangs' into docker 2021-05-13 06:29:34 +02:00
Manuel ce05a4f680
Merge branch 'newlangs' into docker 2021-05-13 06:29:27 +02:00
Manuel 099c7d11b2
Merge branch 'fix/images' into docker 2021-05-13 06:29:20 +02:00
Manuel a8e2fc1af3
Merge branch 'fix/checkimages' into docker 2021-05-13 06:28:54 +02:00
Manuel e5ac8a9c55
Reduce excessive logging 2021-05-13 06:28:21 +02:00
Manuel 6d6f6f32aa
Disable buffering to fix Docker logs 2021-05-13 06:25:21 +02:00
Manuel 2a9afa5b25
Add ArnoldC image 2021-05-12 07:48:28 +02:00
Manuel 50e1a663c8
Add emojicode image 2021-05-12 07:48:10 +02:00
Manuel bbb8dd9646
Add lolcode image 2021-05-12 07:47:58 +02:00
Manuel 5858e89fab
Add setlX image 2021-05-12 07:43:41 +02:00
Manuel 26e49b3db5
Add dlang image 2021-05-12 07:43:19 +02:00
Manuel 45d28eb237
Update Haskell image and use stable Debian slim 2021-05-12 07:37:36 +02:00
Manuel a51b94913a
Use swc for TypeScript and don't print by default 2021-05-12 07:37:00 +02:00
Manuel 73d3fce78a
Update OpenJDK to latest version 2021-05-12 07:31:49 +02:00
Manuel 23bfdb65ab
Reduce language image sizes 2021-05-12 07:30:57 +02:00
Manuel bfed6e74a7
Allow container to be run with custom command 2021-05-12 07:16:42 +02:00
Manuel 1b8c2eea8d
Check if image exists before building 2021-05-12 07:10:21 +02:00
17 changed files with 201 additions and 19 deletions

View File

@ -1,5 +1,6 @@
module Main where
import System.IO (BufferMode (NoBuffering), hSetBuffering, stdout)
import Options.Applicative
import Myriad
@ -31,5 +32,6 @@ parseArgs = execParser $ info (helper <*> args) (fullDesc <> progDesc "Run the M
main :: IO ()
main = do
hSetBuffering stdout NoBuffering
Args { configPath, languagesDir } <- parseArgs
runMyriadServer configPath languagesDir

View File

@ -0,0 +1,9 @@
FROM openjdk:17-alpine
LABEL author="SunRed"
RUN apk add --no-cache curl && \
curl -O http://lhartikk.github.io/ArnoldC.jar && \
mv ArnoldC.jar /var/run && \
apk del --no-cache curl
COPY run.sh /var/run/

2
languages/arnoldc/run.sh Normal file
View File

@ -0,0 +1,2 @@
cat > program.arnoldc
java -jar /var/run/ArnoldC.jar program.arnoldc && java program

View File

@ -1,12 +1,13 @@
FROM alpine AS build
FROM alpine as build
COPY bf.cpp .
RUN apk add --no-cache g++ && \
g++ bf.cpp -o bf
WORKDIR /tmp/bf
RUN apk add --no-cache musl-dev gcc make git && \
git clone https://github.com/rdebath/Brainfuck.git . && \
cd tritium && \
make
FROM alpine
LABEL author="1Computer1"
LABEL author="SunRed"
RUN apk add --no-cache libstdc++
COPY --from=build bf /usr/local/bin/
COPY --from=build /tmp/bf/tritium/bfi.out /usr/local/bin/bf
COPY run.sh /var/run/

6
languages/d/Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM alpine
LABEL author="SunRed"
RUN apk add --no-cache musl-dev gcc ldc
COPY run.sh /var/run/

2
languages/d/run.sh Normal file
View File

@ -0,0 +1,2 @@
cat > program.d
ldc2 program.d -of program && ./program

View File

@ -0,0 +1,57 @@
FROM debian:stable-slim as build
ENV CC clang-8
ENV CXX clang++-8
ENV DEBIAN_FRONTEND=nontinteractive
ENV PYTHONIOENCODING utf8
RUN \
apt-get update && \
apt-get install -y \
gnupg \
wget && \
echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list && \
echo "deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" >> /etc/apt/sources.list && \
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add - && \
apt-get update && \
apt-get install -y \
clang-8 \
cmake \
libstdc++-8-dev \
libclang1-8 \
libclang-8-dev \
libclang-common-8-dev \
libfuzzer-8-dev \
libllvm8 \
libncurses-dev \
libz-dev \
llvm-8 \
llvm-8-dev \
llvm-runtime \
ninja-build \
python3 \
rsync \
git && \
rm -rf /var/lib/apt/lists/* && \
mkdir /tmp/emojicode/
WORKDIR /tmp/emojicode/
RUN git clone https://github.com/emojicode/emojicode.git .
RUN cmake . -GNinja && \
ninja && \
ninja magicinstall
FROM debian:stable-slim
LABEL author="SunRed"
ENV CXX=g++
RUN apt-get update && \
apt-get install -y ${CXX} && \
apt-get autoremove -y && \
apt-get autoclean -y
COPY --from=build /usr/local/bin /usr/local/bin
COPY --from=build /usr/local/EmojicodePackages /usr/local/EmojicodePackages
COPY run.sh /var/run/

View File

@ -0,0 +1,2 @@
cat > program.emojic
emojicodec program.emojic -o program && ./program

View File

@ -1,4 +1,4 @@
FROM node:alpine
FROM node:slim
LABEL author="1Computer1"
COPY run.sh /var/run/

View File

@ -0,0 +1,15 @@
FROM alpine as build
RUN apk add --no-cache build-base git cmake
WORKDIR /tmp/lci
RUN git clone https://github.com/justinmeza/lci.git .
RUN cmake . && make
FROM alpine
LABEL author="SunRed"
COPY --from=build /tmp/lci/lci /usr/local/bin
COPY run.sh /var/run/

2
languages/lolcode/run.sh Normal file
View File

@ -0,0 +1,2 @@
cat > program.lol
lci program.lol

View File

@ -0,0 +1,17 @@
FROM openjdk:17-alpine
LABEL author="SunRed"
COPY setlX /usr/local/bin/
COPY run.sh /var/run/
RUN apk add --no-cache curl unzip bash && \
curl -O https://download.randoom.org/setlX/pc/setlX_v2-7-2.binary_only.zip && \
unzip -d setlx setlX_v2-7-2.binary_only.zip && \
rm -f setlX_v2-7-2.binary_only.zip && \
mkdir -p /usr/local/setlX && \
mv setlx/setlX*.jar /usr/local/setlX && \
mkdir -p /usr/local/setlXlibrary && \
mv setlx/setlXlibrary/* /usr/local/setlXlibrary && \
chmod +x /usr/local/bin/setlX && \
rm -rf setlx && \
apk del --no-cache curl unzip

2
languages/setlx/run.sh Normal file
View File

@ -0,0 +1,2 @@
cat > program.stlx
bash /usr/local/bin/setlX ./program.stlx

65
languages/setlx/setlX Normal file
View File

@ -0,0 +1,65 @@
#!/bin/bash
#
#
# launcher script for the setlX interpreter on Unix-like systems
#
#
# insert path to the folder where you copied the jar files here
setlXJarDirectory="/usr/local/setlX/"
# insert full path to library location here
setlXlibraryPath="/usr/local/setlXlibrary/"
############################## additional options ##############################
javaParameters=""
# uncomment to force execution in 64 bit mode
#javaParameters="$javaParameters -d64"
# uncomment to execute with increased memory size (6GB) (>2GB needs 64 Bit mode!)
#javaParameters="$javaParameters -Xmx6144m"
# uncomment to execute with increased stack size
#javaParameters="$javaParameters -Xss48m"
################################################################################
if [ -n "$OVERRIDE_setlXJarDirectory" ]
then
setlXJarDirectory="$OVERRIDE_setlXJarDirectory"
fi
if [ -n "$OVERRIDE_setlXjavaParameters" ]
then
javaParameters="$OVERRIDE_setlXjavaParameters"
fi
if [ -z "$SETLX_LIBRARY_PATH" ]
then
export SETLX_LIBRARY_PATH="$setlXlibraryPath"
fi
java_call="java"
if [[ -z "$INSIDE_EMACS" && $(which rlwrap > /dev/null 2>&1; echo $?) -eq 0 ]]
then
java_call="rlwrap -C $(basename $0) $java_call"
fi
jarFiles=""
while read -r -d $'\0' jarname
do
if [ -n "$jarFiles" ]
then
jarFiles="$jarFiles:"
fi
jarFiles="$jarFiles${jarname#./}"
done < <( find "$setlXJarDirectory" -maxdepth 1 -name "*.jar" -print0 )
if [ -n "$jarFiles" ]
then
$java_call -cp "$jarFiles:$CLASSPATH" $javaParameters org.randoom.setlx.pc.ui.SetlX "$@"
exit $?
else
echo "The setlX jar files cannot be found!"
exit 1
fi

View File

@ -1,4 +1,4 @@
FROM node:alpine
FROM node:slim
LABEL author="1Computer1"
RUN yarn global add typescript @types/node

View File

@ -95,7 +95,7 @@ initEnv configPath languagesDir =
<*> newSnowflakeGen defaultConfig 0
runMyriadT :: MonadIO m => Env -> MyriadT m a -> m a
runMyriadT env = runStdoutLoggingT . flip runReaderT env . unMyriadT
runMyriadT env = runStdoutLoggingT . filterLogger (\_ lvl -> lvl /= LevelDebug) . flip runReaderT env . unMyriadT
exec :: (MonadIO m, MonadLogger m) => [String] -> m BL.ByteString
exec args = do

View File

@ -83,9 +83,9 @@ startCleanup = do
timer t = forever $ do
-- Takes time in microseconds
threadDelay $ t * 60000000
logInfo ["Starting cleanup of containers"]
logDebug ["Starting cleanup of containers"]
n <- killContainers
logInfo ["Cleaned up ", cs $ show n, " containers, next in ", cs $ show t, " minutes"]
logDebug ["Cleaned up ", cs $ show n, " containers, next in ", cs $ show t, " minutes"]
timer t
setupContainer :: Language -> Myriad ContainerName
@ -152,9 +152,9 @@ killContainer lang = do
killContainers :: Myriad [ContainerName]
killContainers = do
containers <- gview #containers >>= readMVar
logInfo ["Starting killing of containers"]
logDebug ["Starting killing of containers"]
xs <- forConcurrently (M.toList containers) $ \(k, v) -> (v,) <$> killContainer k
logInfo ["Finished killing of containers"]
logDebug ["Finished killing of containers"]
pure . map fst $ filter snd xs
evalCode :: Language -> Int -> String -> Myriad EvalResult
@ -171,14 +171,14 @@ evalCode lang numRetries code = withContainer $ \cnt -> do
if done
-- If we find the eval is done from an exception, then it was timed out.
then do
logInfo ["Code timed out in container ", cs cnt, ", evaluation ", cs $ show snowflake]
logDebug ["Code timed out in container ", cs cnt, ", evaluation ", cs $ show snowflake]
pure EvalTimedOut
-- Otherwise, the container was killed from another eval, so we should retry.
else do
writeMVar doneRef True
if numRetries < fromIntegral (lang ^. #retries)
then do
logInfo
logDebug
[ "An exception occured in "
, cs cnt
, ", evaluation "
@ -188,7 +188,7 @@ evalCode lang numRetries code = withContainer $ \cnt -> do
]
evalCode lang (numRetries + 1) code
else do
logInfo
logDebug
[ "An exception occured in "
, cs cnt
, ", evaluation "
@ -228,7 +228,7 @@ evalCode lang numRetries code = withContainer $ \cnt -> do
eval :: ContainerName -> Snowflake -> Myriad EvalResult
eval cnt snowflake = do
logInfo ["Running code in container ", cs cnt, ", evaluation ", cs $ show snowflake, ":\n", cs code]
logDebug ["Running code in container ", cs cnt, ", evaluation ", cs $ show snowflake, ":\n", cs code]
exec_ ["docker exec ", cs cnt, " mkdir eval/", show snowflake]
exec_ ["docker exec ", cs cnt, " chmod 777 eval/", show snowflake]
-- User 1001 will be used for the actual execution so that they can't access `eval` itself
@ -245,7 +245,7 @@ evalCode lang numRetries code = withContainer $ \cnt -> do
logDebug ["Executing with stdin `", cs cmd, "`"]
output <- readProcessInterleaved_ pr
exec_ ["docker exec ", cnt, " rm -rf eval/", show snowflake]
logInfo ["Ran code in container ", cs cnt, ", evaluation ", cs $ show snowflake]
logDebug ["Ran code in container ", cs cnt, ", evaluation ", cs $ show snowflake]
pure $ EvalOk output
newContainerName :: Language -> Myriad ContainerName