-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
317 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,317 @@ | ||
FROM ubuntu:22.04 | ||
|
||
ARG TARGETPLATFORM | ||
|
||
RUN apt-get update \ | ||
&& apt-get -y --no-install-recommends install \ | ||
grep \ | ||
libseccomp-dev \ | ||
libseccomp2 \ | ||
procps \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
# | ||
# Source: https://github.com/docker-library/python/blob/master/3.6/stretch/slim/Dockerfile | ||
# | ||
|
||
# ensure local python is preferred over distribution python | ||
ENV PATH /usr/local/bin:$PATH | ||
|
||
# http://bugs.python.org/issue19846 | ||
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. | ||
ENV LANG C.UTF-8 | ||
|
||
# runtime dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
netbase \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV GPG_KEY A821E680E5FA6305 | ||
ENV PYTHON_VERSION 3.12.1 | ||
|
||
RUN set -ex \ | ||
\ | ||
&& savedAptMark="$(apt-mark showmanual)" \ | ||
&& apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
dpkg-dev \ | ||
gcc \ | ||
libbz2-dev \ | ||
libc6-dev \ | ||
libexpat1-dev \ | ||
libffi-dev \ | ||
libgdbm-dev \ | ||
liblzma-dev \ | ||
libncursesw5-dev \ | ||
libreadline-dev \ | ||
libsqlite3-dev \ | ||
libssl-dev \ | ||
make \ | ||
tk-dev \ | ||
wget \ | ||
xz-utils \ | ||
zlib1g-dev \ | ||
# as of Stretch, "gpg" is no longer included by default | ||
$(command -v gpg > /dev/null || echo 'gnupg dirmngr') \ | ||
\ | ||
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ | ||
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ | ||
&& export GNUPGHOME="$(mktemp -d)" \ | ||
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY" \ | ||
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \ | ||
&& { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ | ||
&& rm -rf "$GNUPGHOME" python.tar.xz.asc \ | ||
&& mkdir -p /usr/src/python \ | ||
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ | ||
&& rm python.tar.xz \ | ||
\ | ||
&& cd /usr/src/python \ | ||
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ | ||
&& ./configure \ | ||
--build="$gnuArch" \ | ||
--enable-loadable-sqlite-extensions \ | ||
--enable-shared \ | ||
--with-system-expat \ | ||
--with-system-ffi \ | ||
--without-ensurepip \ | ||
&& make -j "$(nproc)" \ | ||
&& make install \ | ||
&& ldconfig \ | ||
\ | ||
&& apt-mark auto '.*' > /dev/null \ | ||
&& apt-mark manual $savedAptMark \ | ||
&& find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ | ||
| awk '/=>/ { print $(NF-1) }' \ | ||
| sort -u \ | ||
| xargs -r dpkg-query --search \ | ||
| cut -d: -f1 \ | ||
| sort -u \ | ||
| xargs -r apt-mark manual \ | ||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
\ | ||
&& find /usr/local -depth \ | ||
\( \ | ||
\( -type d -a \( -name test -o -name tests \) \) \ | ||
-o \ | ||
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ | ||
\) -exec rm -rf '{}' + \ | ||
&& rm -rf /usr/src/python \ | ||
\ | ||
&& python3 --version | ||
|
||
# make some useful symlinks that are expected to exist | ||
RUN cd /usr/local/bin \ | ||
&& ln -s idle3 idle \ | ||
&& ln -s pydoc3 pydoc \ | ||
&& ln -s python3 python \ | ||
&& ln -s python3-config python-config | ||
|
||
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" | ||
ENV PYTHON_PIP_VERSION 23.3.2 | ||
|
||
RUN set -ex; \ | ||
\ | ||
savedAptMark="$(apt-mark showmanual)"; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends wget; \ | ||
\ | ||
wget -O get-pip.py 'https://bootstrap.pypa.io/pip/get-pip.py'; \ | ||
\ | ||
apt-mark auto '.*' > /dev/null; \ | ||
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \ | ||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
\ | ||
python get-pip.py \ | ||
--disable-pip-version-check \ | ||
--no-cache-dir \ | ||
"pip==$PYTHON_PIP_VERSION" \ | ||
; \ | ||
pip --version; \ | ||
\ | ||
find /usr/local -depth \ | ||
\( \ | ||
\( -type d -a \( -name test -o -name tests \) \) \ | ||
-o \ | ||
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ | ||
\) -exec rm -rf '{}' +; \ | ||
rm -f get-pip.py; \ | ||
pip3 install aioconsole; \ | ||
pip3 uninstall --yes pip setuptools | ||
|
||
# Necessary as Submitty does path expansion of commands in compiling a homework, | ||
# and so resolves "python" -> "/usr/bin/python" | ||
RUN cd /usr/bin \ | ||
&& ln -s /usr/local/bin/python3 python3 \ | ||
&& ln -s /usr/local/bin/python3 python \ | ||
&& ln -s /usr/local/bin/pip3 pip3 \ | ||
&& ln -s /usr/local/bin/pip3 pip | ||
# | ||
# Source: https://github.com/docker-library/openjdk/blob/master/8/jdk/slim/Dockerfile | ||
# | ||
|
||
# A few reasons for installing distribution-provided OpenJDK: | ||
# | ||
# 1. Oracle. Licensing prevents us from redistributing the official JDK. | ||
# | ||
# 2. Compiling OpenJDK also requires the JDK to be installed, and it gets | ||
# really hairy. | ||
# | ||
# For some sample build times, see Debian's buildd logs: | ||
# https://buildd.debian.org/status/logs.php?pkg=openjdk-8 | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
bzip2 \ | ||
unzip \ | ||
xz-utils \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
# emacs \ | ||
nano \ | ||
vim \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
iproute2 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# add a simple script that can auto-detect the appropriate JAVA_HOME value | ||
# based on whether the JDK or only the JRE is installed | ||
RUN { \ | ||
echo '#!/bin/sh'; \ | ||
echo 'set -e'; \ | ||
echo; \ | ||
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \ | ||
} > /usr/local/bin/docker-java-home \ | ||
&& chmod +x /usr/local/bin/docker-java-home | ||
|
||
# do some fancy footwork to create a JAVA_HOME that's cross-architecture-safe | ||
RUN ln -svT "/usr/lib/jvm/java-11-openjdk-$(dpkg --print-architecture)" /docker-java-home | ||
ENV JAVA_HOME /docker-java-home | ||
|
||
# Look here to update: https://packages.ubuntu.com/jammy/openjdk-11-jdk-headless | ||
ENV JAVA_UBUNTU_VERSION 11.0.22+7-0ubuntu2~22.04.1 | ||
|
||
RUN set -ex; \ | ||
\ | ||
# deal with slim variants not having man page directories (which causes "update-alternatives" to fail) | ||
if [ ! -d /usr/share/man/man1 ]; then \ | ||
mkdir -p /usr/share/man/man1; \ | ||
fi; \ | ||
# ca-certificates-java does not work on src:openjdk-11 with no-install-recommends: (https://bugs.debian.org/914860, https://bugs.debian.org/775775) | ||
# /var/lib/dpkg/info/ca-certificates-java.postinst: line 56: java: command not found | ||
ln -svT /docker-java-home/bin/java /usr/local/bin/java; \ | ||
\ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
openjdk-11-jdk-headless="$JAVA_UBUNTU_VERSION" \ | ||
; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
\ | ||
rm -v /usr/local/bin/java; \ | ||
\ | ||
# ca-certificates-java does not work on src:openjdk-11: (https://bugs.debian.org/914424, https://bugs.debian.org/894979, https://salsa.debian.org/java-team/ca-certificates-java/commit/813b8c4973e6c4bb273d5d02f8d4e0aa0b226c50#d4b95d176f05e34cd0b718357c532dc5a6d66cd7_54_56) | ||
keytool -importkeystore -srckeystore /etc/ssl/certs/java/cacerts -destkeystore /etc/ssl/certs/java/cacerts.jks -deststoretype JKS -srcstorepass changeit -deststorepass changeit -noprompt; \ | ||
mv /etc/ssl/certs/java/cacerts.jks /etc/ssl/certs/java/cacerts; \ | ||
/var/lib/dpkg/info/ca-certificates-java.postinst configure; \ | ||
\ | ||
# verify that "docker-java-home" returns what we expect | ||
[ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; \ | ||
\ | ||
# update-alternatives so that future installs of other OpenJDK versions don't change /usr/bin/java | ||
update-alternatives --get-selections | awk -v home="$(readlink -f "$JAVA_HOME")" 'index($3, home) == 1 { $2 = "manual"; print | "update-alternatives --set-selections" }'; \ | ||
# ... and verify that it actually worked for one of the alternatives we care about | ||
update-alternatives --query java | grep -q 'Status: manual' | ||
|
||
# see CA_CERTIFICATES_JAVA_VERSION notes above | ||
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure | ||
|
||
# # Go install | ||
|
||
ENV GOLANG_VERSION 1.21.5 | ||
|
||
RUN set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends wget; \ | ||
# this "case" statement is generated via "update.sh" | ||
dpkgArch="$(dpkg --print-architecture)"; \ | ||
case "${dpkgArch##*-}" in \ | ||
amd64) goRelArch='linux-amd64'; goRelSha256='e2bc0b3e4b64111ec117295c088bde5f00eeed1567999ff77bc859d7df70078e' ;; \ | ||
armhf) goRelArch='linux-armv6l'; goRelSha256='837f4bf4e22fcdf920ffeaa4abf3d02d1314e03725431065f4d44c46a01b42fe' ;; \ | ||
arm64) goRelArch='linux-arm64'; goRelSha256='841cced7ecda9b2014f139f5bab5ae31785f35399f236b8b3e75dff2a2978d96' ;; \ | ||
i386) goRelArch='linux-386'; goRelSha256='8f4dba9cf5c61757bbd7e9ebdb93b6a30a1b03f4a636a1ba0cc2f27b907ab8e1' ;; \ | ||
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='907b8c6ec4be9b184952e5d3493be66b1746442394a8bc78556c56834cd7c38b' ;; \ | ||
s390x) goRelArch='linux-s390x'; goRelSha256='9c4a81b72ebe44368813cd03684e1080a818bf915d84163abae2ed325a1b2dc0' ;; \ | ||
*) goRelArch='src'; goRelSha256='285cbbdf4b6e6e62ed58f370f3f6d8c30825d6e56c5853c66d3c23bcdb09db19'; \ | ||
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \ | ||
esac; \ | ||
\ | ||
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ | ||
wget -O go.tgz "$url"; \ | ||
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ | ||
tar -C /usr/local -xzf go.tgz; \ | ||
rm go.tgz; \ | ||
\ | ||
if [ "$goRelArch" = 'src' ]; then \ | ||
echo >&2; \ | ||
echo >&2 'error: UNIMPLEMENTED'; \ | ||
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \ | ||
echo >&2; \ | ||
exit 1; \ | ||
fi; \ | ||
\ | ||
export PATH="/usr/local/go/bin:$PATH"; \ | ||
go version | ||
|
||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH | ||
|
||
|
||
ENV RUSTUP_HOME=/usr/local/rustup \ | ||
CARGO_HOME=/usr/local/cargo \ | ||
PATH=/usr/local/cargo/bin:$PATH \ | ||
RUST_VERSION=1.75.0 | ||
|
||
RUN set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
gcc \ | ||
libc6-dev \ | ||
wget \ | ||
; \ | ||
dpkgArch="$(dpkg --print-architecture)"; \ | ||
case "${dpkgArch##*-}" in \ | ||
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db' ;; \ | ||
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='f21c44b01678c645d8fbba1e55e4180a01ac5af2d38bcbd14aa665e0d96ed69a' ;; \ | ||
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800' ;; \ | ||
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e7b0f47557c1afcd86939b118cbcf7fb95a5d1d917bdd355157b63ca00fc4333' ;; \ | ||
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ | ||
esac; \ | ||
url="https://static.rust-lang.org/rustup/archive/1.26.0/${rustArch}/rustup-init"; \ | ||
wget "$url"; \ | ||
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ | ||
chmod +x rustup-init; \ | ||
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \ | ||
rm rustup-init; \ | ||
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ | ||
rustup --version; \ | ||
cargo --version; \ | ||
rustc --version; \ | ||
apt-get remove -y --auto-remove \ | ||
wget \ | ||
; \ | ||
rm -rf /var/lib/apt/lists/*; | ||
|
||
RUN cargo new dockerdeps \ | ||
&& echo 'serde_json = "=1.0.111"' >> /dockerdeps/Cargo.toml \ | ||
&& echo 'serde = { version = "=1.0.196", features = ["derive"] }' >> /dockerdeps/Cargo.toml \ | ||
&& cd dockerdeps \ | ||
&& cargo fetch \ | ||
&& cd .. && \ | ||
rm -rf dockerdeps | ||
|
||
CMD ["/bin/bash"] |