Skip to content

Commit 6f70615

Browse files
authored
Merge pull request #321 from gkreitz/restructure_docker_build
Restructure docker build
2 parents cae4199 + d86f384 commit 6f70615

File tree

11 files changed

+243
-177
lines changed

11 files changed

+243
-177
lines changed

Dockerfile

Lines changed: 0 additions & 31 deletions
This file was deleted.

admin/docker/Dockerfile.build

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,24 @@
1-
# Package for building the problemtools .deb package
2-
# Ends up in the /usr/local/problemtools_build/deb/ directory
1+
# Docker image with all packages needed to build a problemtools .deb
32
#
4-
# Setting build argument PROBLEMTOOLS_VERSION causes a specific
5-
# version of problemtools to be built (default is latest version of
6-
# develop branch on GitHub)
3+
# Not uploaded anywhere, only used locally during building
74

8-
FROM ubuntu:22.04
9-
10-
LABEL maintainer="austrin@kattis.com"
5+
ARG PROBLEMTOOLS_VERSION=develop
6+
FROM problemtools/runreqs:${PROBLEMTOOLS_VERSION}
117

8+
LABEL maintainer="contact@kattis.com"
129
ENV DEBIAN_FRONTEND=noninteractive
1310

14-
# Install packages needed for build
15-
RUN apt update && \
16-
apt install -y \
11+
# Packages required to build and run problemtools
12+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
13+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
14+
rm -f /etc/apt/apt.conf.d/docker-clean \
15+
apt-get update && apt-get install -y \
1716
automake \
17+
build-essential \
1818
debhelper \
19-
dh-python \
19+
dh-virtualenv \
2020
dpkg-dev \
2121
g++ \
2222
git \
2323
make \
24-
libboost-regex-dev \
25-
libgmp-dev \
26-
libgmp10 \
27-
libgmpxx4ldbl \
28-
pandoc \
29-
python3 \
30-
python3-pytest \
31-
python3-setuptools \
32-
python3-yaml \
33-
python3-setuptools
34-
35-
RUN mkdir -p /usr/local/problemtools_build
36-
37-
WORKDIR /usr/local/problemtools_build
38-
RUN git clone --recursive https://github.com/kattis/problemtools
39-
40-
ARG PROBLEMTOOLS_VERSION=develop
41-
RUN cd problemtools && git checkout ${PROBLEMTOOLS_VERSION} && make builddeb
42-
43-
RUN mkdir -p deb
44-
RUN mv kattis-problemtools*.deb deb/
24+
libboost-regex-dev

admin/docker/Dockerfile.full

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
11
# Full problemtools docker image, containing problemtools and all
22
# supported programming languages.
33
#
4+
#
5+
# Build requirements:
6+
# - The problemtools .deb package must be available from the host file
7+
# system under a file name matching
8+
# artifacts/deb/kattis-problemtools*.deb
9+
# (Version of that .deb file should match the build argument
10+
# PROBLEMTOOLS_VERSION but this is not checked.)
411

512
ARG PROBLEMTOOLS_VERSION=develop
6-
FROM problemtools/icpc:${PROBLEMTOOLS_VERSION}
7-
8-
LABEL maintainer="austrin@kattis.com"
13+
FROM problemtools/runreqs:${PROBLEMTOOLS_VERSION}
914

15+
LABEL maintainer="contact@kattis.com"
1016
ENV DEBIAN_FRONTEND=noninteractive
1117

12-
RUN apt-get update && \
13-
apt-get install -y \
14-
fp-compiler \
15-
gfortran \
16-
gnucobol \
17-
gccgo \
18-
ghc haskell-platform \
19-
gnustep-devel gnustep gnustep-make gnustep-common gobjc \
20-
libgmp3-dev \
21-
libmozjs-78-dev \
22-
lua5.4 \
23-
mono-complete \
24-
nodejs \
25-
ocaml-nox \
26-
pandoc \
27-
php-cli \
28-
pypy \
29-
rustc \
30-
sbcl \
31-
scala \
32-
swi-prolog \
33-
;
18+
RUN mkdir -p /usr/local/artifacts
19+
WORKDIR /usr/local/artifacts
20+
COPY artifacts/deb .
21+
RUN dpkg -i kattis-problemtools*.deb
22+
23+
WORKDIR /

