Skip to content

Commit

Permalink
Run docker OS cluster with different JDK version (#276)
Browse files Browse the repository at this point in the history
* Propagate matrix java version to dockerfile

Signed-off-by: Filip Drobnjakovic <[email protected]>

* Fix gradle.yml indentation

Signed-off-by: Filip Drobnjakovic <[email protected]>

Signed-off-by: Filip Drobnjakovic <[email protected]>
  • Loading branch information
Tjofil authored Jan 26, 2023
1 parent e6eb393 commit 4734d6d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
# Enable RCA for Integration Tests
- name: Spin up Docker cluster for integ testing
working-directory: ./tmp/performance-analyzer-rca
run: ./gradlew enableRca
run: ./gradlew enableRca -Dbuild.docker_jdk_ver=${{matrix.java}}

# Run Integration Tests in PA
- name: Run integration tests
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
buildDockerJdkVersion = System.getProperty("build.docker_jdk_ver", "11")

// 3.0.0-SNAPSHOT -> 3.0.0.0-SNAPSHOT
version_tokens = opensearch_version.tokenize('-')
Expand Down Expand Up @@ -473,7 +474,7 @@ task buildDocker(type: Exec) {
dependsOn(copyAllArtifacts)

workingDir(dockerArtifactsDir)
commandLine 'docker', 'build', '-t', 'opensearch/pa-rca:3.0', '.'
commandLine 'docker', 'build', '-t', 'opensearch/pa-rca:3.0', '.', '--build-arg', "JDK_VER=${buildDockerJdkVersion}"
}

task runDocker(type: Exec) {
Expand Down
26 changes: 21 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@
################################################################################

FROM centos:7 AS prep_open_search_files
ARG JDK_VER=11

ENV PATH /usr/share/opensearch/bin:$PATH
RUN curl -s https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz | tar -C /opt -zxf -
ENV OPENSEARCH_JAVA_HOME /opt/jdk-11.0.1

RUN if [[ "${JDK_VER}" = "17" ]] ; then \
curl -s https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz | tar -C /opt -zxf -; \
mkdir /opt/jdk ; \
mv -v /opt/jdk-17.0.2/* /opt/jdk; \
else \
curl -s https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz | tar -C /opt -zxf -; \
mkdir /opt/jdk ; \
mv -v /opt/jdk-11.0.1/* /opt/jdk; \
fi


ENV OPENSEARCH_JAVA_HOME /opt/jdk
RUN yum install -y unzip
RUN yum install -y lsof

Expand Down Expand Up @@ -54,6 +66,10 @@ RUN chown -R opensearch:0 . && \
RUN unzip config/performance-analyzer-rca-3.0.0.0-SNAPSHOT.zip

RUN chmod -R 755 /dev/shm

RUN if [[ "${JDK_VER}" = "17" ]] ; then \
echo "--add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED" >> /usr/share/opensearch/config/jvm.options ; \
fi
################################################################################
# Build stage 1 (the actual OpenSearch image):
# Copy OpenSearch from stage 0
Expand Down Expand Up @@ -86,13 +102,13 @@ RUN yum update -y && \
yum install -y nc unzip wget which && \
yum clean all
COPY CENTOS_LICENSING.txt /root
COPY --from=prep_open_search_files --chown=1000:0 /opt/jdk-11.0.1 /opt/jdk-11.0.1
ENV OPENSEARCH_JAVA_HOME /opt/jdk-11.0.1
COPY --from=prep_open_search_files --chown=1000:0 /opt/jdk /opt/jdk
ENV OPENSEARCH_JAVA_HOME /opt/jdk
ENV OPENSEARCH_PATH_CONF /usr/share/opensearch/config

# Replace OpenJDK's built-in CA certificate keystore with the one from the OS
# vendor. The latter is superior in several ways.
RUN ln -sf /etc/pki/ca-trust/extracted/java/cacerts /opt/jdk-11.0.1/lib/security/cacerts
RUN ln -sf /etc/pki/ca-trust/extracted/java/cacerts /opt/jdk/lib/security/cacerts

ENV PATH $PATH:$OPENSEARCH_JAVA_HOME/bin

Expand Down

0 comments on commit 4734d6d

Please sign in to comment.