From b641a08a7f4468b07558dfde479bcc36e4604cc3 Mon Sep 17 00:00:00 2001 From: Stefano Franz Date: Thu, 6 Dec 2018 03:42:07 -0800 Subject: [PATCH] Build both corretto and zulu docker images (#4359) * add logic to push images * build zulu and corretto images --- docker/build.gradle | 37 +++++++++++------ docker/src/docker/DockerfileAL | 74 ++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 docker/src/docker/DockerfileAL diff --git a/docker/build.gradle b/docker/build.gradle index f04eeeb60a..30fea9f79f 100644 --- a/docker/build.gradle +++ b/docker/build.gradle @@ -55,6 +55,7 @@ task buildDockerFolder(dependsOn: [":node:capsule:buildCordaJAR", shadowJar]) { from shadowJar.archivePath from "src/config/starting-node.conf" from "src/bash/generate-config.sh" + from "src/docker/DockerfileAL" from "src/docker/Dockerfile" rename(cordaJar.name, "corda.jar") rename(shadowJar.archivePath.name, "config-exporter.jar") @@ -64,23 +65,35 @@ task buildDockerFolder(dependsOn: [":node:capsule:buildCordaJAR", shadowJar]) { final String runTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) final String suffix = project.version.toString().toLowerCase().contains("snapshot") ? runTime : "RELEASE" -final buildTags = ["corda/corda-${project.version.toString().toLowerCase()}:${suffix}", "corda/corda-${project.version.toString().toLowerCase()}:latest"] +final zuluBuildTags = ["corda/corda-zulu-${project.version.toString().toLowerCase()}:${suffix}", "corda/corda-zulu-${project.version.toString().toLowerCase()}:latest"] +final correttoBuildTags = ["corda/corda-corretto-${project.version.toString().toLowerCase()}:${suffix}", "corda/corda-corretto-${project.version.toString().toLowerCase()}:latest"] -task buildOfficialDockerImage(type: DockerBuildImage, dependsOn: [buildDockerFolder]) { - //if we are a snapshot, append a timestamp - //if we are a release, append RELEASE +task buildOfficialZuluDockerImage(type: DockerBuildImage, dependsOn: [buildDockerFolder]) { inputDir = new File(project.buildDir, "docker-temp") - tags = buildTags + tags = zuluBuildTags + dockerFile = new File(new File(project.buildDir, "docker-temp"), "Dockerfile") } -task pushTimeStampedTag('type': DockerPushImage, dependsOn: [buildOfficialDockerImage]){ - imageName = buildTags[0] +task buildOfficialCorrettoDockerImage(type: DockerBuildImage, dependsOn: [buildDockerFolder]) { + inputDir = new File(project.buildDir, "docker-temp") + tags = correttoBuildTags + dockerFile = new File(new File(project.buildDir, "docker-temp"), "DockerfileAL") } -task pushLatestTag('type': DockerPushImage, dependsOn: [buildOfficialDockerImage]){ - imageName = buildTags[1] +task pushZuluTimeStampedTag('type': DockerPushImage, dependsOn: [buildOfficialZuluDockerImage]){ + imageName = zuluBuildTags[0] } -task pushOfficialImages(dependsOn: [pushTimeStampedTag, pushLatestTag]){ - -} \ No newline at end of file +task pushZuluLatestTag('type': DockerPushImage, dependsOn: [buildOfficialZuluDockerImage]){ + imageName = zuluBuildTags[1] +} + +task pushCorrettoTimeStampedTag('type': DockerPushImage, dependsOn: [buildOfficialCorrettoDockerImage]){ + imageName = correttoBuildTags[0] +} + +task pushCorrettoLatestTag('type': DockerPushImage, dependsOn: [buildOfficialCorrettoDockerImage]){ + imageName = correttoBuildTags[1] +} + +task pushOfficialImages(dependsOn: [pushZuluTimeStampedTag, pushZuluLatestTag, pushCorrettoTimeStampedTag, pushCorrettoLatestTag]) \ No newline at end of file diff --git a/docker/src/docker/DockerfileAL b/docker/src/docker/DockerfileAL new file mode 100644 index 0000000000..34bc5311cc --- /dev/null +++ b/docker/src/docker/DockerfileAL @@ -0,0 +1,74 @@ +FROM amazonlinux:2 + +RUN amazon-linux-extras enable corretto8 +RUN yum -y install java-1.8.0-amazon-corretto-devel +RUN yum -y install bash +RUN yum -y install curl +RUN yum -y install unzip + +# Create dirs +RUN mkdir -p /opt/corda/cordapps +RUN mkdir -p /opt/corda/persistence +RUN mkdir -p /opt/corda/certificates +RUN mkdir -p /opt/corda/drivers +RUN mkdir -p /opt/corda/logs +RUN mkdir -p /opt/corda/bin +RUN mkdir -p /opt/corda/additional-node-infos +RUN mkdir -p /etc/corda + +# Create corda user +RUN groupadd corda && \ + useradd corda -g corda -m -d /opt/corda + +WORKDIR /opt/corda + +ENV CORDAPPS_FOLDER="/opt/corda/cordapps" +ENV PERSISTENCE_FOLDER="/opt/corda/persistence" +ENV CERTIFICATES_FOLDER="/opt/corda/certificates" +ENV DRIVERS_FOLDER="/opt/corda/drivers" +ENV CONFIG_FOLDER="/etc/corda" + +ENV MY_P2P_PORT=10200 +ENV MY_RPC_PORT=10201 +ENV MY_RPC_ADMIN_PORT=10202 + +RUN chown -R corda:corda /opt/corda +RUN chown -R corda:corda /etc/corda + +##CORDAPPS FOLDER +VOLUME ["/opt/corda/cordapps"] +##PERSISTENCE FOLDER +VOLUME ["/opt/corda/persistence"] +##CERTS FOLDER +VOLUME ["/opt/corda/certificates"] +##OPTIONAL JDBC DRIVERS FOLDER +VOLUME ["/opt/corda/drivers"] +##LOG FOLDER +VOLUME ["/opt/corda/logs"] +##ADDITIONAL NODE INFOS FOLDER +VOLUME ["/opt/corda/additional-node-infos"] +##CONFIG LOCATION +VOLUME ["/etc/corda"] + + +##CORDA JAR +ADD --chown=corda:corda corda.jar /opt/corda/bin/corda.jar +##CONFIG MANIPULATOR JAR +ADD --chown=corda:corda config-exporter.jar /opt/corda/config-exporter.jar +##CONFIG GENERATOR SHELL SCRIPT +ADD --chown=corda:corda generate-config.sh /opt/corda/bin/config-generator +##CORDA RUN SCRIPT +ADD --chown=corda:corda run-corda.sh /opt/corda/bin/run-corda +##BASE CONFIG FOR GENERATOR +ADD --chown=corda:corda starting-node.conf /opt/corda/starting-node.conf +##SET EXECUTABLE PERMISSIONS +RUN chmod +x /opt/corda/bin/config-generator +RUN chmod +x /opt/corda/bin/run-corda + +ENV PATH=$PATH:/opt/corda/bin + +EXPOSE $MY_P2P_PORT +EXPOSE $MY_RPC_PORT + +USER "corda" +CMD ["run-corda"]