Skip to content

Commit e856a9e

Browse files
committed
Generate Dockerfiles for stronger consistency
1 parent ed7e793 commit e856a9e

File tree

9 files changed

+179
-45
lines changed

9 files changed

+179
-45
lines changed

openjdk-6-jdk/Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM buildpack-deps:wheezy-scm
28

39
# A few problems with compiling Java from source:
@@ -15,7 +21,11 @@ ENV JAVA_HOME /usr/lib/jvm/java-6-openjdk-amd64
1521
ENV JAVA_VERSION 6b36
1622
ENV JAVA_DEBIAN_VERSION 6b36-1.13.8-1~deb7u1
1723

18-
RUN apt-get update && apt-get install -y openjdk-6-jdk="$JAVA_DEBIAN_VERSION" && rm -rf /var/lib/apt/lists/*
24+
RUN set -x \
25+
&& apt-get update \
26+
&& apt-get install -y \
27+
openjdk-6-jdk="$JAVA_DEBIAN_VERSION" \
28+
&& rm -rf /var/lib/apt/lists/*
1929

2030
# If you're reading this and have any feedback on how this image could be
2131
# improved, please open an issue or a pull request so we can discuss it!

openjdk-6-jre/Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM buildpack-deps:wheezy-curl
28

39
# A few problems with compiling Java from source:
@@ -10,12 +16,16 @@ RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
1016
# Default to UTF-8 file.encoding
1117
ENV LANG C.UTF-8
1218

13-
ENV JAVA_HOME /usr/lib/jvm/java-6-openjdk-amd64
19+
ENV JAVA_HOME /usr/lib/jvm/java-6-openjdk-amd64/jre
1420

1521
ENV JAVA_VERSION 6b36
1622
ENV JAVA_DEBIAN_VERSION 6b36-1.13.8-1~deb7u1
1723

18-
RUN apt-get update && apt-get install -y openjdk-6-jre-headless="$JAVA_DEBIAN_VERSION" && rm -rf /var/lib/apt/lists/*
24+
RUN set -x \
25+
&& apt-get update \
26+
&& apt-get install -y \
27+
openjdk-6-jre-headless="$JAVA_DEBIAN_VERSION" \
28+
&& rm -rf /var/lib/apt/lists/*
1929

2030
# If you're reading this and have any feedback on how this image could be
2131
# improved, please open an issue or a pull request so we can discuss it!

openjdk-7-jdk/Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM buildpack-deps:jessie-scm
28

39
# A few problems with compiling Java from source:
@@ -15,7 +21,11 @@ ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
1521
ENV JAVA_VERSION 7u91
1622
ENV JAVA_DEBIAN_VERSION 7u91-2.6.3-1~deb8u1
1723

18-
RUN apt-get update && apt-get install -y openjdk-7-jdk="$JAVA_DEBIAN_VERSION" && rm -rf /var/lib/apt/lists/*
24+
RUN set -x \
25+
&& apt-get update \
26+
&& apt-get install -y \
27+
openjdk-7-jdk="$JAVA_DEBIAN_VERSION" \
28+
&& rm -rf /var/lib/apt/lists/*
1929

2030
# If you're reading this and have any feedback on how this image could be
2131
# improved, please open an issue or a pull request so we can discuss it!

openjdk-7-jre/Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM buildpack-deps:jessie-curl
28

39
# A few problems with compiling Java from source:
@@ -10,12 +16,16 @@ RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
1016
# Default to UTF-8 file.encoding
1117
ENV LANG C.UTF-8
1218

13-
ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
19+
ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64/jre
1420

1521
ENV JAVA_VERSION 7u91
1622
ENV JAVA_DEBIAN_VERSION 7u91-2.6.3-1~deb8u1
1723

18-
RUN apt-get update && apt-get install -y openjdk-7-jre-headless="$JAVA_DEBIAN_VERSION" && rm -rf /var/lib/apt/lists/*
24+
RUN set -x \
25+
&& apt-get update \
26+
&& apt-get install -y \
27+
openjdk-7-jre-headless="$JAVA_DEBIAN_VERSION" \
28+
&& rm -rf /var/lib/apt/lists/*
1929

2030
# If you're reading this and have any feedback on how this image could be
2131
# improved, please open an issue or a pull request so we can discuss it!

openjdk-8-jdk/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM buildpack-deps:jessie-scm
28

39
# A few problems with compiling Java from source:

openjdk-8-jre/Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM buildpack-deps:jessie-curl
28

39
# A few problems with compiling Java from source:
@@ -12,7 +18,7 @@ RUN echo 'deb http://httpredir.debian.org/debian jessie-backports main' > /etc/a
1218
# Default to UTF-8 file.encoding
1319
ENV LANG C.UTF-8
1420

15-
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
21+
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/jre
1622

1723
ENV JAVA_VERSION 8u66
1824
ENV JAVA_DEBIAN_VERSION 8u66-b17-1~bpo8+1
@@ -31,9 +37,5 @@ RUN set -x \
3137
# see CA_CERTIFICATES_JAVA_VERSION notes above
3238
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
3339

34-
# see https://bugs.debian.org/793210
35-
# and https://github.com/docker-library/java/issues/46#issuecomment-119026586
36-
RUN apt-get update && apt-get install -y --no-install-recommends libfontconfig1 && rm -rf /var/lib/apt/lists/*
37-
3840
# If you're reading this and have any feedback on how this image could be
3941
# improved, please open an issue or a pull request so we can discuss it!

openjdk-9-jdk/Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
FROM buildpack-deps:sid-curl
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
7+
FROM buildpack-deps:sid-scm
28

39
# A few problems with compiling Java from source:
410
# 1. Oracle. Licensing prevents us from redistributing the official JDK.
@@ -31,9 +37,5 @@ RUN set -x \
3137
# see CA_CERTIFICATES_JAVA_VERSION notes above
3238
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
3339

34-
# see https://bugs.debian.org/793210
35-
# and https://github.com/docker-library/java/issues/46#issuecomment-119026586
36-
RUN apt-get update && apt-get install -y --no-install-recommends libfontconfig1 && rm -rf /var/lib/apt/lists/*
37-
3840
# If you're reading this and have any feedback on how this image could be
3941
# improved, please open an issue or a pull request so we can discuss it!

openjdk-9-jre/Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM buildpack-deps:sid-curl
28

39
# A few problems with compiling Java from source:
@@ -12,7 +18,7 @@ RUN echo 'deb http://httpredir.debian.org/debian experimental main' > /etc/apt/s
1218
# Default to UTF-8 file.encoding
1319
ENV LANG C.UTF-8
1420

15-
ENV JAVA_HOME /usr/lib/jvm/java-9-openjdk-amd64
21+
ENV JAVA_HOME /usr/lib/jvm/java-9-openjdk-amd64/jre
1622

1723
ENV JAVA_VERSION 9~b96
1824
ENV JAVA_DEBIAN_VERSION 9~b96-1
@@ -31,9 +37,5 @@ RUN set -x \
3137
# see CA_CERTIFICATES_JAVA_VERSION notes above
3238
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
3339

34-
# see https://bugs.debian.org/793210
35-
# and https://github.com/docker-library/java/issues/46#issuecomment-119026586
36-
RUN apt-get update && apt-get install -y --no-install-recommends libfontconfig1 && rm -rf /var/lib/apt/lists/*
37-
3840
# If you're reading this and have any feedback on how this image could be
3941
# improved, please open an issue or a pull request so we can discuss it!

update.sh

Lines changed: 106 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,125 @@ if [ ${#versions[@]} -eq 0 ]; then
99
fi
1010
versions=( "${versions[@]%/}" )
1111

12+
declare -A suites=(
13+
[openjdk-6]='wheezy'
14+
[openjdk-7]='jessie'
15+
[openjdk-8]='jessie'
16+
[openjdk-9]='sid'
17+
)
18+
19+
declare -A addSuites=(
20+
[openjdk-8]='jessie-backports'
21+
[openjdk-9]='experimental'
22+
)
23+
24+
declare -A variants=(
25+
[jre]='curl'
26+
[jdk]='scm'
27+
)
28+
1229
travisEnv=
1330
for version in "${versions[@]}"; do
1431
flavor="${version%%-*}" # "openjdk"
1532
javaVersion="${version#*-}" # "6-jdk"
1633
javaType="${javaVersion##*-}" # "jdk"
1734
javaVersion="${javaVersion%-*}" # "6"
1835

19-
# Determine debian:SUITE based on FROM directive
20-
dist="$(grep '^FROM ' "$version/Dockerfile" | cut -d' ' -f2 | sed -r 's/^buildpack-deps:(\w+)-.*$/debian:\1/')"
36+
suite="${suites[$flavor-$javaVersion]}"
37+
addSuite="${addSuites[$flavor-$javaVersion]}"
38+
variant="${variants[$javaType]}"
2139

22-
# Use debian:SUITE-backports if backports packages are required
23-
if grep -q backports "$version/Dockerfile"; then
24-
dist+="-backports"
40+
javaHome="/usr/lib/jvm/java-$javaVersion-$flavor-$(dpkg --print-architecture)"
41+
if [ "$javaType" = 'jre' ]; then
42+
javaHome+='/jre'
2543
fi
2644

27-
# we don't have buildpack-deps:experimental-* so we use sid and add a source
28-
if grep -q experimental "$version/Dockerfile"; then
29-
dist="${dist%:sid}:experimental"
45+
needCaHack=
46+
if [ "$javaVersion" -ge 8 ]; then
47+
needCaHack=1
3048
fi
3149

32-
fullVersion=
33-
case "$flavor" in
34-
openjdk)
35-
debianVersion="$(set -x; docker run --rm "$dist" bash -c "apt-get update -qq && apt-cache show $flavor-$javaVersion-$javaType | awk -F ': ' '\$1 == \"Version\" { print \$2; exit }'")"
36-
fullVersion="${debianVersion%%-*}"
37-
;;
38-
esac
39-
40-
if [ "$fullVersion" ]; then
41-
(
42-
set -x
43-
sed -ri '
44-
s/(ENV JAVA_VERSION) .*/\1 '"$fullVersion"'/g;
45-
s/(ENV JAVA_DEBIAN_VERSION) .*/\1 '"$debianVersion"'/g;
46-
' "$version/Dockerfile"
47-
)
50+
dist="debian:${addSuite:-$suite}"
51+
debianPackage="$flavor-$javaVersion-$javaType"
52+
if [ "$javaType" = 'jre' ]; then
53+
debianPackage+='-headless'
4854
fi
55+
debianVersion="$(set -x; docker run --rm "$dist" bash -c 'apt-get update -qq && apt-cache show "$@"' -- "$debianPackage" |tac|tac| awk -F ': ' '$1 == "Version" { print $2; exit }')"
56+
fullVersion="${debianVersion%%-*}"
57+
58+
cat > "$version/Dockerfile" <<-EOD
59+
#
60+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
61+
#
62+
# PLEASE DO NOT EDIT IT DIRECTLY.
63+
#
64+
65+
FROM buildpack-deps:$suite-$variant
66+
67+
# A few problems with compiling Java from source:
68+
# 1. Oracle. Licensing prevents us from redistributing the official JDK.
69+
# 2. Compiling OpenJDK also requires the JDK to be installed, and it gets
70+
# really hairy.
71+
72+
RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
73+
EOD
74+
75+
if [ "$addSuite" ]; then
76+
cat >> "$version/Dockerfile" <<-EOD
77+
78+
RUN echo 'deb http://httpredir.debian.org/debian $addSuite main' > /etc/apt/sources.list.d/$addSuite.list
79+
EOD
80+
fi
81+
82+
cat >> "$version/Dockerfile" <<-EOD
83+
84+
# Default to UTF-8 file.encoding
85+
ENV LANG C.UTF-8
86+
87+
ENV JAVA_HOME $javaHome
88+
89+
ENV JAVA_VERSION $fullVersion
90+
ENV JAVA_DEBIAN_VERSION $debianVersion
91+
EOD
92+
93+
if [ "$needCaHack" ]; then
94+
cat >> "$version/Dockerfile" <<-EOD
95+
96+
# see https://bugs.debian.org/775775
97+
# and https://github.com/docker-library/java/issues/19#issuecomment-70546872
98+
ENV CA_CERTIFICATES_JAVA_VERSION 20140324
99+
EOD
100+
fi
101+
102+
cat >> "$version/Dockerfile" <<EOD
103+
104+
RUN set -x \\
105+
&& apt-get update \\
106+
&& apt-get install -y \\
107+
$debianPackage="\$JAVA_DEBIAN_VERSION" \\
108+
EOD
109+
if [ "$needCaHack" ]; then
110+
cat >> "$version/Dockerfile" <<EOD
111+
ca-certificates-java="\$CA_CERTIFICATES_JAVA_VERSION" \\
112+
EOD
113+
fi
114+
cat >> "$version/Dockerfile" <<EOD
115+
&& rm -rf /var/lib/apt/lists/*
116+
EOD
117+
118+
if [ "$needCaHack" ]; then
119+
cat >> "$version/Dockerfile" <<-EOD
120+
121+
# see CA_CERTIFICATES_JAVA_VERSION notes above
122+
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
123+
EOD
124+
fi
125+
126+
cat >> "$version/Dockerfile" <<-EOD
127+
128+
# If you're reading this and have any feedback on how this image could be
129+
# improved, please open an issue or a pull request so we can discuss it!
130+
EOD
49131

50132
travisEnv='\n - VERSION='"$version$travisEnv"
51133
done

0 commit comments

Comments
 (0)