Skip to content

Commit 4086632

Browse files
author
Frank Blechschmidt
committed
Add initial Dockerfile
1 parent b59eb72 commit 4086632

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
FROM python:3.7.2-slim-stretch
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
bzip2 \
5+
unzip \
6+
xz-utils \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
RUN echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list
10+
11+
# Default to UTF-8 file.encoding
12+
ENV LANG C.UTF-8
13+
14+
# add a simple script that can auto-detect the appropriate JAVA_HOME value
15+
# based on whether the JDK or only the JRE is installed
16+
RUN { \
17+
echo '#!/bin/sh'; \
18+
echo 'set -e'; \
19+
echo; \
20+
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
21+
} > /usr/local/bin/docker-java-home \
22+
&& chmod +x /usr/local/bin/docker-java-home
23+
24+
# do some fancy footwork to create a JAVA_HOME that's cross-architecture-safe
25+
RUN ln -svT "/usr/lib/jvm/java-11-openjdk-$(dpkg --print-architecture)" /docker-java-home
26+
ENV JAVA_HOME /docker-java-home
27+
28+
ENV JAVA_VERSION 11.0.1
29+
ENV JAVA_DEBIAN_VERSION 11.0.1+13-2~bpo9+1
30+
31+
RUN set -ex; \
32+
\
33+
# deal with slim variants not having man page directories (which causes "update-alternatives" to fail)
34+
if [ ! -d /usr/share/man/man1 ]; then \
35+
mkdir -p /usr/share/man/man1; \
36+
fi; \
37+
\
38+
# ca-certificates-java does not work on src:openjdk-11 with no-install-recommends: (https://bugs.debian.org/914860, https://bugs.debian.org/775775)
39+
# /var/lib/dpkg/info/ca-certificates-java.postinst: line 56: java: command not found
40+
ln -svT /docker-java-home/bin/java /usr/local/bin/java; \
41+
\
42+
apt-get update; \
43+
apt-get install -y --no-install-recommends \
44+
openjdk-11-jdk-headless="$JAVA_DEBIAN_VERSION" \
45+
gcc g++ maven \
46+
; \
47+
rm -rf /var/lib/apt/lists/*; \
48+
\
49+
rm -v /usr/local/bin/java; \
50+
\
51+
# 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)
52+
keytool -importkeystore -srckeystore /etc/ssl/certs/java/cacerts -destkeystore /etc/ssl/certs/java/cacerts.jks -deststoretype JKS -srcstorepass changeit -deststorepass changeit -noprompt; \
53+
mv /etc/ssl/certs/java/cacerts.jks /etc/ssl/certs/java/cacerts; \
54+
/var/lib/dpkg/info/ca-certificates-java.postinst configure; \
55+
\
56+
# verify that "docker-java-home" returns what we expect
57+
[ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; \
58+
\
59+
# update-alternatives so that future installs of other OpenJDK versions don't change /usr/bin/java
60+
update-alternatives --get-selections | awk -v home="$(readlink -f "$JAVA_HOME")" 'index($3, home) == 1 { $2 = "manual"; print | "update-alternatives --set-selections" }'; \
61+
# ... and verify that it actually worked for one of the alternatives we care about
62+
update-alternatives --query java | grep -q 'Status: manual'
63+
64+
CMD ["python3"]

0 commit comments

Comments
 (0)