admin/docker/Dockerfile.fulllangs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Docker image with all packages needed to run a problemtools .deb, plus
2+
# language support for all supported languages
3+
#
4+
# Not uploaded anywhere, only used locally during building
5+
6+
ARG PROBLEMTOOLS_VERSION=develop
7+
FROM problemtools/icpclangs:${PROBLEMTOOLS_VERSION}
8+
9+
LABEL maintainer="contact@kattis.com"
10+
ENV DEBIAN_FRONTEND=noninteractive
11+
12+
# All languages, plus curl which we need to fetch pypy2
13+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
14+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
15+
rm -f /etc/apt/apt.conf.d/docker-clean \
16+
apt-get update && apt-get install -y \
17+
curl \
18+
fp-compiler \
19+
gfortran \
20+
gnucobol \
21+
gccgo \
22+
ghc \
23+
gnustep-devel gnustep gnustep-make gnustep-common gobjc \
24+
lua5.4 \
25+
mono-complete \
26+
nodejs \
27+
ocaml-nox \
28+
php-cli \
29+
rustc \
30+
sbcl \
31+
scala \
32+
swi-prolog
33+
34+
# pypy2 is no longer packaged for Ubuntu, so download tarball (and check a sha256)
35+
RUN curl -LO https://downloads.python.org/pypy/pypy2.7-v7.3.16-linux64.tar.bz2 \
36+
&& echo '04b2fceb712d6f811274825b8a471ee392d3d1b53afc83eb3f42439ce00d8e07 pypy2.7-v7.3.16-linux64.tar.bz2' | sha256sum --check \
37+
&& tar -xf pypy2.7-v7.3.16-linux64.tar.bz2 \
38+
&& mv pypy2.7-v7.3.16-linux64 /opt/pypy \
39+
&& ln -s /opt/pypy/bin/pypy /usr/bin/pypy \
40+
&& rm pypy2.7-v7.3.16-linux64.tar.bz2

admin/docker/Dockerfile.githubci

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Docker image with all deb packages needed for our github actions
2+
# - Building a problemtools deb
3+
# - Running verifyproblem on all examples
4+
5+
ARG PROBLEMTOOLS_VERSION=develop
6+
FROM problemtools/fulllangs:${PROBLEMTOOLS_VERSION}
7+
8+
LABEL maintainer="contact@kattis.com"
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# Packages required to build and run problemtools
12+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
13+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
14+
rm -f /etc/apt/apt.conf.d/docker-clean \
15+
apt-get update && apt-get install -y \
16+
automake \
17+
build-essential \
18+
debhelper \
19+
dh-virtualenv \
20+
dpkg-dev \
21+
git \
22+
make \
23+
libboost-regex-dev

admin/docker/Dockerfile.icpc

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,22 @@
11
# Basic problemtools docker image, containing problemtools and the
22
# "ICPC languages" (C, C++, Java, Kotlin, and Python 3)
33
#
4+
# Build requirements:
5+
# - The problemtools .deb package must be available from the host file
6+
# system under a file name matching
7+
# artifacts/deb/kattis-problemtools*.deb
8+
# (Version of that .deb file should match the build argument
9+
# PROBLEMTOOLS_VERSION but this is not checked.)
410

511
ARG PROBLEMTOOLS_VERSION=develop
6-
FROM problemtools/minimal:${PROBLEMTOOLS_VERSION}
7-
8-
LABEL maintainer="austrin@kattis.com"
12+
FROM problemtools/icpclangs:${PROBLEMTOOLS_VERSION}
913

14+
LABEL maintainer="contact@kattis.com"
1015
ENV DEBIAN_FRONTEND=noninteractive
1116

