Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Java Contrib submodule and update to use java 17 in build #1352

Merged
merged 18 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 31 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,27 @@ ADD https://github.com/adoptium/temurin${OPENJDK_MAJOR_VERSION}-binaries/release
/tmp/OpenJDK${OPENJDK_MAJOR_VERSION}U.tar.gz

FROM openjdk-${BUILDARCH} as openjdk-install
ARG OPENJDK_MAJOR_VERSION
RUN set -xe; (echo "$hash /tmp/OpenJDK${OPENJDK_MAJOR_VERSION}U.tar.gz" | sha256sum -c)
igorpeshansky marked this conversation as resolved.
Show resolved Hide resolved
RUN set -xe; \
mkdir -p /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk && \
tar -xf /tmp/OpenJDK${OPENJDK_MAJOR_VERSION}U.tar.gz -C /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk --strip-components=1


# ======================================
# Build Ops Agent for centos-7
# ======================================

FROM centos:7 AS centos7-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; yum -y update && \
yum -y install git systemd \
autoconf libtool libcurl-devel libtool-ltdl-devel openssl-devel yajl-devel \
gcc gcc-c++ make bison flex file systemd-devel zlib-devel gtest-devel rpm-build \
expect rpm-sign zip
COPY --from=openjdk-install /tmp/OpenJDK17U.tar.gz /tmp/OpenJDK17U.tar.gz
RUN set -xe; \
mkdir -p /usr/local/java-17-openjdk && \
tar -xf /tmp/OpenJDK17U.tar.gz -C /usr/local/java-17-openjdk --strip-components=1

ENV JAVA_HOME /usr/local/java-17-openjdk/
COPY --from=openjdk-install /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/ /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk
ENV JAVA_HOME /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/
COPY --from=cmake-install-recent /cmake.sh /cmake.sh
RUN set -x; bash /cmake.sh --skip-license --prefix=/usr/local

Expand Down Expand Up @@ -180,13 +181,14 @@ COPY --from=centos7-build /google-cloud-ops-agent*.rpm /
# ======================================

FROM rockylinux:8 AS centos8-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; yum -y update && \
dnf -y install 'dnf-command(config-manager)' && \
yum config-manager --set-enabled powertools && \
yum -y install git systemd \
autoconf libtool libcurl-devel libtool-ltdl-devel openssl-devel yajl-devel \
gcc gcc-c++ make cmake bison flex file systemd-devel zlib-devel gtest-devel rpm-build systemd-rpm-macros java-17-openjdk-devel \
gcc gcc-c++ make cmake bison flex file systemd-devel zlib-devel gtest-devel rpm-build systemd-rpm-macros java-${OPENJDK_MAJOR_VERSION}-openjdk-devel \
expect rpm-sign zip tzdata-java

SHELL ["/bin/bash", "-c"]
Expand Down Expand Up @@ -279,17 +281,18 @@ COPY --from=centos8-build /google-cloud-ops-agent*.rpm /
# ======================================

FROM rockylinux:9 AS rockylinux9-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; dnf -y update && \
dnf -y install 'dnf-command(config-manager)' && \
dnf config-manager --set-enabled crb && \
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
dnf -y install git systemd \
autoconf libtool libcurl-devel libtool-ltdl-devel openssl-devel yajl-devel \
gcc gcc-c++ make cmake bison flex file systemd-devel zlib-devel gtest-devel rpm-build systemd-rpm-macros java-17-openjdk-devel \
gcc gcc-c++ make cmake bison flex file systemd-devel zlib-devel gtest-devel rpm-build systemd-rpm-macros java-${OPENJDK_MAJOR_VERSION}-openjdk-devel \
expect rpm-sign zip

ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk/
ENV JAVA_HOME /usr/lib/jvm/java-${OPENJDK_MAJOR_VERSION}-openjdk/

SHELL ["/bin/bash", "-c"]

Expand Down Expand Up @@ -381,12 +384,13 @@ COPY --from=rockylinux9-build /google-cloud-ops-agent*.rpm /
# ======================================

FROM debian:bookworm AS bookworm-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip

SHELL ["/bin/bash", "-c"]

Expand Down Expand Up @@ -478,12 +482,13 @@ COPY --from=bookworm-build /google-cloud-ops-agent*.deb /
# ======================================

