|
| 1 | +FROM ubuntu:22.04 |
| 2 | + |
| 3 | +ARG TARGETPLATFORM |
| 4 | + |
| 5 | +RUN apt-get update \ |
| 6 | + && apt-get -y --no-install-recommends install \ |
| 7 | + grep \ |
| 8 | + libseccomp-dev \ |
| 9 | + libseccomp2 \ |
| 10 | + procps \ |
| 11 | + && rm -rf /var/lib/apt/lists/* |
| 12 | +# |
| 13 | +# Source: https://github.com/docker-library/python/blob/master/3.6/stretch/slim/Dockerfile |
| 14 | +# |
| 15 | + |
| 16 | +# ensure local python is preferred over distribution python |
| 17 | +ENV PATH /usr/local/bin:$PATH |
| 18 | + |
| 19 | +# http://bugs.python.org/issue19846 |
| 20 | +# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. |
| 21 | +ENV LANG C.UTF-8 |
| 22 | + |
| 23 | +# runtime dependencies |
| 24 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 25 | + ca-certificates \ |
| 26 | + netbase \ |
| 27 | + && rm -rf /var/lib/apt/lists/* |
| 28 | + |
| 29 | +ENV GPG_KEY A821E680E5FA6305 |
| 30 | +ENV PYTHON_VERSION 3.12.1 |
| 31 | + |
| 32 | +RUN set -ex \ |
| 33 | + \ |
| 34 | + && savedAptMark="$(apt-mark showmanual)" \ |
| 35 | + && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ |
| 36 | + dpkg-dev \ |
| 37 | + gcc \ |
| 38 | + libbz2-dev \ |
| 39 | + libc6-dev \ |
| 40 | + libexpat1-dev \ |
| 41 | + libffi-dev \ |
| 42 | + libgdbm-dev \ |
| 43 | + liblzma-dev \ |
| 44 | + libncursesw5-dev \ |
| 45 | + libreadline-dev \ |
| 46 | + libsqlite3-dev \ |
| 47 | + libssl-dev \ |
| 48 | + make \ |
| 49 | + tk-dev \ |
| 50 | + wget \ |
| 51 | + xz-utils \ |
| 52 | + zlib1g-dev \ |
| 53 | +# as of Stretch, "gpg" is no longer included by default |
| 54 | + $(command -v gpg > /dev/null || echo 'gnupg dirmngr') \ |
| 55 | + \ |
| 56 | + && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ |
| 57 | + && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ |
| 58 | + && export GNUPGHOME="$(mktemp -d)" \ |
| 59 | + && gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY" \ |
| 60 | + && gpg --batch --verify python.tar.xz.asc python.tar.xz \ |
| 61 | + && { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ |
| 62 | + && rm -rf "$GNUPGHOME" python.tar.xz.asc \ |
| 63 | + && mkdir -p /usr/src/python \ |
| 64 | + && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ |
| 65 | + && rm python.tar.xz \ |
| 66 | + \ |
| 67 | + && cd /usr/src/python \ |
| 68 | + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ |
| 69 | + && ./configure \ |
| 70 | + --build="$gnuArch" \ |
| 71 | + --enable-loadable-sqlite-extensions \ |
| 72 | + --enable-shared \ |
| 73 | + --with-system-expat \ |
| 74 | + --with-system-ffi \ |
| 75 | + --without-ensurepip \ |
| 76 | + && make -j "$(nproc)" \ |
| 77 | + && make install \ |
| 78 | + && ldconfig \ |
| 79 | + \ |
| 80 | + && apt-mark auto '.*' > /dev/null \ |
| 81 | + && apt-mark manual $savedAptMark \ |
| 82 | + && find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ |
| 83 | + | awk '/=>/ { print $(NF-1) }' \ |
| 84 | + | sort -u \ |
| 85 | + | xargs -r dpkg-query --search \ |
| 86 | + | cut -d: -f1 \ |
| 87 | + | sort -u \ |
| 88 | + | xargs -r apt-mark manual \ |
| 89 | + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ |
| 90 | + && rm -rf /var/lib/apt/lists/* \ |
| 91 | + \ |
| 92 | + && find /usr/local -depth \ |
| 93 | + \( \ |
| 94 | + \( -type d -a \( -name test -o -name tests \) \) \ |
| 95 | + -o \ |
| 96 | + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ |
| 97 | + \) -exec rm -rf '{}' + \ |
| 98 | + && rm -rf /usr/src/python \ |
| 99 | + \ |
| 100 | + && python3 --version |
| 101 | + |
| 102 | +# make some useful symlinks that are expected to exist |
| 103 | +RUN cd /usr/local/bin \ |
| 104 | + && ln -s idle3 idle \ |
| 105 | + && ln -s pydoc3 pydoc \ |
| 106 | + && ln -s python3 python \ |
| 107 | + && ln -s python3-config python-config |
| 108 | + |
| 109 | +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" |
| 110 | +ENV PYTHON_PIP_VERSION 23.3.2 |
| 111 | + |
| 112 | +RUN set -ex; \ |
| 113 | + \ |
| 114 | + savedAptMark="$(apt-mark showmanual)"; \ |
| 115 | + apt-get update; \ |
| 116 | + apt-get install -y --no-install-recommends wget; \ |
| 117 | + \ |
| 118 | + wget -O get-pip.py 'https://bootstrap.pypa.io/pip/get-pip.py'; \ |
| 119 | + \ |
| 120 | + apt-mark auto '.*' > /dev/null; \ |
| 121 | + [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \ |
| 122 | + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ |
| 123 | + rm -rf /var/lib/apt/lists/*; \ |
| 124 | + \ |
| 125 | + python get-pip.py \ |
| 126 | + --disable-pip-version-check \ |
| 127 | + --no-cache-dir \ |
| 128 | + "pip==$PYTHON_PIP_VERSION" \ |
| 129 | + ; \ |
| 130 | + pip --version; \ |
| 131 | + \ |
| 132 | + find /usr/local -depth \ |
| 133 | + \( \ |
| 134 | + \( -type d -a \( -name test -o -name tests \) \) \ |
| 135 | + -o \ |
| 136 | + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ |
| 137 | + \) -exec rm -rf '{}' +; \ |
| 138 | + rm -f get-pip.py; \ |
| 139 | + pip3 install aioconsole; \ |
| 140 | + pip3 uninstall --yes pip setuptools |
| 141 | + |
| 142 | +# Necessary as Submitty does path expansion of commands in compiling a homework, |
| 143 | +# and so resolves "python" -> "/usr/bin/python" |
| 144 | +RUN cd /usr/bin \ |
| 145 | + && ln -s /usr/local/bin/python3 python3 \ |
| 146 | + && ln -s /usr/local/bin/python3 python \ |
| 147 | + && ln -s /usr/local/bin/pip3 pip3 \ |
| 148 | + && ln -s /usr/local/bin/pip3 pip |
| 149 | +# |
| 150 | +# Source: https://github.com/docker-library/openjdk/blob/master/8/jdk/slim/Dockerfile |
| 151 | +# |
| 152 | + |
| 153 | +# A few reasons for installing distribution-provided OpenJDK: |
| 154 | +# |
| 155 | +# 1. Oracle. Licensing prevents us from redistributing the official JDK. |
| 156 | +# |
| 157 | +# 2. Compiling OpenJDK also requires the JDK to be installed, and it gets |
| 158 | +# really hairy. |
| 159 | +# |
| 160 | +# For some sample build times, see Debian's buildd logs: |
| 161 | +# https://buildd.debian.org/status/logs.php?pkg=openjdk-8 |
| 162 | + |
| 163 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 164 | + bzip2 \ |
| 165 | + unzip \ |
| 166 | + xz-utils \ |
| 167 | + && rm -rf /var/lib/apt/lists/* |
| 168 | + |
| 169 | +RUN apt-get update \ |
| 170 | + && apt-get install -y --no-install-recommends \ |
| 171 | + # emacs \ |
| 172 | + nano \ |
| 173 | + vim \ |
| 174 | + && rm -rf /var/lib/apt/lists/* |
| 175 | + |
| 176 | +RUN apt-get update \ |
| 177 | + && apt-get install -y \ |
| 178 | + iproute2 \ |
| 179 | + && rm -rf /var/lib/apt/lists/* |
| 180 | + |
| 181 | +# add a simple script that can auto-detect the appropriate JAVA_HOME value |
| 182 | +# based on whether the JDK or only the JRE is installed |
| 183 | +RUN { \ |
| 184 | + echo '#!/bin/sh'; \ |
| 185 | + echo 'set -e'; \ |
| 186 | + echo; \ |
| 187 | + echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \ |
| 188 | + } > /usr/local/bin/docker-java-home \ |
| 189 | + && chmod +x /usr/local/bin/docker-java-home |
| 190 | + |
| 191 | +# do some fancy footwork to create a JAVA_HOME that's cross-architecture-safe |
| 192 | +RUN ln -svT "/usr/lib/jvm/java-11-openjdk-$(dpkg --print-architecture)" /docker-java-home |
| 193 | +ENV JAVA_HOME /docker-java-home |
| 194 | + |
| 195 | +# Look here to update: https://packages.ubuntu.com/jammy/openjdk-11-jdk-headless |
| 196 | +ENV JAVA_UBUNTU_VERSION 11.0.22+7-0ubuntu2~22.04.1 |
| 197 | + |
| 198 | +RUN set -ex; \ |
| 199 | + \ |
| 200 | +# deal with slim variants not having man page directories (which causes "update-alternatives" to fail) |
| 201 | + if [ ! -d /usr/share/man/man1 ]; then \ |
| 202 | + mkdir -p /usr/share/man/man1; \ |
| 203 | + fi; \ |
| 204 | +# ca-certificates-java does not work on src:openjdk-11 with no-install-recommends: (https://bugs.debian.org/914860, https://bugs.debian.org/775775) |
| 205 | +# /var/lib/dpkg/info/ca-certificates-java.postinst: line 56: java: command not found |
| 206 | + ln -svT /docker-java-home/bin/java /usr/local/bin/java; \ |
| 207 | + \ |
| 208 | + apt-get update; \ |
| 209 | + apt-get install -y --no-install-recommends \ |
| 210 | + openjdk-11-jdk-headless="$JAVA_UBUNTU_VERSION" \ |
| 211 | + ; \ |
| 212 | + rm -rf /var/lib/apt/lists/*; \ |
| 213 | + \ |
| 214 | + rm -v /usr/local/bin/java; \ |
| 215 | + \ |
| 216 | +# 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) |
| 217 | + keytool -importkeystore -srckeystore /etc/ssl/certs/java/cacerts -destkeystore /etc/ssl/certs/java/cacerts.jks -deststoretype JKS -srcstorepass changeit -deststorepass changeit -noprompt; \ |
| 218 | + mv /etc/ssl/certs/java/cacerts.jks /etc/ssl/certs/java/cacerts; \ |
| 219 | + /var/lib/dpkg/info/ca-certificates-java.postinst configure; \ |
| 220 | + \ |
| 221 | +# verify that "docker-java-home" returns what we expect |
| 222 | + [ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; \ |
| 223 | + \ |
| 224 | +# update-alternatives so that future installs of other OpenJDK versions don't change /usr/bin/java |
| 225 | + update-alternatives --get-selections | awk -v home="$(readlink -f "$JAVA_HOME")" 'index($3, home) == 1 { $2 = "manual"; print | "update-alternatives --set-selections" }'; \ |
| 226 | +# ... and verify that it actually worked for one of the alternatives we care about |
| 227 | + update-alternatives --query java | grep -q 'Status: manual' |
| 228 | + |
| 229 | +# see CA_CERTIFICATES_JAVA_VERSION notes above |
| 230 | +RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure |
| 231 | + |
| 232 | +# # Go install |
| 233 | + |
| 234 | +ENV GOLANG_VERSION 1.21.5 |
| 235 | + |
| 236 | +RUN set -eux; \ |
| 237 | + apt-get update; \ |
| 238 | + apt-get install -y --no-install-recommends wget; \ |
| 239 | +# this "case" statement is generated via "update.sh" |
| 240 | + dpkgArch="$(dpkg --print-architecture)"; \ |
| 241 | + case "${dpkgArch##*-}" in \ |
| 242 | + amd64) goRelArch='linux-amd64'; goRelSha256='e2bc0b3e4b64111ec117295c088bde5f00eeed1567999ff77bc859d7df70078e' ;; \ |
| 243 | + armhf) goRelArch='linux-armv6l'; goRelSha256='837f4bf4e22fcdf920ffeaa4abf3d02d1314e03725431065f4d44c46a01b42fe' ;; \ |
| 244 | + arm64) goRelArch='linux-arm64'; goRelSha256='841cced7ecda9b2014f139f5bab5ae31785f35399f236b8b3e75dff2a2978d96' ;; \ |
| 245 | + i386) goRelArch='linux-386'; goRelSha256='8f4dba9cf5c61757bbd7e9ebdb93b6a30a1b03f4a636a1ba0cc2f27b907ab8e1' ;; \ |
| 246 | + ppc64el) goRelArch='linux-ppc64le'; goRelSha256='907b8c6ec4be9b184952e5d3493be66b1746442394a8bc78556c56834cd7c38b' ;; \ |
| 247 | + s390x) goRelArch='linux-s390x'; goRelSha256='9c4a81b72ebe44368813cd03684e1080a818bf915d84163abae2ed325a1b2dc0' ;; \ |
| 248 | + *) goRelArch='src'; goRelSha256='285cbbdf4b6e6e62ed58f370f3f6d8c30825d6e56c5853c66d3c23bcdb09db19'; \ |
| 249 | + echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \ |
| 250 | + esac; \ |
| 251 | + \ |
| 252 | + url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ |
| 253 | + wget -O go.tgz "$url"; \ |
| 254 | + echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ |
| 255 | + tar -C /usr/local -xzf go.tgz; \ |
| 256 | + rm go.tgz; \ |
| 257 | + \ |
| 258 | + if [ "$goRelArch" = 'src' ]; then \ |
| 259 | + echo >&2; \ |
| 260 | + echo >&2 'error: UNIMPLEMENTED'; \ |
| 261 | + echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \ |
| 262 | + echo >&2; \ |
| 263 | + exit 1; \ |
| 264 | + fi; \ |
| 265 | + \ |
| 266 | + export PATH="/usr/local/go/bin:$PATH"; \ |
| 267 | + go version |
| 268 | + |
| 269 | +ENV GOPATH /go |
| 270 | +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH |
| 271 | + |
| 272 | + |
| 273 | +ENV RUSTUP_HOME=/usr/local/rustup \ |
| 274 | + CARGO_HOME=/usr/local/cargo \ |
| 275 | + PATH=/usr/local/cargo/bin:$PATH \ |
| 276 | + RUST_VERSION=1.75.0 |
| 277 | + |
| 278 | +RUN set -eux; \ |
| 279 | + apt-get update; \ |
| 280 | + apt-get install -y --no-install-recommends \ |
| 281 | + ca-certificates \ |
| 282 | + gcc \ |
| 283 | + libc6-dev \ |
| 284 | + wget \ |
| 285 | + ; \ |
| 286 | + dpkgArch="$(dpkg --print-architecture)"; \ |
| 287 | + case "${dpkgArch##*-}" in \ |
| 288 | + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db' ;; \ |
| 289 | + armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='f21c44b01678c645d8fbba1e55e4180a01ac5af2d38bcbd14aa665e0d96ed69a' ;; \ |
| 290 | + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800' ;; \ |
| 291 | + i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e7b0f47557c1afcd86939b118cbcf7fb95a5d1d917bdd355157b63ca00fc4333' ;; \ |
| 292 | + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ |
| 293 | + esac; \ |
| 294 | + url="https://static.rust-lang.org/rustup/archive/1.26.0/${rustArch}/rustup-init"; \ |
| 295 | + wget "$url"; \ |
| 296 | + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ |
| 297 | + chmod +x rustup-init; \ |
| 298 | + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \ |
| 299 | + rm rustup-init; \ |
| 300 | + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ |
| 301 | + rustup --version; \ |
| 302 | + cargo --version; \ |
| 303 | + rustc --version; \ |
| 304 | + apt-get remove -y --auto-remove \ |
| 305 | + wget \ |
| 306 | + ; \ |
| 307 | + rm -rf /var/lib/apt/lists/*; |
| 308 | + |
| 309 | +RUN cargo new dockerdeps \ |
| 310 | + && echo 'serde_json = "=1.0.111"' >> /dockerdeps/Cargo.toml \ |
| 311 | + && echo 'serde = { version = "=1.0.196", features = ["derive"] }' >> /dockerdeps/Cargo.toml \ |
| 312 | + && cd dockerdeps \ |
| 313 | + && cargo fetch \ |
| 314 | + && cd .. && \ |
| 315 | + rm -rf dockerdeps |
| 316 | + |
| 317 | +CMD ["/bin/bash"] |
0 commit comments