Skip to content

Commit df2d591

Browse files
committed
chore: Clean up scripts
1 parent 89b6fd4 commit df2d591

File tree

3 files changed

+54
-59
lines changed

3 files changed

+54
-59
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Test images
3939
run: ./build --test
4040
- name: Describe images
41-
run: ./build --describe
41+
run: ./build --describe >> $GITHUB_STEP_SUMMARY
4242
- name: Push images
4343
run: ./build --push
4444
- name: Free Disk Space (Ubuntu) # Required by trivy to have enough space to scan full image

Dockerfile

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# syntax=docker/dockerfile:1.6
2+
13
# Intermediate image used to prune cruft from JDKs and squash them all.
24
FROM cimg/base:edge-22.04 AS all-jdk
35

@@ -21,26 +23,32 @@ COPY --from=ghcr.io/graalvm/native-image-community:21-ol9 /usr/lib64/graalvm/gra
2123

2224
RUN sudo apt-get -y update && sudo apt-get -y install curl
2325
# See: https://gist.github.com/wavezhang/ba8425f24a968ec9b2a8619d7c2d86a6
24-
RUN set -eux; \
25-
sudo mkdir -p /usr/lib/jvm/oracle8; \
26-
curl -L --fail "https://javadl.oracle.com/webapps/download/AutoDL?BundleId=246284_165374ff4ea84ef0bbd821706e29b123" | sudo tar -xvzf - -C /usr/lib/jvm/oracle8 --strip-components 1
26+
RUN <<-EOT
27+
set -eux
28+
sudo mkdir -p /usr/lib/jvm/oracle8
29+
curl -L --fail "https://javadl.oracle.com/webapps/download/AutoDL?BundleId=246284_165374ff4ea84ef0bbd821706e29b123" | sudo tar -xvzf - -C /usr/lib/jvm/oracle8 --strip-components 1
30+
EOT
2731

2832
# Install Ubuntu's OpenJDK 17 and fix broken symlinks:
2933
# some files in /usr/lib/jvm/ubuntu17 are symlinks to /etc/java-17-openjdk/, so we just copy all symlinks targets.
30-
RUN set -eux;\
31-
sudo apt-get install openjdk-17-jdk;\
32-
sudo mv /usr/lib/jvm/java-17-openjdk-amd64 /usr/lib/jvm/ubuntu17;\
33-
sudo cp -rf --remove-destination /etc/java-17-openjdk/* /usr/lib/jvm/ubuntu17/conf/;\
34-
sudo cp -rf --remove-destination /etc/java-17-openjdk/* /usr/lib/jvm/ubuntu17/lib/;\
35-
sudo cp -f --remove-destination /etc/java-17-openjdk/jvm-amd64.cfg /usr/lib/jvm/ubuntu17/lib/;
34+
RUN <<-EOT
35+
set -eux
36+
sudo apt-get install openjdk-17-jdk
37+
sudo mv /usr/lib/jvm/java-17-openjdk-amd64 /usr/lib/jvm/ubuntu17
38+
sudo cp -rf --remove-destination /etc/java-17-openjdk/* /usr/lib/jvm/ubuntu17/conf/
39+
sudo cp -rf --remove-destination /etc/java-17-openjdk/* /usr/lib/jvm/ubuntu17/lib/
40+
sudo cp -f --remove-destination /etc/java-17-openjdk/jvm-amd64.cfg /usr/lib/jvm/ubuntu17/lib/
41+
EOT
3642

3743
# Remove cruft from JDKs that is not used in the build process.
38-
RUN sudo rm -rf \
39-
/usr/lib/jvm/*/man \
40-
/usr/lib/jvm/*/lib/src.zip \
41-
/usr/lib/jvm/*/demo \
42-
/usr/lib/jvm/*/sample \
43-
/usr/lib/jvm/graalvm*/lib/installer
44+
RUN <<-EOT
45+
sudo rm -rf \
46+
/usr/lib/jvm/*/man \
47+
/usr/lib/jvm/*/lib/src.zip \
48+
/usr/lib/jvm/*/demo \
49+
/usr/lib/jvm/*/sample \
50+
/usr/lib/jvm/graalvm*/lib/installer
51+
EOT
4452

4553
FROM scratch AS default-jdk
4654

@@ -57,38 +65,42 @@ FROM cimg/base:edge-22.04 AS base
5765
LABEL org.opencontainers.image.source=https://github.com/DataDog/dd-trace-java-docker-build
5866