FROM debian:bullseye AS bullseye-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip

SHELL ["/bin/bash", "-c"]

Expand Down Expand Up @@ -575,18 +580,15 @@ COPY --from=bullseye-build /google-cloud-ops-agent*.deb /
# ======================================

FROM debian:buster AS buster-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config zip
COPY --from=openjdk-install /tmp/OpenJDK17U.tar.gz /tmp/OpenJDK17U.tar.gz
RUN set -xe; \
mkdir -p /usr/local/java-17-openjdk && \
tar -xf /tmp/OpenJDK17U.tar.gz -C /usr/local/java-17-openjdk --strip-components=1

ENV JAVA_HOME /usr/local/java-17-openjdk/
COPY --from=openjdk-install /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/ /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk
ENV JAVA_HOME /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/

SHELL ["/bin/bash", "-c"]

Expand Down Expand Up @@ -678,6 +680,7 @@ COPY --from=buster-build /google-cloud-ops-agent*.deb /
# ======================================

FROM opensuse/archive:42.3 AS sles12-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; \
# The 'OSS Update' repo signature is no longer valid, so verify the checksum instead.
Expand All @@ -696,12 +699,8 @@ RUN set -x; \
zypper -n install bison>3.4 && \
# Allow fluent-bit to find systemd
ln -fs /usr/lib/systemd /lib/systemd
COPY --from=openjdk-install /tmp/OpenJDK17U.tar.gz /tmp/OpenJDK17U.tar.gz
RUN set -xe; \
mkdir -p /usr/local/java-17-openjdk && \
tar -xf /tmp/OpenJDK17U.tar.gz -C /usr/local/java-17-openjdk --strip-components=1

ENV JAVA_HOME /usr/local/java-17-openjdk/
COPY --from=openjdk-install /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/ /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk
ENV JAVA_HOME /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/
COPY --from=cmake-install-recent /cmake.sh /cmake.sh
RUN set -x; bash /cmake.sh --skip-license --prefix=/usr/local

Expand Down Expand Up @@ -796,6 +795,7 @@ COPY --from=sles12-build /google-cloud-ops-agent*.rpm /
# ======================================

FROM opensuse/leap:15.1 AS sles15-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; zypper -n install git systemd autoconf automake flex libtool libcurl-devel libopenssl-devel libyajl-devel gcc gcc-c++ zlib-devel rpm-build expect cmake systemd-devel systemd-rpm-macros unzip zip
# Add agent-vendor.repo to install >3.4 bison
Expand All @@ -812,12 +812,8 @@ RUN set -x; zypper -n install git systemd autoconf automake flex libtool libcurl
zypper -n install bison>3.4 && \
# Allow fluent-bit to find systemd
ln -fs /usr/lib/systemd /lib/systemd
COPY --from=openjdk-install /tmp/OpenJDK17U.tar.gz /tmp/OpenJDK17U.tar.gz
RUN set -xe; \
mkdir -p /usr/local/java-17-openjdk && \
tar -xf /tmp/OpenJDK17U.tar.gz -C /usr/local/java-17-openjdk --strip-components=1

ENV JAVA_HOME /usr/local/java-17-openjdk/
COPY --from=openjdk-install /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/ /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk
ENV JAVA_HOME /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/
COPY --from=cmake-install-recent /cmake.sh /cmake.sh
RUN set -x; bash /cmake.sh --skip-license --prefix=/usr/local

Expand Down Expand Up @@ -912,12 +908,13 @@ COPY --from=sles15-build /google-cloud-ops-agent*.rpm /
# ======================================

FROM ubuntu:focal AS focal-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip

SHELL ["/bin/bash", "-c"]

Expand Down Expand Up @@ -1009,12 +1006,13 @@ COPY --from=focal-build /google-cloud-ops-agent*.deb /
# ======================================

FROM ubuntu:jammy AS jammy-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip

SHELL ["/bin/bash", "-c"]

Expand Down Expand Up @@ -1106,12 +1104,13 @@ COPY --from=jammy-build /google-cloud-ops-agent*.deb /
# ======================================

FROM ubuntu:lunar AS lunar-build-base
ARG OPENJDK_MAJOR_VERSION

