Sign inSign up
compilers logo

stden/compilers

By stden

•Updated 1 day ago

Compile Hello, world! examples in eight languages and check PDF output with two LaTeX engines.

Image
Languages & frameworks
Developer tools
0

2.0K

stden/compilers repository overview

⁠stden/compilers

Compile Hello, world! examples in eight languages and check PDF output with two LaTeX engines.

⁠What you learn

You learn to use compilers in a Docker container.

⁠Overview

This image contains GNU C, GNU C++, Mono C#, DMD for D, GHC for Haskell, OpenJDK 25 for Java, Free Pascal, and Python. Python runs from a virtual environment with NumPy and pandas. The image also has pdfLaTeX, LuaLaTeX, PDF text tools, git, curl, wget, and tree.

The base image is debian:stable-slim. The WORKDIR is /x. The default command compiles each example and checks its output.

⁠Tags

TagMeaningPlatform
latestLatest successful build from main.linux/amd64

View all tags on Docker Hub⁠. The latest tag changes when a new build passes its tests.

⁠Pull the image

docker pull stden/compilers:latest

⁠Run the sample programs

docker run --rm stden/compilers:latest

Each program must print Hello, world!. Both LaTeX engines must create a PDF with the same text. The runner stops if a compiler fails, a program fails, or the result is incorrect. The runner deletes all temporary files after each run.

Language or formatToolExample
CGCChw_c.c⁠
C++G++hw_cpp.cpp⁠
C#Mono C# and Monohw.cs⁠
DDMDhw_d.d⁠
HaskellGHChw_haskell.hs⁠
JavaOpenJDK 25hw_java.java⁠
PascalFree Pascalhw_pascal.pas⁠
PythonPython 3hw_python.py⁠
PDFpdfLaTeX and LuaLaTeXhw_latex.tex⁠

Expected output:

== Program in C ==
Hello, world!
PASS C
== Program in C++ ==
Hello, world!
PASS C++
== Program in C# ==
Hello, world!
PASS C#
== Program in D ==
Hello, world!
PASS D
== Program in Haskell ==
Hello, world!
PASS Haskell
== Program in Java ==
Hello, world!
PASS Java
== Program in Pascal ==
Hello, world!
PASS Pascal
== Program in Python ==
Hello, world!
PASS Python
== Program in pdfLaTeX ==
Hello, world!
PASS pdfLaTeX
== Program in LuaLaTeX ==
Hello, world!
PASS LuaLaTeX

⁠Compile your own code

Mount your source directory at /workspace. Select it with -w /workspace. The sample programs stay available under /x.

For a C++ source file named main.cpp:

docker run --rm -v "$PWD":/workspace -w /workspace stden/compilers:latest \
  bash -c 'g++ main.cpp -o app && ./app'

For a Python source file named main.py:

docker run --rm -v "$PWD":/workspace -w /workspace stden/compilers:latest \
  python main.py

For a Haskell source file named main.hs:

docker run --rm -v "$PWD":/workspace -w /workspace stden/compilers:latest \
  bash -c 'ghc -o app main.hs && ./app'

For a Java source file named Main.java with the class Main:

docker run --rm -v "$PWD":/workspace -w /workspace stden/compilers:latest \
  bash -c 'javac Main.java && java Main'

Start an interactive shell to use the other compilers:

docker run --rm -it -v "$PWD":/workspace -w /workspace \
  stden/compilers:latest bash

New files in /workspace stay in the host directory. If the included tools are not sufficient, install extra project dependencies in a child image.

⁠Source and checks

The smoke test runs the examples and checks all ten results. Both CI runners use this test. The regression test checks compile failures, runtime failures, incorrect text, PDF failures, and temporary file cleanup.

From the repository root, build the image and test every result:

./test-images.sh compilers

Run the runner regression test without Docker:

bash ci/test-compilers.sh

Tag summary

Content type

Image

Digest

sha256:f61e96d9a…

Size

1000.2 MB

Last updated

1 day ago

docker pull stden/compilers