5967
# Replace Docker Compose and yq versions from CircleCI Base Image by latest
60-
RUN dockerPluginDir=/usr/local/lib/docker/cli-plugins && \
61-
sudo curl -sSL "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o $dockerPluginDir/docker-compose && \
62-
sudo chmod +x $dockerPluginDir/docker-compose && \
63-
sudo curl -fL "https://github.com/docker/compose-switch/releases/latest/download/docker-compose-linux-$(dpkg --print-architecture)" -o /usr/local/bin/compose-switch && \
64-
sudo chmod +x /usr/local/bin/compose-switch && \
65-
sudo rm /usr/local/bin/{install-man-page.sh,yq*} && \
66-
curl -sSL "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$(dpkg --print-architecture).tar.gz" | \
67-
sudo tar -xz -C /usr/local/bin --wildcards --no-anchored 'yq_linux_*' && \
68-
sudo mv /usr/local/bin/yq{_linux_*,} && \
69-
sudo chown root:root /usr/local/bin/yq
68+
RUN <<-EOT
69+
set -eu
70+
dockerPluginDir=/usr/local/lib/docker/cli-plugins
71+
sudo curl -sSL "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o $dockerPluginDir/docker-compose
72+
sudo chmod +x $dockerPluginDir/docker-compose
73+
sudo curl -fL "https://github.com/docker/compose-switch/releases/latest/download/docker-compose-linux-$(dpkg --print-architecture)" -o /usr/local/bin/compose-switch
74+
sudo chmod +x /usr/local/bin/compose-switch
75+
sudo rm /usr/local/bin/{install-man-page.sh,yq*}
76+
curl -sSL "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$(dpkg --print-architecture).tar.gz" | sudo tar -xz -C /usr/local/bin --wildcards --no-anchored 'yq_linux_*'
77+
sudo mv /usr/local/bin/yq{_linux_*,}
78+
sudo chown root:root /usr/local/bin/yq
79+
EOT
7080

7181
COPY --from=default-jdk /usr/lib/jvm /usr/lib/jvm
7282

7383
COPY autoforward.py /usr/local/bin/autoforward
7484

7585
# Force downgrade of urllib3 to work around https://github.com/docker/docker-py/issues/3113
7686
# Install urllib3 early since it is also used by awscli
77-
RUN set -eux; \
78-
sudo apt-get update; \
79-
sudo apt-get install --no-install-recommends apt-transport-https socat; \
80-
sudo apt-get install --no-install-recommends vim less debian-goodies; \
81-
sudo apt-get install --no-install-recommends autossh; \
82-
sudo apt-get install ca-certificates-java;\
83-
sudo apt install python3-pip; \
84-
sudo apt-get -y clean; \
85-
sudo rm -rf /var/lib/apt/lists/*; \
86-
pip3 install "urllib3>=1.25.4,<2" awscli; \
87-
pip3 install requests requests-unixsocket; \
88-
pip3 cache purge; \
89-
sudo chmod +x /usr/local/bin/autoforward; \
90-
sudo curl -L --fail "https://github.com/DataDog/datadog-ci/releases/download/v1.3.0-alpha/datadog-ci_linux-x64" --output "/usr/local/bin/datadog-ci"; \
91-
sudo chmod +x /usr/local/bin/datadog-ci;
87+
RUN <<-EOT
88+
set -eux
89+
sudo apt-get update
90+
sudo apt-get install --no-install-recommends apt-transport-https socat
91+
sudo apt-get install --no-install-recommends vim less debian-goodies
92+
sudo apt-get install --no-install-recommends autossh
93+
sudo apt-get install ca-certificates-java
94+
sudo apt install python3-pip
95+
sudo apt-get -y clean
96+
sudo rm -rf /var/lib/apt/lists/*
97+
pip3 install "urllib3>=1.25.4,<2" awscli
98+
pip3 install requests requests-unixsocket
99+
pip3 cache purge
100+
sudo chmod +x /usr/local/bin/autoforward
101+
sudo curl -L --fail "https://github.com/DataDog/datadog-ci/releases/download/v1.3.0-alpha/datadog-ci_linux-x64" --output "/usr/local/bin/datadog-ci"
102+
sudo chmod +x /usr/local/bin/datadog-ci
103+
EOT
92104

93105
# IBM specific env variables
94106
ENV IBM_JAVA_OPTIONS="-XX:+UseContainerSupport"

build

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,6 @@ function list_layers() {
9595
docker inspect "${image}" | jq -r '.[].RootFS.Layers[]'
9696
}
9797

98-
function shares_layers() {
99-
local base="${1}"
100-
local other="${2}"
101-
mapfile -t base_layers < <(list_layers "${base}")
102-
mapfile -t other_layers < <(list_layers "${base}")
103-
declare -A other_map
104-
for ol in "${other_layers[@]}"; do
105-
other_map[$ol]=true
106-
done
107-
for bl in "${base_layers[@]}"; do
108-
if [[ ${other_map[$bl]} != true ]]; then
109-
echo "Layer $bl from $base not found in $other"
110-
return 1
111-
fi
112-
done
113-
}
114-
11598
function do_test() {
11699
local image_base image_variant
117100
compute_metadata
@@ -200,7 +183,7 @@ function do_inner_describe() {
200183
env_upper="JAVA_${variant_upper}_HOME"
201184
echo "* $env_upper"
202185
echo '```'
203-
"${!env_upper}/bin/java" -version
186+
"${!env_upper}/bin/java" -version 2>&1
204187
echo '```'
205188
echo
206189
done

0 commit comments

Comments
 (0)