12-
# Install C++, Java, and PyPy 3 via their ppa repository (Kotlin is installed below to get a more up-to-date version)
13-
RUN apt-get update && \
14-
apt-get install -y software-properties-common && \
15-
add-apt-repository ppa:pypy/ppa && \
16-
apt-get update && \
17-
apt-get install -y \
18-
gcc g++ \
19-
openjdk-11-jdk openjdk-11-jre \
20-
pypy3
21-
22-
RUN apt-get install -y curl
23-
24-
ARG KOTLIN_VERSION=1.8.10
25-
RUN curl "https://github.com/JetBrains/kotlin/releases/download/v$KOTLIN_VERSION/kotlin-compiler-$KOTLIN_VERSION.zip" -L -o kotlin.zip
26-
RUN unzip -q kotlin.zip
27-
RUN rm kotlin.zip
28-
29-
RUN mv kotlinc/bin/* /usr/bin
30-
RUN mv kotlinc/lib/* /usr/lib
31-
32-
RUN rm -r kotlinc
33-
34-
# Reconfigure problemtools:
35-
# - Use PyPy for Python 2 (not available in this image but in the full one)
36-
# - Use PyPy for Python 3
37-
RUN mkdir -p /etc/kattis/problemtools
38-
RUN echo " \n\
39-
python2: \n\
40-
name: 'Python 2 w/PyPy'\n\
41-
run: '/usr/bin/pypy \"{mainfile}\"'\n\
42-
\n\
43-
python3: \n\
44-
name: 'Python 3 w/PyPy'\n\
45-
run: '/usr/bin/pypy3 \"{mainfile}\"'\n\
46-
\n" > /etc/kattis/problemtools/languages.yaml
17+
RUN mkdir -p /usr/local/artifacts
18+
WORKDIR /usr/local/artifacts
19+
COPY artifacts/deb .
20+
RUN dpkg -i kattis-problemtools*.deb
4721

4822
WORKDIR /

admin/docker/Dockerfile.icpclangs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Docker image with all packages needed to run a problemtools .deb, plus
2+
# language support for the "ICPC languages" (C, C++, Java, Kotlin, and Python 3)
3+
#
4+
# Not uploaded anywhere, only used locally during building
5+
6+
ARG PROBLEMTOOLS_VERSION=develop
7+
FROM problemtools/runreqs:${PROBLEMTOOLS_VERSION}
8+
9+
LABEL maintainer="contact@kattis.com"
10+
ENV DEBIAN_FRONTEND=noninteractive
11+
12+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
13+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
14+
rm -f /etc/apt/apt.conf.d/docker-clean \
15+
apt-get update && apt-get install -y \
16+
gcc \
17+
g++ \
18+
kotlin \
19+
openjdk-21-jdk \
20+
openjdk-21-jre \
21+
pypy3

admin/docker/Dockerfile.minimal

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,11 @@
1010
# PROBLEMTOOLS_VERSION but this is not checked.)
1111

1212
ARG PROBLEMTOOLS_VERSION=develop
13-
FROM ubuntu:22.04
14-
15-
LABEL maintainer="austrin@kattis.com"
13+
FROM problemtools/runreqs:${PROBLEMTOOLS_VERSION}
1614

15+
LABEL maintainer="contact@kattis.com"
1716
ENV DEBIAN_FRONTEND=noninteractive
1817

19-
RUN apt update && \
20-
apt install -y \
21-
ghostscript \
22-
libgmpxx4ldbl \
23-
pandoc \
24-
python-pkg-resources \
25-
python3-minimal \
26-
python3-yaml \
27-
python3-plastex \
28-
texlive-fonts-recommended \
29-
texlive-lang-cyrillic \
30-
texlive-latex-extra \
31-
texlive-plain-generic \
32-
tidy
33-
3418
RUN mkdir -p /usr/local/artifacts
3519
WORKDIR /usr/local/artifacts
3620
COPY artifacts/deb .

admin/docker/Dockerfile.runreqs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Docker image with all packages needed to run a problemtools .deb
2+
#
3+
# Not uploaded anywhere, only used locally during building
4+
5+
ARG PROBLEMTOOLS_VERSION=develop
6+
FROM ubuntu:24.04
7+
8+
LABEL maintainer="contact@kattis.com"
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# Packages required to build and run problemtools
12+
# For libgmp, we technically just need libgmpxx4ldbl here, but for readability
13+
# (and we need libgmp-dev in other images), we take libgmp-dev here
14+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
15+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
16+
rm -f /etc/apt/apt.conf.d/docker-clean \
17+
apt-get update && apt-get install -y \
18+
dvisvgm \
19+
ghostscript \
20+
libgmp-dev \
21+
pandoc \
22+
python3 \
23+
python3-venv \
24+
texlive-fonts-recommended \
25+
texlive-lang-cyrillic \
26+
texlive-latex-extra \
27+
texlive-plain-generic \
28+
tidy

admin/docker/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Our docker images. Note that images depend on each other, please use the script
2+
admin/update_docker.sh to build images in the correct order.
3+
4+
We have 4 images which are only used locally in the build process, and are not
5+
uploaded to a repository.
6+
- `runreqs`: Base image containing just the things needed to run problemtools
7+
- `build`: Base image containing just the things needed to build a deb and run problemtools
8+
- `icpclangs`: Base image containing what is needed to run problemtools, plus the "ICPC languages"
9+
- `fulllangs`: Base image containing what is needed to run problemtools, plus all supported languages
10+
11+
We have 3 images which are meant for end users:
12+
- `minimal`: Image with problemtools installed, but no languages.
13+
- `icpc`: Image with problemtools plus the "ICPC languages" installed.
14+
- `full`: Image with problemtools and all languages
15+
16+
We have 1 image which is used in our CI (to speed up things - it takes a few
17+
minutes to apt-get install all languages and runtime requirements):
18+
- `githubci`: Image with all languages and everything needed to build a deb and run problemtools
19+
20+
Build dependencies:
21+
```
22+
runreqs -> icpclangs -> fullangs -> githubci
23+
/ \ | |
24+
build minimal icpc full
25+
```

0 commit comments

Comments
 (0)