RUN set -x; apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip debhelper
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip debhelper

SHELL ["/bin/bash", "-c"]

Expand Down
55 changes: 19 additions & 36 deletions dockerfiles/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ COPY --from=cmake-install-recent /cmake.sh /cmake.sh
RUN set -x; bash /cmake.sh --skip-license --prefix=/usr/local
`

// installJaava is used on platforms where the default package manager
igorpeshansky marked this conversation as resolved.
Show resolved Hide resolved
// does not provided an implementation of java 17 as required by the JMX metrics gatherer build.
igorpeshansky marked this conversation as resolved.
Show resolved Hide resolved
// The openjdk-install layer is defined in template-header.
const installJava = `
COPY --from=openjdk-install /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/ /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk
ENV JAVA_HOME /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/`

var dockerfileArguments = []templateArguments{
{
from_image: "centos:7",
Expand All @@ -69,13 +76,7 @@ var dockerfileArguments = []templateArguments{
yum -y install git systemd \
autoconf libtool libcurl-devel libtool-ltdl-devel openssl-devel yajl-devel \
gcc gcc-c++ make bison flex file systemd-devel zlib-devel gtest-devel rpm-build \
expect rpm-sign zip
COPY --from=openjdk-install /tmp/OpenJDK17U.tar.gz /tmp/OpenJDK17U.tar.gz
RUN set -xe; \
mkdir -p /usr/local/java-17-openjdk && \
tar -xf /tmp/OpenJDK17U.tar.gz -C /usr/local/java-17-openjdk --strip-components=1

ENV JAVA_HOME /usr/local/java-17-openjdk/` + installCMake,
expect rpm-sign zip` + installJava + installCMake,
package_build: "RUN ./pkg/rpm/build.sh",
tar_distro_name: "centos-7",
package_extension: "rpm",
Expand All @@ -88,7 +89,7 @@ var dockerfileArguments = []templateArguments{
yum config-manager --set-enabled powertools && \
yum -y install git systemd \
autoconf libtool libcurl-devel libtool-ltdl-devel openssl-devel yajl-devel \
gcc gcc-c++ make cmake bison flex file systemd-devel zlib-devel gtest-devel rpm-build systemd-rpm-macros java-17-openjdk-devel \
gcc gcc-c++ make cmake bison flex file systemd-devel zlib-devel gtest-devel rpm-build systemd-rpm-macros java-${OPENJDK_MAJOR_VERSION}-openjdk-devel \
expect rpm-sign zip tzdata-java`,
package_build: "RUN ./pkg/rpm/build.sh",
tar_distro_name: "centos-8",
Expand All @@ -103,10 +104,10 @@ var dockerfileArguments = []templateArguments{
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
dnf -y install git systemd \
autoconf libtool libcurl-devel libtool-ltdl-devel openssl-devel yajl-devel \
gcc gcc-c++ make cmake bison flex file systemd-devel zlib-devel gtest-devel rpm-build systemd-rpm-macros java-17-openjdk-devel \
gcc gcc-c++ make cmake bison flex file systemd-devel zlib-devel gtest-devel rpm-build systemd-rpm-macros java-${OPENJDK_MAJOR_VERSION}-openjdk-devel \
expect rpm-sign zip

ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk/`,
ENV JAVA_HOME /usr/lib/jvm/java-${OPENJDK_MAJOR_VERSION}-openjdk/`,
package_build: "RUN ./pkg/rpm/build.sh",
tar_distro_name: "rockylinux-9",
package_extension: "rpm",
Expand All @@ -118,7 +119,7 @@ var dockerfileArguments = []templateArguments{
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip`,
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip`,
package_build: "RUN ./pkg/deb/build.sh",
tar_distro_name: "debian-bookworm",
package_extension: "deb",
Expand All @@ -130,7 +131,7 @@ var dockerfileArguments = []templateArguments{
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip`,
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip`,
package_build: "RUN ./pkg/deb/build.sh",
tar_distro_name: "debian-bullseye",
package_extension: "deb",
Expand All @@ -142,13 +143,7 @@ var dockerfileArguments = []templateArguments{
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config zip
COPY --from=openjdk-install /tmp/OpenJDK17U.tar.gz /tmp/OpenJDK17U.tar.gz
RUN set -xe; \
mkdir -p /usr/local/java-17-openjdk && \
tar -xf /tmp/OpenJDK17U.tar.gz -C /usr/local/java-17-openjdk --strip-components=1

ENV JAVA_HOME /usr/local/java-17-openjdk/`,
devscripts cdbs pkg-config zip` + installJava,
package_build: "RUN ./pkg/deb/build.sh",
tar_distro_name: "debian-buster",
package_extension: "deb",
Expand All @@ -174,13 +169,7 @@ var dockerfileArguments = []templateArguments{
# If this bug happens to trigger in the future, adding a "zypper -n download" of a subset of the packages can avoid the segfault.
zypper -n install bison>3.4 && \
# Allow fluent-bit to find systemd
ln -fs /usr/lib/systemd /lib/systemd
COPY --from=openjdk-install /tmp/OpenJDK17U.tar.gz /tmp/OpenJDK17U.tar.gz
RUN set -xe; \
mkdir -p /usr/local/java-17-openjdk && \
tar -xf /tmp/OpenJDK17U.tar.gz -C /usr/local/java-17-openjdk --strip-components=1

ENV JAVA_HOME /usr/local/java-17-openjdk/` + installCMake,
ln -fs /usr/lib/systemd /lib/systemd` + installJava + installCMake,
package_build: "RUN ./pkg/rpm/build.sh",
tar_distro_name: "sles-12",
package_extension: "rpm",
Expand All @@ -203,13 +192,7 @@ var dockerfileArguments = []templateArguments{
zypper -n update && \
zypper -n install bison>3.4 && \
# Allow fluent-bit to find systemd
ln -fs /usr/lib/systemd /lib/systemd
COPY --from=openjdk-install /tmp/OpenJDK17U.tar.gz /tmp/OpenJDK17U.tar.gz
RUN set -xe; \
mkdir -p /usr/local/java-17-openjdk && \
tar -xf /tmp/OpenJDK17U.tar.gz -C /usr/local/java-17-openjdk --strip-components=1

ENV JAVA_HOME /usr/local/java-17-openjdk/` + installCMake,
ln -fs /usr/lib/systemd /lib/systemd` + installJava + installCMake,
package_build: "RUN ./pkg/rpm/build.sh",
tar_distro_name: "sles-15",
package_extension: "rpm",
Expand All @@ -221,7 +204,7 @@ var dockerfileArguments = []templateArguments{
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip`,
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip`,
package_build: "RUN ./pkg/deb/build.sh",
tar_distro_name: "ubuntu-focal",
package_extension: "deb",
Expand All @@ -233,7 +216,7 @@ var dockerfileArguments = []templateArguments{
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip`,
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip`,
package_build: "RUN ./pkg/deb/build.sh",
tar_distro_name: "ubuntu-jammy",
package_extension: "deb",
Expand All @@ -245,7 +228,7 @@ var dockerfileArguments = []templateArguments{
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
build-essential cmake bison flex file libsystemd-dev \
devscripts cdbs pkg-config openjdk-17-jdk zip debhelper`,
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip debhelper`,
package_build: "RUN ./pkg/deb/build.sh",
tar_distro_name: "ubuntu-lunar",
package_extension: "deb",
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/template
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# ======================================

FROM {from_image} AS {target_name}-build-base
ARG OPENJDK_MAJOR_VERSION

{install_packages}

Expand Down
4 changes: 4 additions & 0 deletions dockerfiles/template-header
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ ADD https://github.com/adoptium/temurin${OPENJDK_MAJOR_VERSION}-binaries/release
/tmp/OpenJDK${OPENJDK_MAJOR_VERSION}U.tar.gz

FROM openjdk-${BUILDARCH} as openjdk-install
ARG OPENJDK_MAJOR_VERSION
RUN set -xe; (echo "$hash /tmp/OpenJDK${OPENJDK_MAJOR_VERSION}U.tar.gz" | sha256sum -c)
RUN set -xe; \
mkdir -p /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk && \
tar -xf /tmp/OpenJDK${OPENJDK_MAJOR_VERSION}U.tar.gz -C /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk --strip-components=1