From fbefced60bd2fda0391be7357be84881cf22f293 Mon Sep 17 00:00:00 2001 From: Marc Diaz <33824219+marcgabe15@users.noreply.github.com> Date: Sat, 28 Jun 2025 19:07:52 -0700 Subject: [PATCH 01/16] feat: cleaning up included packages (#1) * updated dockerfile * update catch2 * sending to other device * removed mono and bash * removed python * final image * feat: adding actions workflow and installing python packages --------- Co-authored-by: Prayuj Tuli --- .github/workflows/build.yml | 40 ++++ Dockerfile | 461 +++--------------------------------- 2 files changed, 79 insertions(+), 422 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..28eb7a2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +name: Build Judge0 Compilers Image + +on: + release: + types: [published] + +env: + ACCOUNT_ID: 990066513532 + AWS_REGION: us-east-1 + ECR_REPO: edugatorlabs/judge0-compilers + PIPELINE_ID: ${{ github.run_id }}-${{ github.run_number }} + +permissions: + id-token: write + contents: read + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/GitHubDeploymentRole + aws-region: ${{ env.AWS_REGION }} + + - name: Log in to Amazon ECR + run: | + aws ecr get-login-password --region ${{ env.AWS_REGION }} \ + | docker login --username AWS --password-stdin ${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com + + - name: Build, Tag, and Push Docker image to ECR + run: | + IMAGE_URI=${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:${{ env.PIPELINE_ID }} + docker build -t $IMAGE_URI . + docker push $IMAGE_URI + echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 78833f7..cbbd3c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,11 @@ # Check for latest version here: https://hub.docker.com/_/buildpack-deps?tab=tags&page=1&name=buster&ordering=last_updated # This is just a snapshot of buildpack-deps:buster that was last updated on 2019-12-28. -FROM judge0/buildpack-deps:buster-2019-12-28 +FROM buildpack-deps:bookworm # Check for latest version here: https://gcc.gnu.org/releases.html, https://ftpmirror.gnu.org/gcc ENV GCC_VERSIONS \ - 7.4.0 \ - 8.3.0 \ - 9.2.0 + 12.1.0 + RUN set -xe && \ for VERSION in $GCC_VERSIONS; do \ curl -fSsL "https://ftpmirror.gnu.org/gcc/gcc-$VERSION/gcc-$VERSION.tar.gz" -o /tmp/gcc-$VERSION.tar.gz && \ @@ -18,41 +17,19 @@ RUN set -xe && \ { rm *.tar.* || true; } && \ tmpdir="$(mktemp -d)" && \ cd "$tmpdir"; \ - if [ $VERSION = "9.2.0" ]; then \ - ENABLE_FORTRAN=",fortran"; \ - else \ - ENABLE_FORTRAN=""; \ - fi; \ /tmp/gcc-$VERSION/configure \ --disable-multilib \ - --enable-languages=c,c++$ENABLE_FORTRAN \ + --enable-languages=c,c++,fortran \ --prefix=/usr/local/gcc-$VERSION && \ make -j$(nproc) && \ make -j$(nproc) install-strip && \ rm -rf /tmp/*; \ done -# Check for latest version here: https://www.ruby-lang.org/en/downloads -ENV RUBY_VERSIONS \ - 2.7.0 -RUN set -xe && \ - for VERSION in $RUBY_VERSIONS; do \ - curl -fSsL "https://cache.ruby-lang.org/pub/ruby/$%7BVERSION%.*%7D/ruby-$VERSION.tar.gz" -o /tmp/ruby-$VERSION.tar.gz && \ - mkdir /tmp/ruby-$VERSION && \ - tar -xf /tmp/ruby-$VERSION.tar.gz -C /tmp/ruby-$VERSION --strip-components=1 && \ - rm /tmp/ruby-$VERSION.tar.gz && \ - cd /tmp/ruby-$VERSION && \ - ./configure \ - --disable-install-doc \ - --prefix=/usr/local/ruby-$VERSION && \ - make -j$(nproc) && \ - make -j$(nproc) install && \ - rm -rf /tmp/*; \ - done - # Check for latest version here: https://www.python.org/downloads +# python3.11 is already installed ENV PYTHON_VERSIONS \ - 3.8.1 \ + 3.12.7 \ 2.7.17 RUN set -xe && \ for VERSION in $PYTHON_VERSIONS; do \ @@ -68,37 +45,23 @@ RUN set -xe && \ rm -rf /tmp/*; \ done -# Check for latest version here: https://ftp.gnu.org/gnu/octave -ENV OCTAVE_VERSIONS \ - 5.1.0 +# Install pandas and numpy on python 3.12 +# After Python installs RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends gfortran libblas-dev liblapack-dev libpcre3-dev && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $OCTAVE_VERSIONS; do \ - curl -fSsL "https://ftp.gnu.org/gnu/octave/octave-$VERSION.tar.gz" -o /tmp/octave-$VERSION.tar.gz && \ - mkdir /tmp/octave-$VERSION && \ - tar -xf /tmp/octave-$VERSION.tar.gz -C /tmp/octave-$VERSION --strip-components=1 && \ - rm /tmp/octave-$VERSION.tar.gz && \ - cd /tmp/octave-$VERSION && \ - ./configure \ - --prefix=/usr/local/octave-$VERSION && \ - make -j$(nproc) && \ - make -j$(nproc) install && \ - rm -rf /tmp/*; \ - done + /usr/local/python-3.12.7/bin/python3 -m ensurepip && \ + /usr/local/python-3.12.7/bin/pip3 install --no-cache-dir pandas numpy # Check for latest version here: https://jdk.java.net RUN set -xe && \ - curl -fSsL "https://download.java.net/java/GA/jdk13.0.1/cec27d702aa74d5a8630c65ae61e4305/9/GPL/openjdk-13.0.1_linux-x64_bin.tar.gz" -o /tmp/openjdk13.tar.gz && \ - mkdir /usr/local/openjdk13 && \ - tar -xf /tmp/openjdk13.tar.gz -C /usr/local/openjdk13 --strip-components=1 && \ - rm /tmp/openjdk13.tar.gz && \ - ln -s /usr/local/openjdk13/bin/javac /usr/local/bin/javac && \ - ln -s /usr/local/openjdk13/bin/java /usr/local/bin/java && \ - ln -s /usr/local/openjdk13/bin/jar /usr/local/bin/jar + curl -fSsL "https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz" -o /tmp/openjdk21.tar.gz && \ + mkdir /usr/local/openjdk21 && \ + tar -xf /tmp/openjdk21.tar.gz -C /usr/local/openjdk21 --strip-components=1 && \ + rm /tmp/openjdk21.tar.gz && \ + ln -s /usr/local/openjdk21/bin/javac /usr/local/bin/javac && \ + ln -s /usr/local/openjdk21/bin/java /usr/local/bin/java && \ + ln -s /usr/local/openjdk21/bin/jar /usr/local/bin/jar -# Check for latest version here: https://ftpmirror.gnu.org/bash +## Check for latest version here: https://ftpmirror.gnu.org/bash ENV BASH_VERSIONS \ 5.0 RUN set -xe && \ @@ -115,62 +78,9 @@ RUN set -xe && \ rm -rf /tmp/*; \ done -# Check for latest version here: https://www.freepascal.org/download.html -ENV FPC_VERSIONS \ - 3.0.4 -RUN set -xe && \ - for VERSION in $FPC_VERSIONS; do \ - curl -fSsL "ftp://ftp.freepascal.org/fpc/dist/$VERSION/x86_64-linux/fpc-$VERSION.x86_64-linux.tar" -o /tmp/fpc-$VERSION.tar && \ - mkdir /tmp/fpc-$VERSION && \ - tar -xf /tmp/fpc-$VERSION.tar -C /tmp/fpc-$VERSION --strip-components=1 && \ - rm /tmp/fpc-$VERSION.tar && \ - cd /tmp/fpc-$VERSION && \ - echo "/usr/local/fpc-$VERSION" | sh install.sh && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://www.haskell.org/ghc/download.html -ENV HASKELL_VERSIONS \ - 8.8.1 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends libgmp-dev libtinfo5 && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $HASKELL_VERSIONS; do \ - curl -fSsL "https://downloads.haskell.org/~ghc/$VERSION/ghc-$VERSION-x86_64-deb8-linux.tar.xz" -o /tmp/ghc-$VERSION.tar.xz && \ - mkdir /tmp/ghc-$VERSION && \ - tar -xf /tmp/ghc-$VERSION.tar.xz -C /tmp/ghc-$VERSION --strip-components=1 && \ - rm /tmp/ghc-$VERSION.tar.xz && \ - cd /tmp/ghc-$VERSION && \ - ./configure \ - --prefix=/usr/local/ghc-$VERSION && \ - make -j$(nproc) install && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://www.mono-project.com/download/stable -ENV MONO_VERSIONS \ - 6.6.0.161 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends cmake && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $MONO_VERSIONS; do \ - curl -fSsL "https://download.mono-project.com/sources/mono/mono-$VERSION.tar.xz" -o /tmp/mono-$VERSION.tar.xz && \ - mkdir /tmp/mono-$VERSION && \ - tar -xf /tmp/mono-$VERSION.tar.xz -C /tmp/mono-$VERSION --strip-components=1 && \ - rm /tmp/mono-$VERSION.tar.xz && \ - cd /tmp/mono-$VERSION && \ - ./configure \ - --prefix=/usr/local/mono-$VERSION && \ - make -j$(nproc) && \ - make -j$(proc) install && \ - rm -rf /tmp/*; \ - done - # Check for latest version here: https://nodejs.org/en ENV NODE_VERSIONS \ - 12.14.0 + 22.12.0 RUN set -xe && \ for VERSION in $NODE_VERSIONS; do \ curl -fSsL "https://nodejs.org/dist/v$VERSION/node-v$VERSION.tar.gz" -o /tmp/node-$VERSION.tar.gz && \ @@ -185,44 +95,9 @@ RUN set -xe && \ rm -rf /tmp/*; \ done -# Check for latest version here: https://github.com/erlang/otp/releases -ENV ERLANG_VERSIONS \ - 22.2 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends unzip && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $ERLANG_VERSIONS; do \ - curl -fSsL "https://github.com/erlang/otp/archive/OTP-$VERSION.tar.gz" -o /tmp/erlang-$VERSION.tar.gz && \ - mkdir /tmp/erlang-$VERSION && \ - tar -xf /tmp/erlang-$VERSION.tar.gz -C /tmp/erlang-$VERSION --strip-components=1 && \ - rm /tmp/erlang-$VERSION.tar.gz && \ - cd /tmp/erlang-$VERSION && \ - ./otp_build autoconf && \ - ./configure \ - --prefix=/usr/local/erlang-$VERSION && \ - make -j$(nproc) && \ - make -j$(nproc) install && \ - rm -rf /tmp/*; \ - done; \ - ln -s /usr/local/erlang-22.2/bin/erl /usr/local/bin/erl - -# Check for latest version here: https://github.com/elixir-lang/elixir/releases -ENV ELIXIR_VERSIONS \ - 1.9.4 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends unzip && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $ELIXIR_VERSIONS; do \ - curl -fSsL "https://github.com/elixir-lang/elixir/releases/download/v$VERSION/Precompiled.zip" -o /tmp/elixir-$VERSION.zip && \ - unzip -d /usr/local/elixir-$VERSION /tmp/elixir-$VERSION.zip && \ - rm -rf /tmp/*; \ - done - # Check for latest version here: https://www.rust-lang.org ENV RUST_VERSIONS \ - 1.40.0 + 1.83.0 RUN set -xe && \ for VERSION in $RUST_VERSIONS; do \ curl -fSsL "https://static.rust-lang.org/dist/rust-$VERSION-x86_64-unknown-linux-gnu.tar.gz" -o /tmp/rust-$VERSION.tar.gz && \ @@ -236,7 +111,7 @@ RUN set -xe && \ rm -rf /tmp/*; \ done -# Check for latest version here: https://golang.org/dl +## Check for latest version here: https://golang.org/dl ENV GO_VERSIONS \ 1.13.5 RUN set -xe && \ @@ -247,284 +122,26 @@ RUN set -xe && \ rm -rf /tmp/*; \ done -# Check for latest version here: https://sourceforge.net/projects/fbc/files/Binaries%20-%20Linux -ENV FBC_VERSIONS \ - 1.07.1 -RUN set -xe && \ - for VERSION in $FBC_VERSIONS; do \ - curl -fSsL "https://downloads.sourceforge.net/project/fbc/Binaries%20-%20Linux/FreeBASIC-$VERSION-linux-x86_64.tar.gz" -o /tmp/fbc-$VERSION.tar.gz && \ - mkdir /usr/local/fbc-$VERSION && \ - tar -xf /tmp/fbc-$VERSION.tar.gz -C /usr/local/fbc-$VERSION --strip-components=1 && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://github.com/ocaml/ocaml/releases -ENV OCAML_VERSIONS \ - 4.09.0 -RUN set -xe && \ - for VERSION in $OCAML_VERSIONS; do \ - curl -fSsL "https://github.com/ocaml/ocaml/archive/$VERSION.tar.gz" -o /tmp/ocaml-$VERSION.tar.gz && \ - mkdir /tmp/ocaml-$VERSION && \ - tar -xf /tmp/ocaml-$VERSION.tar.gz -C /tmp/ocaml-$VERSION --strip-components=1 && \ - rm /tmp/ocaml-$VERSION.tar.gz && \ - cd /tmp/ocaml-$VERSION && \ - ./configure \ - -prefix /usr/local/ocaml-$VERSION \ - --disable-ocamldoc --disable-debugger && \ - make -j$(nproc) world.opt && \ - make -j$(nproc) install && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://www.php.net/downloads -ENV PHP_VERSIONS \ - 7.4.1 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends bison re2c && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $PHP_VERSIONS; do \ - curl -fSsL "https://codeload.github.com/php/php-src/tar.gz/php-$VERSION" -o /tmp/php-$VERSION.tar.gz && \ - mkdir /tmp/php-$VERSION && \ - tar -xf /tmp/php-$VERSION.tar.gz -C /tmp/php-$VERSION --strip-components=1 && \ - rm /tmp/php-$VERSION.tar.gz && \ - cd /tmp/php-$VERSION && \ - ./buildconf --force && \ - ./configure \ - --prefix=/usr/local/php-$VERSION && \ - make -j$(nproc) && \ - make -j$(nproc) install && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://dlang.org/download.html#dmd -ENV D_VERSIONS \ - 2.089.1 -RUN set -xe && \ - for VERSION in $D_VERSIONS; do \ - curl -fSsL "http://downloads.dlang.org/releases/2.x/$VERSION/dmd.$VERSION.linux.tar.xz" -o /tmp/d-$VERSION.tar.gz && \ - mkdir /usr/local/d-$VERSION && \ - tar -xf /tmp/d-$VERSION.tar.gz -C /usr/local/d-$VERSION --strip-components=1 && \ - rm -rf /usr/local/d-$VERSION/linux/*32 && \ - rm -rf /tmp/*; \ - done +## Check for latest version here: https://github.com/microsoft/TypeScript/releases +#ENV TYPESCRIPT_VERSIONS \ +# 3.7.4 +#RUN set -xe && \ +# curl -fSsL "https://deb.nodesource.com/setup_12.x" | bash - && \ +# apt-get update && \ +# apt-get install -y --no-install-recommends nodejs && \ +# rm -rf /var/lib/apt/lists/* && \ +# for VERSION in $TYPESCRIPT_VERSIONS; do \ +# npm install -g typescript@$VERSION; \ +# done -# Check for latest version here: https://www.lua.org/download.html -ENV LUA_VERSIONS \ - 5.3.5 RUN set -xe && \ - for VERSION in $LUA_VERSIONS; do \ - curl -fSsL "https://downloads.sourceforge.net/project/luabinaries/$VERSION/Tools%20Executables/lua-$%7BVERSION%7D_Linux44_64_bin.tar.gz" -o /tmp/lua-$VERSION.tar.gz && \ - mkdir /usr/local/lua-$VERSION && \ - tar -xf /tmp/lua-$VERSION.tar.gz -C /usr/local/lua-$VERSION && \ - rm -rf /tmp/*; \ - done; \ - ln -s /lib/x86_64-linux-gnu/libreadline.so.7 /lib/x86_64-linux-gnu/libreadline.so.6 + mkdir -p /usr/local/include/catch2 && \ + wget https://raw.githubusercontent.com/catchorg/Catch2/refs/tags/v2.13.8/single_include/catch2/catch.hpp -P /usr/local/include/catch2 -# Check for latest version here: https://github.com/microsoft/TypeScript/releases -ENV TYPESCRIPT_VERSIONS \ - 3.7.4 RUN set -xe && \ - curl -fSsL "https://deb.nodesource.com/setup_12.x" | bash - && \ - apt-get update && \ - apt-get install -y --no-install-recommends nodejs && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $TYPESCRIPT_VERSIONS; do \ - npm install -g typescript@$VERSION; \ - done - -# Check for latest version here: https://nasm.us -ENV NASM_VERSIONS \ - 2.14.02 -RUN set -xe && \ - for VERSION in $NASM_VERSIONS; do \ - curl -fSsL "https://www.nasm.us/pub/nasm/releasebuilds/$VERSION/nasm-$VERSION.tar.gz" -o /tmp/nasm-$VERSION.tar.gz && \ - mkdir /tmp/nasm-$VERSION && \ - tar -xf /tmp/nasm-$VERSION.tar.gz -C /tmp/nasm-$VERSION --strip-components=1 && \ - rm /tmp/nasm-$VERSION.tar.gz && \ - cd /tmp/nasm-$VERSION && \ - ./configure \ - --prefix=/usr/local/nasm-$VERSION && \ - make -j$(nproc) nasm ndisasm && \ - make -j$(nproc) strip && \ - make -j$(nproc) install && \ - echo "/usr/local/nasm-$VERSION/bin/nasm -o main.o \$@ && ld main.o" >> /usr/local/nasm-$VERSION/bin/nasmld && \ - chmod +x /usr/local/nasm-$VERSION/bin/nasmld && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: http://gprolog.org/#download -ENV GPROLOG_VERSIONS \ - 1.4.5 -RUN set -xe && \ - for VERSION in $GPROLOG_VERSIONS; do \ - curl -fSsL "http://gprolog.org/gprolog-$VERSION.tar.gz" -o /tmp/gprolog-$VERSION.tar.gz && \ - mkdir /tmp/gprolog-$VERSION && \ - tar -xf /tmp/gprolog-$VERSION.tar.gz -C /tmp/gprolog-$VERSION --strip-components=1 && \ - rm /tmp/gprolog-$VERSION.tar.gz && \ - cd /tmp/gprolog-$VERSION/src && \ - ./configure \ - --prefix=/usr/local/gprolog-$VERSION && \ - make -j$(nproc) && \ - make -j$(nproc) install-strip && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: http://www.sbcl.org/platform-table.html -ENV SBCL_VERSIONS \ - 2.0.0 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends bison re2c && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $SBCL_VERSIONS; do \ - curl -fSsL "https://downloads.sourceforge.net/project/sbcl/sbcl/$VERSION/sbcl-$VERSION-x86-64-linux-binary.tar.bz2" -o /tmp/sbcl-$VERSION.tar.bz2 && \ - mkdir /tmp/sbcl-$VERSION && \ - tar -xf /tmp/sbcl-$VERSION.tar.bz2 -C /tmp/sbcl-$VERSION --strip-components=1 && \ - cd /tmp/sbcl-$VERSION && \ - export INSTALL_ROOT=/usr/local/sbcl-$VERSION && \ - sh install.sh && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://ftp.gnu.org/gnu/gnucobol -ENV COBOL_VERSIONS \ - 2.2 -RUN set -xe && \ - for VERSION in $COBOL_VERSIONS; do \ - curl -fSsL "https://ftp.gnu.org/gnu/gnucobol/gnucobol-$VERSION.tar.xz" -o /tmp/gnucobol-$VERSION.tar.xz && \ - mkdir /tmp/gnucobol-$VERSION && \ - tar -xf /tmp/gnucobol-$VERSION.tar.xz -C /tmp/gnucobol-$VERSION --strip-components=1 && \ - rm /tmp/gnucobol-$VERSION.tar.xz && \ - cd /tmp/gnucobol-$VERSION && \ - ./configure \ - --prefix=/usr/local/gnucobol-$VERSION && \ - make -j$(nproc) && \ - make -j$(nproc) install && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://swift.org/download -ENV SWIFT_VERSIONS \ - 5.2.3 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends libncurses5 && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $SWIFT_VERSIONS; do \ - curl -fSsL "https://swift.org/builds/swift-$VERSION-release/ubuntu1804/swift-$VERSION-RELEASE/swift-$VERSION-RELEASE-ubuntu18.04.tar.gz" -o /tmp/swift-$VERSION.tar.gz && \ - mkdir /usr/local/swift-$VERSION && \ - tar -xf /tmp/swift-$VERSION.tar.gz -C /usr/local/swift-$VERSION --strip-components=2 && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://kotlinlang.org -ENV KOTLIN_VERSIONS \ - 1.3.70 -RUN set -xe && \ - for VERSION in $KOTLIN_VERSIONS; do \ - curl -fSsL "https://github.com/JetBrains/kotlin/releases/download/v$VERSION/kotlin-compiler-$VERSION.zip" -o /tmp/kotlin-$VERSION.zip && \ - unzip -d /usr/local/kotlin-$VERSION /tmp/kotlin-$VERSION.zip && \ - mv /usr/local/kotlin-$VERSION/kotlinc/* /usr/local/kotlin-$VERSION/ && \ - rm -rf /usr/local/kotlin-$VERSION/kotlinc && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://hub.docker.com/_/mono -# I currently use this to add support for Visual Basic.Net but this can be also -# used to support C# language which has been already supported but with manual -# installation of Mono (see above). -ENV MONO_VERSION 6.6.0.161 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends gnupg dirmngr && \ - rm -rf /var/lib/apt/lists/* && \ - export GNUPGHOME="$(mktemp -d)" && \ - gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \ - gpg --batch --export --armor 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF > /etc/apt/trusted.gpg.d/mono.gpg.asc && \ - gpgconf --kill all && \ - rm -rf "$GNUPGHOME" && \ - apt-key list | grep Xamarin && \ - apt-get purge -y --auto-remove gnupg dirmngr && \ - echo "deb http://download.mono-project.com/repo/debian stable-stretch/snapshots/$MONO_VERSION main" > /etc/apt/sources.list.d/mono-official-stable.list && \ - apt-get update && \ - apt-get install -y --no-install-recommends mono-vbnc && \ - rm -rf /var/lib/apt/lists/* /tmp/* - -# Check for latest version here: https://packages.debian.org/buster/clang-7 -# Used for additional compilers for C, C++ and used for Objective-C. -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends clang-7 gnustep-devel && \ - rm -rf /var/lib/apt/lists/* - -# Check for latest version here: https://cloud.r-project.org/src/base -ENV R_VERSIONS \ - 4.0.0 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends libpcre2-dev && \ - rm -rf /var/lib/apt/lists/* && \ - for VERSION in $R_VERSIONS; do \ - curl -fSsL "https://cloud.r-project.org/src/base/R-4/R-$VERSION.tar.gz" -o /tmp/r-$VERSION.tar.gz && \ - mkdir /tmp/r-$VERSION && \ - tar -xf /tmp/r-$VERSION.tar.gz -C /tmp/r-$VERSION --strip-components=1 && \ - rm /tmp/r-$VERSION.tar.gz && \ - cd /tmp/r-$VERSION && \ - ./configure \ - --prefix=/usr/local/r-$VERSION && \ - make -j$(nproc) && \ - make -j$(nproc) install && \ - rm -rf /tmp/*; \ - done - -# Check for latest version here: https://packages.debian.org/buster/sqlite3 -# Used for support of SQLite. -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends sqlite3 && \ - rm -rf /var/lib/apt/lists/* - -# Check for latest version here: https://scala-lang.org -ENV SCALA_VERSIONS \ - 2.13.2 -RUN set -xe && \ - for VERSION in $SCALA_VERSIONS; do \ - curl -fSsL "https://downloads.lightbend.com/scala/$VERSION/scala-$VERSION.tgz" -o /tmp/scala-$VERSION.tgz && \ - mkdir /usr/local/scala-$VERSION && \ - tar -xf /tmp/scala-$VERSION.tgz -C /usr/local/scala-$VERSION --strip-components=1 && \ - rm -rf /tmp/*; \ - done - -# Support for Perl came "for free" since it is already installed. - -# Check for latest version here: https://github.com/clojure/clojure/releases -ENV CLOJURE_VERSION 1.10.1 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends maven && \ - cd /tmp && \ - git clone https://github.com/clojure/clojure && \ - cd clojure && \ - git checkout clojure-$CLOJURE_VERSION && \ - mvn -Plocal -Dmaven.test.skip=true package && \ - mkdir /usr/local/clojure-$CLOJURE_VERSION && \ - cp clojure.jar /usr/local/clojure-$CLOJURE_VERSION && \ - apt-get remove --purge -y maven && \ - rm -rf /var/lib/apt/lists/* /tmp/* - -# Check for latest version here: https://github.com/dotnet/sdk/releases -RUN set -xe && \ - curl -fSsL "https://download.visualstudio.microsoft.com/download/pr/7d4c708b-38db-48b2-8532-9fc8a3ab0e42/23229fd17482119822bd9261b3570d87/dotnet-sdk-3.1.202-linux-x64.tar.gz" -o /tmp/dotnet.tar.gz && \ - mkdir /usr/local/dotnet-sdk && \ - tar -xf /tmp/dotnet.tar.gz -C /usr/local/dotnet-sdk && \ - rm -rf /tmp/* - -# Check for latest version here: https://groovy.apache.org/download.html -RUN set -xe && \ - curl -fSsL "https://dl.bintray.com/groovy/maven/apache-groovy-binary-3.0.3.zip" -o /tmp/groovy.zip && \ - unzip /tmp/groovy.zip -d /usr/local && \ - rm -rf /tmp/* + mkdir -p /usr/local/junit && \ + wget https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar -P /usr/local/junit && \ + wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar -P /usr/local/junit RUN set -xe && \ apt-get update && \ @@ -545,5 +162,5 @@ RUN set -xe && \ rm -rf /tmp/* ENV BOX_ROOT /var/local/lib/isolate -LABEL maintainer="Herman Zvonimir Došilović " -LABEL version="1.4.0" +LABEL maintainer="edugatorlabs " +LABEL version="0.0.1" \ No newline at end of file From 0b4430396efdec383aed4b2ebe70151fc1c6bd80 Mon Sep 17 00:00:00 2001 From: Prayuj Tuli Date: Sun, 29 Jun 2025 03:56:07 -0400 Subject: [PATCH 02/16] refactor: adding ruby back to compilers image --- Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Dockerfile b/Dockerfile index cbbd3c2..a7c7b32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,24 @@ RUN set -xe && \ rm -rf /tmp/*; \ done +# Check for latest version here: https://www.ruby-lang.org/en/downloads +ENV RUBY_VERSIONS \ + 2.7.0 +RUN set -xe && \ + for VERSION in $RUBY_VERSIONS; do \ + curl -fSsL "https://cache.ruby-lang.org/pub/ruby/$%7BVERSION%.*%7D/ruby-$VERSION.tar.gz" -o /tmp/ruby-$VERSION.tar.gz && \ + mkdir /tmp/ruby-$VERSION && \ + tar -xf /tmp/ruby-$VERSION.tar.gz -C /tmp/ruby-$VERSION --strip-components=1 && \ + rm /tmp/ruby-$VERSION.tar.gz && \ + cd /tmp/ruby-$VERSION && \ + ./configure \ + --disable-install-doc \ + --prefix=/usr/local/ruby-$VERSION && \ + make -j$(nproc) && \ + make -j$(nproc) install && \ + rm -rf /tmp/*; \ + done + # Check for latest version here: https://www.python.org/downloads # python3.11 is already installed ENV PYTHON_VERSIONS \ From 6a104abcb30487f63916c0db6d3baf282c7cee7f Mon Sep 17 00:00:00 2001 From: Prayuj Tuli Date: Sun, 29 Jun 2025 12:19:41 -0400 Subject: [PATCH 03/16] refactor: switching back to judge0 buildpack-deps base --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a7c7b32..f76f870 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ # Check for latest version here: https://hub.docker.com/_/buildpack-deps?tab=tags&page=1&name=buster&ordering=last_updated # This is just a snapshot of buildpack-deps:buster that was last updated on 2019-12-28. -FROM buildpack-deps:bookworm +FROM judge0/buildpack-deps:buster-2019-12-28 # Check for latest version here: https://gcc.gnu.org/releases.html, https://ftpmirror.gnu.org/gcc +# build image comes with gcc and g++ 8.3.0 by default ENV GCC_VERSIONS \ 12.1.0 From 0c306b234f6af913686262b8c914f3d2d8391047 Mon Sep 17 00:00:00 2001 From: Prayuj Tuli Date: Sun, 29 Jun 2025 14:09:46 -0400 Subject: [PATCH 04/16] refactor: setting latest gcc/g++ versions to default --- Dockerfile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index f76f870..2f2b899 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,11 +45,15 @@ RUN set -xe && \ rm -rf /tmp/*; \ done +# Change default gcc / g++ after Ruby installation +# Ruby 2.7.0 needs gcc-8.0 +RUN ln -sf /usr/local/gcc-12.1.0/bin/gcc /usr/bin/gcc && \ + ln -sf /usr/local/gcc-12.1.0/bin/g++ /usr/bin/g++ + # Check for latest version here: https://www.python.org/downloads # python3.11 is already installed ENV PYTHON_VERSIONS \ - 3.12.7 \ - 2.7.17 + 3.12.7 RUN set -xe && \ for VERSION in $PYTHON_VERSIONS; do \ curl -fSsL "https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz" -o /tmp/python-$VERSION.tar.xz && \ @@ -64,11 +68,15 @@ RUN set -xe && \ rm -rf /tmp/*; \ done +RUN ln -sf /usr/local/python-3.12.7/bin/python3 /usr/bin/python3 && \ + ln -sf /usr/local/python-3.12.7/bin/python3 /usr/bin/python + +ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PYTHONWARNINGS=ignore # Install pandas and numpy on python 3.12 -# After Python installs RUN set -xe && \ - /usr/local/python-3.12.7/bin/python3 -m ensurepip && \ - /usr/local/python-3.12.7/bin/pip3 install --no-cache-dir pandas numpy + python3 -m ensurepip && \ + pip3 install --no-cache-dir pandas numpy # Check for latest version here: https://jdk.java.net RUN set -xe && \ From 3be71d5bab155a82625c3a6d9fbcc6cccbd9e28e Mon Sep 17 00:00:00 2001 From: Prayuj Tuli Date: Sun, 29 Jun 2025 15:37:41 -0400 Subject: [PATCH 05/16] fix: symlinking pip3 to bin --- Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f2b899..6d329d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,8 +68,11 @@ RUN set -xe && \ rm -rf /tmp/*; \ done +# Make Python 3.12.7 the default globally RUN ln -sf /usr/local/python-3.12.7/bin/python3 /usr/bin/python3 && \ - ln -sf /usr/local/python-3.12.7/bin/python3 /usr/bin/python + ln -sf /usr/local/python-3.12.7/bin/python3 /usr/bin/python && \ + ln -sf /usr/local/python-3.12.7/bin/pip3 /usr/bin/pip3 && \ + ln -sf /usr/local/python-3.12.7/bin/pip3 /usr/bin/pip ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ PYTHONWARNINGS=ignore @@ -190,4 +193,4 @@ RUN set -xe && \ ENV BOX_ROOT /var/local/lib/isolate LABEL maintainer="edugatorlabs " -LABEL version="0.0.1" \ No newline at end of file +LABEL version="0.0.1" From ff022b9fbd227d59d9301e870a867250a4a73e53 Mon Sep 17 00:00:00 2001 From: Prayuj Tuli Date: Sun, 29 Jun 2025 17:18:56 -0400 Subject: [PATCH 06/16] feat: switching to pre-compiled node install --- Dockerfile | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6d329d9..b373366 100644 --- a/Dockerfile +++ b/Dockerfile @@ -113,18 +113,16 @@ ENV NODE_VERSIONS \ 22.12.0 RUN set -xe && \ for VERSION in $NODE_VERSIONS; do \ - curl -fSsL "https://nodejs.org/dist/v$VERSION/node-v$VERSION.tar.gz" -o /tmp/node-$VERSION.tar.gz && \ - mkdir /tmp/node-$VERSION && \ - tar -xf /tmp/node-$VERSION.tar.gz -C /tmp/node-$VERSION --strip-components=1 && \ - rm /tmp/node-$VERSION.tar.gz && \ - cd /tmp/node-$VERSION && \ - ./configure \ - --prefix=/usr/local/node-$VERSION && \ - make -j$(nproc) && \ - make -j$(nproc) install && \ - rm -rf /tmp/*; \ + curl -fSsL "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" -o /tmp/node.tar.xz && \ + mkdir -p /usr/local/node-$NODE_VERSION && \ + tar -xf /tmp/node.tar.xz -C /usr/local/node-$NODE_VERSION --strip-components=1 && \ + rm /tmp/node.tar.xz done +RUN ln -s /usr/local/node-22.12.0/bin/node /usr/bin/node && \ + ln -s /usr/local/node-22.12.0/bin/npm /usr/bin/npm && \ + ln -s /usr/local/node-22.12.0/bin/npx /usr/bin/npx + # Check for latest version here: https://www.rust-lang.org ENV RUST_VERSIONS \ 1.83.0 From 3b6d2bc45c6888455157653747fea1470b928150 Mon Sep 17 00:00:00 2001 From: Prayuj Tuli Date: Sun, 29 Jun 2025 17:21:29 -0400 Subject: [PATCH 07/16] fix: adjusting typo in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b373366..025f7cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -116,7 +116,7 @@ RUN set -xe && \ curl -fSsL "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" -o /tmp/node.tar.xz && \ mkdir -p /usr/local/node-$NODE_VERSION && \ tar -xf /tmp/node.tar.xz -C /usr/local/node-$NODE_VERSION --strip-components=1 && \ - rm /tmp/node.tar.xz + rm /tmp/node.tar.xz; \ done RUN ln -s /usr/local/node-22.12.0/bin/node /usr/bin/node && \ From f9d6d210ed9c4e7799ec11bcd69febce840b1367 Mon Sep 17 00:00:00 2001 From: Prayuj Tuli Date: Sun, 29 Jun 2025 19:03:12 -0400 Subject: [PATCH 08/16] fix(Dockerfile): adjusting incorrect var name --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 025f7cb..eb893c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -113,9 +113,9 @@ ENV NODE_VERSIONS \ 22.12.0 RUN set -xe && \ for VERSION in $NODE_VERSIONS; do \ - curl -fSsL "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" -o /tmp/node.tar.xz && \ - mkdir -p /usr/local/node-$NODE_VERSION && \ - tar -xf /tmp/node.tar.xz -C /usr/local/node-$NODE_VERSION --strip-components=1 && \ + curl -fSsL "https://nodejs.org/dist/v$VERSION/node-v$VERSION-linux-x64.tar.xz" -o /tmp/node.tar.xz && \ + mkdir -p /usr/local/node-$VERSION && \ + tar -xf /tmp/node.tar.xz -C /usr/local/node-$VERSION --strip-components=1 && \ rm /tmp/node.tar.xz; \ done From 790aa5b1400c36467d94f2efc17a2e2df254e6e1 Mon Sep 17 00:00:00 2001 From: Prayuj Tuli Date: Mon, 30 Jun 2025 18:08:10 -0400 Subject: [PATCH 09/16] feat: adding pre-compiled catch2 header library --- Dockerfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Dockerfile b/Dockerfile index eb893c0..3dec0e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -166,6 +166,13 @@ RUN set -xe && \ mkdir -p /usr/local/include/catch2 && \ wget https://raw.githubusercontent.com/catchorg/Catch2/refs/tags/v2.13.8/single_include/catch2/catch.hpp -P /usr/local/include/catch2 +# Precompile test_main.cpp to speed up test builds +RUN set -xe && \ + echo '#define CATCH_CONFIG_MAIN' > /tmp/test_main.cpp && \ + echo '#include ' >> /tmp/test_main.cpp && \ + g++ -std=c++17 -O2 -c /tmp/test_main.cpp -o /usr/local/lib/libcatch2_main.o && \ + rm /tmp/test_main.cpp + RUN set -xe && \ mkdir -p /usr/local/junit && \ wget https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar -P /usr/local/junit && \ From 0b5a24050db4fa96d70c00e27175d0dcc4c88ed7 Mon Sep 17 00:00:00 2001 From: Prayuj Tuli Date: Mon, 30 Jun 2025 18:54:01 -0400 Subject: [PATCH 10/16] refactor: handling catch2 exit code --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3dec0e9..a06af00 100644 --- a/Dockerfile +++ b/Dockerfile @@ -168,8 +168,9 @@ RUN set -xe && \ # Precompile test_main.cpp to speed up test builds RUN set -xe && \ - echo '#define CATCH_CONFIG_MAIN' > /tmp/test_main.cpp && \ + echo '#define CATCH_CONFIG_RUNNER' > /tmp/test_main.cpp && \ echo '#include ' >> /tmp/test_main.cpp && \ + echo 'int main(int argc, char* argv[]) { Catch::Session().run(argc, argv); return 0; }' >> /tmp/test_main.cpp && \ g++ -std=c++17 -O2 -c /tmp/test_main.cpp -o /usr/local/lib/libcatch2_main.o && \ rm /tmp/test_main.cpp From 655bf45e428c2048e3724be3d4937c14651fc248 Mon Sep 17 00:00:00 2001 From: Marc Diaz Date: Thu, 2 Oct 2025 23:09:27 -0400 Subject: [PATCH 11/16] update dep packs --- Dockerfile | 4 +--- slim/Dockerfile | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index a06af00..183df2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,4 @@ -# Check for latest version here: https://hub.docker.com/_/buildpack-deps?tab=tags&page=1&name=buster&ordering=last_updated -# This is just a snapshot of buildpack-deps:buster that was last updated on 2019-12-28. -FROM judge0/buildpack-deps:buster-2019-12-28 +FROM buildpack-deps:bookworm # Check for latest version here: https://gcc.gnu.org/releases.html, https://ftpmirror.gnu.org/gcc # build image comes with gcc and g++ 8.3.0 by default diff --git a/slim/Dockerfile b/slim/Dockerfile index cd52717..7f02957 100644 --- a/slim/Dockerfile +++ b/slim/Dockerfile @@ -1,6 +1,4 @@ -# Check for latest version here: https://hub.docker.com/_/buildpack-deps?tab=tags&page=1&name=buster&ordering=last_updated -# This is just a snapshot of buildpack-deps:buster that was last updated on 2019-12-28. -FROM judge0/buildpack-deps:buster-2019-12-28 +FROM buildpack-deps:bookworm # Check for latest version here: https://www.ruby-lang.org/en/downloads ENV RUBY_VERSIONS \ From 8b29a738b03e40ee2a74059c5609b0e2b49fb8e3 Mon Sep 17 00:00:00 2001 From: Marc Diaz Date: Thu, 2 Oct 2025 23:13:09 -0400 Subject: [PATCH 12/16] add: fix --- .github/workflows/buildOrPublish.yml | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/buildOrPublish.yml diff --git a/.github/workflows/buildOrPublish.yml b/.github/workflows/buildOrPublish.yml new file mode 100644 index 0000000..57a4bb1 --- /dev/null +++ b/.github/workflows/buildOrPublish.yml @@ -0,0 +1,50 @@ +name: Build Judge0 Compilers Image + +on: + workflow_dispatch: + inputs: + publish: + description: "Publish to ECR?" + required: false + default: "false" + +env: + ACCOUNT_ID: 990066513532 + AWS_REGION: us-east-1 + ECR_REPO: edugatorlabs/judge0-compilers + PIPELINE_ID: ${{ github.run_id }}-${{ github.run_number }} + +permissions: + id-token: write + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Configure AWS Credentials (only if publishing) + if: ${{ github.event.inputs.publish == 'true' }} + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/GitHubDeploymentRole + aws-region: ${{ env.AWS_REGION }} + + - name: Log in to Amazon ECR (only if publishing) + if: ${{ github.event.inputs.publish == 'true' }} + run: | + aws ecr get-login-password --region ${{ env.AWS_REGION }} \ + | docker login --username AWS --password-stdin ${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com + + - name: Build Docker image + run: | + IMAGE_URI=${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:${{ env.PIPELINE_ID }} + docker build -t $IMAGE_URI . + echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV + + - name: Push Docker image to ECR (only if publishing) + if: ${{ github.event.inputs.publish == 'true' }} + run: | + docker push $IMAGE_URI \ No newline at end of file From 8fdaafac05950377e5ebcb093aa27e218fc26598 Mon Sep 17 00:00:00 2001 From: Marc Diaz Date: Thu, 2 Oct 2025 23:14:50 -0400 Subject: [PATCH 13/16] rename --- .github/workflows/buildOrPublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildOrPublish.yml b/.github/workflows/buildOrPublish.yml index 57a4bb1..d07ed01 100644 --- a/.github/workflows/buildOrPublish.yml +++ b/.github/workflows/buildOrPublish.yml @@ -1,4 +1,4 @@ -name: Build Judge0 Compilers Image +name: Build Judge0 Compilers Image (or Publish to ECR) on: workflow_dispatch: From 8050e7f85e4f3340925a99ac6344b9829e95f2c1 Mon Sep 17 00:00:00 2001 From: Marc Diaz Date: Thu, 2 Oct 2025 23:21:13 -0400 Subject: [PATCH 14/16] chore: update to just one yml --- .github/workflows/build.yml | 24 +++++++++---- .github/workflows/buildOrPublish.yml | 50 ---------------------------- 2 files changed, 18 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/buildOrPublish.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 28eb7a2..cbbc4e0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,12 @@ name: Build Judge0 Compilers Image on: + workflow_dispatch: + inputs: + publish: + description: "Publish to ECR?" + required: false + default: "false" release: types: [published] @@ -15,26 +21,32 @@ permissions: contents: read jobs: - deploy: + build: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 - - name: Configure AWS Credentials + - name: Configure AWS Credentials (only if publishing) + if: ${{ github.event_name == 'release' || github.event.inputs.publish == 'true' }} uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/GitHubDeploymentRole aws-region: ${{ env.AWS_REGION }} - - name: Log in to Amazon ECR + - name: Log in to Amazon ECR (only if publishing) + if: ${{ github.event_name == 'release' || github.event.inputs.publish == 'true' }} run: | aws ecr get-login-password --region ${{ env.AWS_REGION }} \ | docker login --username AWS --password-stdin ${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com - - name: Build, Tag, and Push Docker image to ECR + - name: Build Docker image run: | IMAGE_URI=${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:${{ env.PIPELINE_ID }} docker build -t $IMAGE_URI . - docker push $IMAGE_URI - echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV \ No newline at end of file + echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV + + - name: Push Docker image to ECR (only if publishing) + if: ${{ github.event_name == 'release' || github.event.inputs.publish == 'true' }} + run: | + docker push $IMAGE_URI \ No newline at end of file diff --git a/.github/workflows/buildOrPublish.yml b/.github/workflows/buildOrPublish.yml deleted file mode 100644 index d07ed01..0000000 --- a/.github/workflows/buildOrPublish.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build Judge0 Compilers Image (or Publish to ECR) - -on: - workflow_dispatch: - inputs: - publish: - description: "Publish to ECR?" - required: false - default: "false" - -env: - ACCOUNT_ID: 990066513532 - AWS_REGION: us-east-1 - ECR_REPO: edugatorlabs/judge0-compilers - PIPELINE_ID: ${{ github.run_id }}-${{ github.run_number }} - -permissions: - id-token: write - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Configure AWS Credentials (only if publishing) - if: ${{ github.event.inputs.publish == 'true' }} - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/GitHubDeploymentRole - aws-region: ${{ env.AWS_REGION }} - - - name: Log in to Amazon ECR (only if publishing) - if: ${{ github.event.inputs.publish == 'true' }} - run: | - aws ecr get-login-password --region ${{ env.AWS_REGION }} \ - | docker login --username AWS --password-stdin ${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com - - - name: Build Docker image - run: | - IMAGE_URI=${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:${{ env.PIPELINE_ID }} - docker build -t $IMAGE_URI . - echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV - - - name: Push Docker image to ECR (only if publishing) - if: ${{ github.event.inputs.publish == 'true' }} - run: | - docker push $IMAGE_URI \ No newline at end of file From 52ae80cceeed1c0e07cc3c36aeabd5f9bb39a015 Mon Sep 17 00:00:00 2001 From: Marc Diaz Date: Fri, 3 Oct 2025 10:43:50 -0400 Subject: [PATCH 15/16] fix: use different versions of ruby + use slim file --- .github/workflows/build.yml | 19 +++++++++++++++++-- slim/Dockerfile | 15 +++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cbbc4e0..b539c9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,10 @@ on: description: "Publish to ECR?" required: false default: "false" + variant: + description: "Which Docker variant to build (default: full, slim: slim/Dockerfile)" + required: false + default: "full" release: types: [published] @@ -42,8 +46,19 @@ jobs: - name: Build Docker image run: | - IMAGE_URI=${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:${{ env.PIPELINE_ID }} - docker build -t $IMAGE_URI . + # Determine Dockerfile and image tag + if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.variant }}" == "slim" ]]; then + DOCKERFILE_PATH=slim/Dockerfile + IMAGE_TAG=slim-${{ env.PIPELINE_ID }} + else + DOCKERFILE_PATH=Dockerfile + IMAGE_TAG=${{ env.PIPELINE_ID }} + fi + + IMAGE_URI=${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:$IMAGE_TAG + + echo "Building Docker image from $DOCKERFILE_PATH..." + docker build -f $DOCKERFILE_PATH -t $IMAGE_URI . echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV - name: Push Docker image to ECR (only if publishing) diff --git a/slim/Dockerfile b/slim/Dockerfile index 7f02957..db47aae 100644 --- a/slim/Dockerfile +++ b/slim/Dockerfile @@ -1,8 +1,19 @@ FROM buildpack-deps:bookworm +RUN apt-get update && apt-get install -y --no-install-recommends \ + libssl-dev \ + libreadline-dev \ + zlib1g-dev \ + libyaml-dev \ + libffi-dev \ + bison \ + libgdbm-dev \ + libncurses-dev \ + && rm -rf /var/lib/apt/lists/* + # Check for latest version here: https://www.ruby-lang.org/en/downloads -ENV RUBY_VERSIONS \ - 2.7.0 +ENV RUBY_VERSIONS="2.7.8 3.3.5" + RUN set -xe && \ for VERSION in $RUBY_VERSIONS; do \ curl -fSsL "https://cache.ruby-lang.org/pub/ruby/$%7BVERSION%.*%7D/ruby-$VERSION.tar.gz" -o /tmp/ruby-$VERSION.tar.gz && \ From 42a95cfeb37ffbbcea73543936e6cc5ae9e08494 Mon Sep 17 00:00:00 2001 From: Marc Diaz Date: Fri, 3 Oct 2025 11:20:47 -0400 Subject: [PATCH 16/16] fix: main dockerfile --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 183df2c..83d76e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,8 +26,7 @@ RUN set -xe && \ done # Check for latest version here: https://www.ruby-lang.org/en/downloads -ENV RUBY_VERSIONS \ - 2.7.0 +ENV RUBY_VERSIONS="2.7.8 3.3.5" RUN set -xe && \ for VERSION in $RUBY_VERSIONS; do \ curl -fSsL "https://cache.ruby-lang.org/pub/ruby/$%7BVERSION%.*%7D/ruby-$VERSION.tar.gz" -o /tmp/ruby-$VERSION.tar.gz && \