|
| 1 | +# Multistage docker file for problemtools |
| 2 | +# |
| 3 | +# Expected to be built with a build context which is the root of a checkout of problemtools |
| 4 | +# Overview of steps: |
| 5 | +# |
| 6 | +# We have 4 targets which are only used locally in the build process, and are not |
| 7 | +# uploaded to a repository. |
| 8 | +# - `runreqs`: Base image containing just the things needed to run problemtools |
| 9 | +# - `build`: Base image which builds a deb, contained in /deb/kattis-problemtools*.deb |
| 10 | +# - `icpclangs`: Base image containing what is needed to run problemtools, plus the "ICPC languages" |
| 11 | +# - `fulllangs`: Base image containing what is needed to run problemtools, plus all supported languages |
| 12 | +# |
| 13 | +# We have 3 targets which are meant for end users: |
| 14 | +# - `minimal`: Image with problemtools installed, but no languages. |
| 15 | +# - `icpc`: Image with problemtools plus the "ICPC languages" installed. |
| 16 | +# - `full`: Image with problemtools and all languages |
| 17 | +# |
| 18 | +# We have 1 image which is used in our CI (to speed up things - it takes a few |
| 19 | +# minutes to apt-get install all languages and runtime requirements): |
| 20 | +# - `githubci`: Image with all languages and everything needed to build a deb and run problemtools |
| 21 | +# |
| 22 | +# Build dependencies: |
| 23 | +# ``` |
| 24 | +# runreqs -> icpclangs -> fullangs -> githubci |
| 25 | +# / \ | | |
| 26 | +# build minimal icpc full |
| 27 | +# ``` |
| 28 | + |
| 29 | +FROM ubuntu:24.04 AS runreqs |
| 30 | + |
| 31 | +LABEL org.opencontainers.image.authors="contact@kattis.com" |
| 32 | +ENV DEBIAN_FRONTEND=noninteractive |
| 33 | + |
| 34 | +# Packages required to build and run problemtools |
| 35 | +# For libgmp, we technically just need libgmpxx4ldbl here, but for readability |
| 36 | +# (and since we need libgmp-dev in other images), we take libgmp-dev here |
| 37 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 38 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 39 | + rm -f /etc/apt/apt.conf.d/docker-clean && \ |
| 40 | + apt-get update && apt-get install -y \ |
| 41 | + dvisvgm \ |
| 42 | + ghostscript \ |
| 43 | + libgmp-dev \ |
| 44 | + pandoc \ |
| 45 | + python3 \ |
| 46 | + python3-venv \ |
| 47 | + texlive-fonts-recommended \ |
| 48 | + texlive-lang-cyrillic \ |
| 49 | + texlive-latex-extra \ |
| 50 | + texlive-plain-generic \ |
| 51 | + tidy |
| 52 | + |
| 53 | + |
| 54 | +# ---------------------------------------------------------------------- |
| 55 | +# Docker image with the debian file (and a full source directory) in /deb |
| 56 | +FROM runreqs AS build |
| 57 | +ARG GITTAG=master |
| 58 | + |
| 59 | +# Packages required to build and run problemtools |
| 60 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 61 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 62 | + rm -f /etc/apt/apt.conf.d/docker-clean && \ |
| 63 | + apt-get update && apt-get install -y \ |
| 64 | + automake \ |
| 65 | + build-essential \ |
| 66 | + debhelper \ |
| 67 | + dh-virtualenv \ |
| 68 | + dpkg-dev \ |
| 69 | + g++ \ |
| 70 | + git \ |
| 71 | + make \ |
| 72 | + libboost-regex-dev |
| 73 | +RUN git config --global --add safe.directory /git/problemtools/.git |
| 74 | +RUN --mount=type=bind,target=/git/problemtools \ |
| 75 | + git clone --branch ${GITTAG} --recurse-submodules /git/problemtools /deb/problemtools |
| 76 | +RUN make -C /deb/problemtools builddeb |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +# ------------------------------------------------------------------------------ |
| 81 | +# Docker image with all packages needed to run a problemtools .deb, plus |
| 82 | +# language support for the "ICPC languages" (C, C++, Java, Kotlin, and Python 3) |
| 83 | + |
| 84 | +FROM runreqs AS icpclangs |
| 85 | + |
| 86 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 87 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 88 | + rm -f /etc/apt/apt.conf.d/docker-clean && \ |
| 89 | + apt-get update && apt-get install -y \ |
| 90 | + gcc \ |
| 91 | + g++ \ |
| 92 | + kotlin \ |
| 93 | + openjdk-21-jdk \ |
| 94 | + openjdk-21-jre \ |
| 95 | + pypy3 |
| 96 | + |
| 97 | +# ---------------------------------------------------------------------- |
| 98 | +# Docker image with all packages needed to run a problemtools .deb, plus |
| 99 | +# language support for all supported languages |
| 100 | + |
| 101 | +FROM icpclangs AS fulllangs |
| 102 | + |
| 103 | +# All languages, plus curl which we need to fetch pypy2 |
| 104 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 105 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 106 | + rm -f /etc/apt/apt.conf.d/docker-clean && \ |
| 107 | + apt-get update && apt-get install -y \ |
| 108 | + curl \ |
| 109 | + fp-compiler \ |
| 110 | + gfortran \ |
| 111 | + gnucobol \ |
| 112 | + gccgo \ |
| 113 | + ghc \ |
| 114 | + gnustep-devel gnustep gnustep-make gnustep-common gobjc \ |
| 115 | + lua5.4 \ |
| 116 | + mono-complete \ |
| 117 | + nodejs \ |
| 118 | + ocaml-nox \ |
| 119 | + php-cli \ |
| 120 | + rustc \ |
| 121 | + sbcl \ |
| 122 | + scala \ |
| 123 | + swi-prolog |
| 124 | + |
| 125 | +# pypy2 is no longer packaged for Ubuntu, so download tarball (and check a sha256) |
| 126 | +RUN curl -LO https://downloads.python.org/pypy/pypy2.7-v7.3.16-linux64.tar.bz2 \ |
| 127 | + && echo '04b2fceb712d6f811274825b8a471ee392d3d1b53afc83eb3f42439ce00d8e07 pypy2.7-v7.3.16-linux64.tar.bz2' | sha256sum --check \ |
| 128 | + && tar -xf pypy2.7-v7.3.16-linux64.tar.bz2 \ |
| 129 | + && mv pypy2.7-v7.3.16-linux64 /opt/pypy \ |
| 130 | + && ln -s /opt/pypy/bin/pypy /usr/bin/pypy \ |
| 131 | + && rm pypy2.7-v7.3.16-linux64.tar.bz2 |
| 132 | + |
| 133 | + |
| 134 | +# --------------------------------------------------------------- |
| 135 | +# Docker image with all deb packages needed for our github actions |
| 136 | +# - Building a problemtools deb |
| 137 | +# - Running verifyproblem on all examples |
| 138 | + |
| 139 | +FROM fulllangs AS githubci |
| 140 | + |
| 141 | +# Packages required to build and run problemtools |
| 142 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 143 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 144 | + rm -f /etc/apt/apt.conf.d/docker-clean && \ |
| 145 | + apt-get update && apt-get install -y \ |
| 146 | + automake \ |
| 147 | + build-essential \ |
| 148 | + debhelper \ |
| 149 | + dh-virtualenv \ |
| 150 | + dpkg-dev \ |
| 151 | + git \ |
| 152 | + make \ |
| 153 | + libboost-regex-dev |
| 154 | + |
| 155 | + |
| 156 | +# ----------------------------------------------------- |
| 157 | +# Docker image with problemtools and no extra languages |
| 158 | +FROM runreqs AS minimal |
| 159 | +RUN --mount=type=bind,from=build,source=/deb,target=/deb \ |
| 160 | + dpkg -i /deb/kattis-problemtools*.deb |
| 161 | + |
| 162 | +# ---------------------------------------------------------------- |
| 163 | +# Basic problemtools docker image, containing problemtools and the |
| 164 | +# "ICPC languages" (C, C++, Java, Kotlin, and Python 3) |
| 165 | + |
| 166 | +FROM icpclangs AS icpc |
| 167 | +RUN --mount=type=bind,from=build,source=/deb,target=/deb \ |
| 168 | + dpkg -i /deb/kattis-problemtools*.deb |
| 169 | + |
| 170 | +# ---------------------------------------------------------------- |
| 171 | +# Full problemtools docker image, containing problemtools and all |
| 172 | +# supported programming languages. |
| 173 | + |
| 174 | +FROM fulllangs AS full |
| 175 | +RUN --mount=type=bind,from=build,source=/deb,target=/deb \ |
| 176 | + dpkg -i /deb/kattis-problemtools*.deb |
| 177 | + |
0 commit comments