├── .gitignore ├── LICENSE ├── README.md ├── blocks ├── agent-bond-install.dck ├── java-pkg-alpine.dck ├── java-pkg-centos.dck └── java-pkg-ubi.dck ├── fish-pepper.yml ├── images.yml ├── images ├── alpine │ ├── openjdk11 │ │ ├── jdk │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── agent-bond-opts │ │ │ ├── jmx_exporter_config.yml │ │ │ └── run-java.sh │ │ └── jre │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── agent-bond-opts │ │ │ ├── jmx_exporter_config.yml │ │ │ └── run-java.sh │ ├── openjdk7 │ │ ├── jdk │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── agent-bond-opts │ │ │ ├── jmx_exporter_config.yml │ │ │ └── run-java.sh │ │ └── jre │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── agent-bond-opts │ │ │ ├── jmx_exporter_config.yml │ │ │ └── run-java.sh │ └── openjdk8 │ │ ├── jdk │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── agent-bond-opts │ │ ├── jmx_exporter_config.yml │ │ └── run-java.sh │ │ └── jre │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── agent-bond-opts │ │ ├── jmx_exporter_config.yml │ │ └── run-java.sh ├── centos │ ├── openjdk11 │ │ ├── jdk │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── agent-bond-opts │ │ │ ├── jmx_exporter_config.yml │ │ │ └── run-java.sh │ │ └── jre │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── agent-bond-opts │ │ │ ├── jmx_exporter_config.yml │ │ │ └── run-java.sh │ ├── openjdk7 │ │ ├── jdk │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── agent-bond-opts │ │ │ ├── jmx_exporter_config.yml │ │ │ └── run-java.sh │ │ └── jre │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── agent-bond-opts │ │ │ ├── jmx_exporter_config.yml │ │ │ └── run-java.sh │ └── openjdk8 │ │ ├── jdk │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── agent-bond-opts │ │ ├── jmx_exporter_config.yml │ │ └── run-java.sh │ │ └── jre │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── agent-bond-opts │ │ ├── jmx_exporter_config.yml │ │ └── run-java.sh ├── jboss │ ├── openjdk7 │ │ └── jdk │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── agent-bond-opts │ │ │ ├── jmx_exporter_config.yml │ │ │ └── run-java.sh │ └── openjdk8 │ │ └── jdk │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── agent-bond-opts │ │ ├── jmx_exporter_config.yml │ │ └── run-java.sh └── ubi │ ├── openjdk11 │ └── jdk │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── agent-bond-opts │ │ ├── jmx_exporter_config.yml │ │ └── run-java.sh │ └── openjdk8 │ └── jdk │ ├── Dockerfile │ ├── README.md │ ├── agent-bond-opts │ ├── jmx_exporter_config.yml │ └── run-java.sh └── templates ├── Dockerfile ├── README.md └── jmx_exporter_config.yml /.gitignore: -------------------------------------------------------------------------------- 1 | github-triggers.yml 2 | .fp-git-blocks 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2009-2010 Roland Huss 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Fabric8 Java Base Images 2 | 3 | This is a repository for Java Docker base images used in various fabric8 projects. 4 | 5 | The Docker build files for these images are generated by 6 | [fish-pepper](https://github.com/fabric8io-images/fish-pepper), a sophisticated 7 | template system for generation Docker builds. `fish-pepper` allows 8 | the composition of various building block so that parametrized Docker 9 | builds are easy possible. 10 | 11 | In order to regenerate all Dockerfiles from the provided templates you 12 | need only to install `fish-pepper` via npm (assuming that you have 13 | [node.js](https://nodejs.org/) installed) 14 | 15 | ``` 16 | npm -g install fish-pepper 17 | fish-pepper 18 | ``` 19 | 20 | Alternatively you can use also Docker for recreating the Docker build for the Java images: 21 | 22 | ``` 23 | docker run -it --rm -v `pwd`:/fp fabric8/fish-pepper 24 | ``` 25 | 26 | The Java base images come in different flavors: 27 | 28 | * Based on [CentOS 7](https://www.centos.org/) or 29 | [Alpine Linux](https://www.alpinelinux.org/) (experimental) or [Red Hat Universal Base Image](https://developers.redhat.com/products/rhel/ubi/) 30 | * [OpenJDK 7](http://openjdk.java.net/projects/jdk7/) or 31 | [OpenJDK 8](http://openjdk.java.net/projects/jdk8/) or 32 | [OpenJDK 11](http://openjdk.java.net/projects/jdk/11/) 33 | * As JDK (Java Developer Toolkit) or as JRE (Java Runtime Environment) 34 | 35 | All images add the following features: 36 | 37 | * [agent-bond](https://github.com/fabric8io/agent-bond) is included 38 | which combines [Jolokia](http://www.jolokia.org) and 39 | [jmx_exporter](https://github.com/prometheus/jmx_exporter) 40 | * A startup script [run-java.sh](https://github.com/fabric8io/run-java-sh) is 41 | included which transparently starts Java application provided as FAT-jar or 42 | traditionally with a bunch of jar dependencies. 43 | 44 | How to use these images and what environment variables can be used are 45 | described in the associated [README](images/centos/openjdk8/jdk/README.md) files. 46 | -------------------------------------------------------------------------------- /blocks/agent-bond-install.dck: -------------------------------------------------------------------------------- 1 | {{ 2 | var destPath = fp.blockOpts.dest || "/bin/agent-bond-options"; 3 | var agentBondVersion = fp.version.agentBond || fp.blockOpts.version || "1.2.0"; 4 | }}# Agent bond including Jolokia and jmx_exporter 5 | ADD agent-bond-opts {{= destPath }} 6 | RUN mkdir -p /opt/agent-bond \ 7 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/{{= agentBondVersion }}/agent-bond-agent-{{= agentBondVersion }}.jar \ 8 | -o /opt/agent-bond/agent-bond.jar \ 9 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 10 | && chmod 755 {{= destPath}} 11 | ADD jmx_exporter_config.yml /opt/agent-bond/ 12 | EXPOSE 8778 9779 -------------------------------------------------------------------------------- /blocks/java-pkg-alpine.dck: -------------------------------------------------------------------------------- 1 | {{ var major = fp.config.version.major; }} 2 | # /dev/urandom is used as random source, which is perfectly safe 3 | # according to http://www.2uo.de/myths-about-urandom/ 4 | RUN apk add --update \ 5 | curl \ 6 | {{= fp.param.type == 'jre' ? 'openjdk' + major + '-jre' : 'openjdk' + major }}={{= fp.config.base.javaPackage[major]}} \ 7 | && rm /var/cache/apk/* \ 8 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/default-jvm/jre/lib/security/java.security 9 | -------------------------------------------------------------------------------- /blocks/java-pkg-centos.dck: -------------------------------------------------------------------------------- 1 | {{ var major = fp.config.version.major; }} 2 | # /dev/urandom is used as random source, which is prefectly safe 3 | # according to http://www.2uo.de/myths-about-urandom/ 4 | RUN yum install -y \ 5 | java-{{= fp.config.version.version }}-openjdk-{{= fp.config.base.javaPackage[major]}} \ {{? fp.param.type === "jdk" }} 6 | java-{{= fp.config.version.version }}-openjdk-devel-{{= fp.config.base.javaPackage[major]}} \ {{?}} 7 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 8 | && yum clean all 9 | 10 | ENV JAVA_HOME /etc/alternatives/jre 11 | -------------------------------------------------------------------------------- /blocks/java-pkg-ubi.dck: -------------------------------------------------------------------------------- 1 | {{ var major = fp.config.version.major; }} 2 | # /dev/urandom is used as random source, which is prefectly safe 3 | # according to http://www.2uo.de/myths-about-urandom/ 4 | RUN microdnf install java-{{= fp.config.version.version }}-openjdk-headless-{{= fp.config.base.javaPackage[major]}} \ 5 | openssl curl ca-certificates \ 6 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 7 | && microdnf clean all 8 | 9 | ENV JAVA_HOME /etc/alternatives/jre 10 | -------------------------------------------------------------------------------- /fish-pepper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Versions of support libs 4 | version: 5 | agentBond: "1.2.0" 6 | jolokia: "1.7.1" 7 | jmxExporter: "0.3.1" 8 | 9 | # Who to blame 10 | maintainer: "rhuss@redhat.com" 11 | 12 | # Meta info influencing the build 13 | fish-pepper: 14 | # Docker Repo User 15 | repoUser: "fabric8" 16 | 17 | # External blocks 18 | blocks: 19 | # run-java.sh for starting up Java processes 20 | - type: "git" 21 | url: "https://github.com/fabric8io-images/run-java-sh.git" 22 | tag: v1.3.8 23 | # agent bond for export Jolokia and jmx_exporter data 24 | - type: "git" 25 | url: "https://github.com/fabric8io/agent-bond.git" 26 | tag: v1.2.0 27 | -------------------------------------------------------------------------------- /images.yml: -------------------------------------------------------------------------------- 1 | --- 2 | fish-pepper: 3 | params: 4 | - base 5 | - version 6 | - type 7 | name: "fabric8/java" 8 | build: "1.9.0" 9 | 10 | # Used for escaping in 'agent-bond-opts' where the same delimiters are used 11 | abSepOpen: "{{" 12 | abSepClosed: "}}" 13 | 14 | config: 15 | base: 16 | default: 17 | agent: "agent-bond" 18 | baseDir: "/deployments" 19 | alpine: 20 | from: "alpine:3.11.12" 21 | version: "3.11.12" 22 | description: "Alpine" 23 | javaPackage: 24 | 7: 7.281.2.6.24-r0 25 | 8: 8.275.01-r0 26 | 11: 11.0.5_p10-r0 27 | centos: 28 | from: "centos:centos7.9.2009" 29 | createUser: true 30 | user: "jboss" 31 | version: "7" 32 | description: "CentOS" 33 | javaPackage: 34 | 7: 1.7.0.261-2.6.22.2.el7_8 35 | 8: 1.8.0.312.b07-1.el7_9 36 | 11: 11.0.13.0.8-1.el7_9 37 | ubi: 38 | from: "registry.access.redhat.com/ubi8/ubi-minimal:8.4-212" 39 | createUser: false 40 | createUBIUser: true 41 | ubiUser: 1001 42 | version: "8.4" 43 | description: "UBI" 44 | javaPackage: 45 | 8: 1.8.0.312.b07-1.el8_4 46 | 11: 11.0.13.0.8-1.el8_4 47 | jboss: 48 | deprecated: true 49 | from: "jboss/base-jdk" 50 | user: "jboss" 51 | # Use the major version 52 | tagFromMajorVersion: true 53 | description: "JBoss with OpenJDK" 54 | version: 55 | openjdk7: 56 | version: "1.7.0" 57 | description: "OpenJDK 7" 58 | major: 7 59 | fish-pepper: 60 | # Ignore for UBI as there are no Java 7 packages 61 | ignore-for: 62 | - [ "ubi" ] 63 | openjdk8: 64 | version: "1.8.0" 65 | description: "OpenJDK 8" 66 | major: 8 67 | openjdk11: 68 | version: "11" 69 | description: "OpenJDK 11" 70 | major: 11 71 | fish-pepper: 72 | # Ignore for JBoss as there are no Java 11 packages 73 | ignore-for: 74 | - [ "jboss" ] 75 | 76 | type: 77 | jre: 78 | description: "Java Runtime Environment (JRE)" 79 | # Ignore JREs for JBoss and UBI images since there are no JRE variants for them available 80 | fish-pepper: 81 | ignore-for: 82 | - [ "jboss" ] 83 | - [ "ubi" ] 84 | jdk: 85 | description: "Java Development Kit (JDK)" 86 | -------------------------------------------------------------------------------- /images/alpine/openjdk11/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.11.12 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=11 10 | 11 | 12 | # /dev/urandom is used as random source, which is perfectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN apk add --update \ 15 | curl \ 16 | openjdk11=11.0.5_p10-r0 \ 17 | && rm /var/cache/apk/* \ 18 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/default-jvm/jre/lib/security/java.security 19 | 20 | # Agent bond including Jolokia and jmx_exporter 21 | ADD agent-bond-opts /opt/run-java-options 22 | RUN mkdir -p /opt/agent-bond \ 23 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 24 | -o /opt/agent-bond/agent-bond.jar \ 25 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 26 | && chmod 755 /opt/run-java-options 27 | ADD jmx_exporter_config.yml /opt/agent-bond/ 28 | EXPOSE 8778 9779 29 | 30 | # Add run script as /deployments/run-java.sh and make it executable 31 | COPY run-java.sh /deployments/ 32 | RUN chmod 755 /deployments/run-java.sh 33 | 34 | 35 | 36 | 37 | CMD [ "/deployments/run-java.sh" ] 38 | -------------------------------------------------------------------------------- /images/alpine/openjdk11/jdk/README.md: -------------------------------------------------------------------------------- 1 | ## Fabric8 Java Base Image OpenJDK 11 (JDK) 2 | 3 | 4 | 5 | This image is based on Alpine and provides OpenJDK 11 (JDK) 6 | 7 | It includes: 8 | 9 | 10 | * An [Agent Bond](https://github.com/fabric8io/agent-bond) agent with [Jolokia](http://www.jolokia.org) and Prometheus' [jmx_exporter](https://github.com/prometheus/jmx_exporter). The agent is installed as `/opt/agent-bond/agent-bond.jar`. See below for configuration options. 11 | 12 | 13 | * A startup script [`/deployments/run-java.sh`](#startup-script-run-javash) for starting up Java applications. 14 | 15 | ### Agent Bond 16 | 17 | In order to enable Jolokia for your application you should use this image as a base image (via `FROM`) and use the output of `agent-bond-opts` in your startup scripts to include it in for the Java startup options. 18 | 19 | For example, the following snippet can be added to a script starting up your Java application 20 | 21 | # ... 22 | export JAVA_OPTIONS="$JAVA_OPTIONS $(agent-bond-opts)" 23 | # .... use JAVA_OPTIONS when starting your app, e.g. as Tomcat does 24 | 25 | The following versions and defaults are used: 26 | 27 | * [Jolokia](http://www.jolokia.org) : version **1.7.1** and port **8778** 28 | * [jmx_exporter](https://github.com/prometheus/jmx_exporter): version **0.3.1** and port **9779** 29 | 30 | You can influence the behaviour of `agent-bond-opts` by setting various environment variables: 31 | 32 | ### Agent-Bond Options 33 | 34 | Agent bond itself can be influenced with the following environment variables: 35 | 36 | * **AB_OFF** : If set disables activation of agent-bond (i.e. echos an empty value). By default, agent-bond is enabled. 37 | * **AB_ENABLED** : Comma separated list of sub-agents enabled. Currently allowed values are `jolokia` and `jmx_exporter`. 38 | By default both are enabled. 39 | 40 | 41 | #### Jolokia configuration 42 | 43 | * **AB_JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 44 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 45 | By default this is `/opt/jolokia/jolokia.properties`. 46 | * **AB_JOLOKIA_HOST** : Host address to bind to (Default: `0.0.0.0`) 47 | * **AB_JOLOKIA_PORT** : Port to use (Default: `8778`) 48 | * **AB_JOLOKIA_USER** : User for authentication. By default authentication is switched off. 49 | * **AB_JOLOKIA_HTTPS** : Switch on secure communication with https. By default self signed server certificates are generated 50 | if no `serverCert` configuration is given in `AB_JOLOKIA_OPTS` 51 | * **AB_JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 52 | * **AB_JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 53 | * **AB_JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 54 | "key=value,key=value,..." 55 | 56 | Some options for integration in various environments: 57 | 58 | * **AB_JOLOKIA_AUTH_OPENSHIFT** : Switch on client authentication for OpenShift TLS communication. The value of this 59 | parameter can be a relative distinguished name which must be contained in a presented client certificate. Enabling this 60 | parameter will automatically switch Jolokia into https communication mode. The default CA cert is set to 61 | `/var/run/secrets/kubernetes.io/serviceaccount/ca.crt` 62 | 63 | #### jmx_exporter configuration 64 | 65 | * **AB_JMX_EXPORTER_OPTS** : Configuration to use for `jmx_exporter` (in the format `:`) 66 | * **AB_JMX_EXPORTER_PORT** : Port to use for the JMX Exporter. Default: `9779` 67 | * **AB_JMX_EXPORTER_CONFIG** : Path to configuration to use for `jmx_exporter`: Default: `/opt/agent-bond/jmx_exporter_config.json` 68 | 69 | 70 | 71 | ### Startup Script run-java.sh 72 | 73 | The default command for this image is [/deployments/run-java.sh](https://github.com/fabric8io/run-java-sh). Its purpose it to fire up Java applications which are provided as fat-jars, including all dependencies or more classical from a main class, where the classpath is build up from all jars within a directory. 74 | 75 | For these images the variable **JAVA_APP_DIR** has the default value `/deployments` 76 | 77 | 78 | ### run-java.sh 79 | 80 | This general purpose startup script is optimized for running Java application from within containers. It is called like 81 | 82 | ``` 83 | ./run-java.sh 84 | ``` 85 | `run-java.sh` knows two sub-commands: 86 | 87 | * `options` to print out JVM option which can be used for own invocation of Java apps (like Maven or Tomcat). It respects container constraints and includes all magic which is used by this script 88 | * `run` executes a Java application as described below. This is also the default command so you can skip adding this command. 89 | 90 | ### Running a Java application 91 | 92 | When no subcommand is given (or when you provide the default subcommand `run`), then by default this scripts starts up Java application. 93 | 94 | The startup process is configured mostly via environment variables: 95 | 96 | * **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides. 97 | * **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**. 98 | * **JAVA_OPTIONS** options to add when calling `java` 99 | * **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output. 100 | * **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added. 101 | * **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set. 102 | * **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed. 103 | * **JAVA_DIAGNOSTICS** set this to get some diagnostics information to standard out when things are happening 104 | * **JAVA_MAIN_CLASS** A main class to use as argument for `java`. When this environment variable is given, all jar files in `$JAVA_APP_DIR` are added to the classpath as well as `$JAVA_LIB_DIR`. 105 | * **JAVA_APP_JAR** A jar file with an appropriate manifest so that it can be started with `java -jar` if no `$JAVA_MAIN_CLASS` is set. In all cases this jar file is added to the classpath, too. 106 | * **JAVA_APP_NAME** Name to use for the process 107 | * **JAVA_CLASSPATH** the classpath to use. If not given, the startup script checks for a file `${JAVA_APP_DIR}/classpath` and use its content literally as classpath. If this file doesn't exists all jars in the app dir are added (`classes:${JAVA_APP_DIR}/*`). 108 | * **JAVA_DEBUG** If set remote debugging will be switched on 109 | * **JAVA_DEBUG_SUSPEND** If set enables suspend mode in remote debugging 110 | * **JAVA_DEBUG_PORT** Port used for remote debugging. Default: 5005 111 | * **HTTP_PROXY** The URL of the proxy server that translates into the `http.proxyHost` and `http.proxyPort` system properties. 112 | * **HTTPS_PROXY** The URL of the proxy server that translates into the `https.proxyHost` and `https.proxyPort` system properties. 113 | * **no_proxy**, **NO_PROXY** The list of hosts that should be reached directly, bypassing the proxy, that translates into the `http.nonProxyHosts` system property. 114 | 115 | If neither `$JAVA_APP_JAR` nor `$JAVA_MAIN_CLASS` is given, `$JAVA_APP_DIR` is checked for a single JAR file which is taken as `$JAVA_APP_JAR`. If no or more then one jar file is found, an error is thrown. 116 | 117 | The classpath is build up with the following parts: 118 | 119 | * If `$JAVA_CLASSPATH` is set, this classpath is taken. 120 | * The current directory (".") is added first. 121 | * If the current directory is not the same as `$JAVA_APP_DIR`, `$JAVA_APP_DIR` is added. 122 | * If `$JAVA_MAIN_CLASS` is set, then 123 | - A `$JAVA_APP_JAR` is added if set 124 | - If a file `$JAVA_APP_DIR/classpath` exists, its content is appended to the classpath. This file 125 | can be either a single line with the jar files colon separated or a multi-line file where each line 126 | holds the path of the jar file relative to `$JAVA_LIB_DIR` (which by default is the `$JAVA_APP_DIR`) 127 | - If this file is not set, a `${JAVA_APP_DIR}/*` is added which effectively adds all 128 | jars in this directory in alphabetical order. 129 | 130 | These variables can be also set in a shell config file `run-env.sh`, which will be sourced by the startup script. This file can be located in the directory where the startup script is located and in `${JAVA_APP_DIR}`, whereas environment variables in the latter override the ones in `run-env.sh` from the script directory. 131 | 132 | This startup script also checks for a command `run-java-options`. If existent it will be called and the output is added to the environment variable `$JAVA_OPTIONS`. 133 | 134 | The startup script also exposes some environment variables describing container limits which can be used by applications: 135 | 136 | * **CONTAINER_CORE_LIMIT** a calculated core limit as described in https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt 137 | * **CONTAINER_MAX_MEMORY** memory limit given to the container 138 | 139 | Any arguments given to the script are given through directly as argument to the Java application. 140 | 141 | Example: 142 | 143 | ``` 144 | # Set the application directory directly 145 | export JAVA_APP_DIR=/deployments 146 | # Set -Xmx based on container constraints 147 | export JAVA_MAX_MEM_RATIO=40 148 | # Start the jar in JAVA_APP_DIR with the given arguments 149 | ./run-java.sh --user maxmorlock --password secret 150 | ``` 151 | 152 | ### Options 153 | 154 | This script can also be used to calculate reasonable, best-practice options for starting Java apps in general. For example, when running Maven in a container it makes sense to respect container Memory constraints. 155 | 156 | The subcommand `options` can be used to print options to standard output so that is can be easily used to feed it to another, Java based application. 157 | 158 | When no extra arguments are given, all defaults will be used, which can be influenced with the environment variables described above. 159 | 160 | You can select specific sets of options by providing additional arguments: 161 | 162 | * `--debug` : Java debug options if `JAVA_DEBUG` is set 163 | * `--memory` : Memory settings based on the environment variables given 164 | * `--proxy` : Evaluate proxy environments variables 165 | * `--cpu` : Tuning when the number of cores is limited 166 | * `--gc` : GC tuning parameters 167 | * `--jit` : JIT options 168 | * `--diagnostics` : Print diagnostics options when `JAVA_DIAGNOSTICS` is set 169 | * `--java-default` : Same as `--memory --jit --diagnostic --cpu --gc` 170 | 171 | Example: 172 | 173 | ``` 174 | # Call Maven with the proper memory settings when running in an container 175 | export MAVEN_OPTS="$(run-java.sh options --memory)" 176 | mvn clean install 177 | ``` 178 | 179 | 180 | ### Versions: 181 | 182 | * Base-Image: **Alpine 3.11.12** 183 | * Java: **OpenJDK 11 11** (Java Development Kit (JDK)) 184 | * Agent-Bond: **1.2.0** (Jolokia 1.7.1, jmx_exporter 0.3.1) 185 | -------------------------------------------------------------------------------- /images/alpine/openjdk11/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/alpine/openjdk11/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/alpine/openjdk11/jre/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.11.12 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=11 10 | 11 | 12 | # /dev/urandom is used as random source, which is perfectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN apk add --update \ 15 | curl \ 16 | openjdk11-jre=11.0.5_p10-r0 \ 17 | && rm /var/cache/apk/* \ 18 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/default-jvm/jre/lib/security/java.security 19 | 20 | # Agent bond including Jolokia and jmx_exporter 21 | ADD agent-bond-opts /opt/run-java-options 22 | RUN mkdir -p /opt/agent-bond \ 23 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 24 | -o /opt/agent-bond/agent-bond.jar \ 25 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 26 | && chmod 755 /opt/run-java-options 27 | ADD jmx_exporter_config.yml /opt/agent-bond/ 28 | EXPOSE 8778 9779 29 | 30 | # Add run script as /deployments/run-java.sh and make it executable 31 | COPY run-java.sh /deployments/ 32 | RUN chmod 755 /deployments/run-java.sh 33 | 34 | 35 | 36 | 37 | CMD [ "/deployments/run-java.sh" ] 38 | -------------------------------------------------------------------------------- /images/alpine/openjdk11/jre/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/alpine/openjdk11/jre/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/alpine/openjdk7/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.11.12 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=7 10 | 11 | 12 | # /dev/urandom is used as random source, which is perfectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN apk add --update \ 15 | curl \ 16 | openjdk7=7.281.2.6.24-r0 \ 17 | && rm /var/cache/apk/* \ 18 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/default-jvm/jre/lib/security/java.security 19 | 20 | # Agent bond including Jolokia and jmx_exporter 21 | ADD agent-bond-opts /opt/run-java-options 22 | RUN mkdir -p /opt/agent-bond \ 23 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 24 | -o /opt/agent-bond/agent-bond.jar \ 25 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 26 | && chmod 755 /opt/run-java-options 27 | ADD jmx_exporter_config.yml /opt/agent-bond/ 28 | EXPOSE 8778 9779 29 | 30 | # Add run script as /deployments/run-java.sh and make it executable 31 | COPY run-java.sh /deployments/ 32 | RUN chmod 755 /deployments/run-java.sh 33 | 34 | 35 | 36 | 37 | CMD [ "/deployments/run-java.sh" ] 38 | -------------------------------------------------------------------------------- /images/alpine/openjdk7/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/alpine/openjdk7/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/alpine/openjdk7/jre/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.11.12 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=7 10 | 11 | 12 | # /dev/urandom is used as random source, which is perfectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN apk add --update \ 15 | curl \ 16 | openjdk7-jre=7.281.2.6.24-r0 \ 17 | && rm /var/cache/apk/* \ 18 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/default-jvm/jre/lib/security/java.security 19 | 20 | # Agent bond including Jolokia and jmx_exporter 21 | ADD agent-bond-opts /opt/run-java-options 22 | RUN mkdir -p /opt/agent-bond \ 23 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 24 | -o /opt/agent-bond/agent-bond.jar \ 25 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 26 | && chmod 755 /opt/run-java-options 27 | ADD jmx_exporter_config.yml /opt/agent-bond/ 28 | EXPOSE 8778 9779 29 | 30 | # Add run script as /deployments/run-java.sh and make it executable 31 | COPY run-java.sh /deployments/ 32 | RUN chmod 755 /deployments/run-java.sh 33 | 34 | 35 | 36 | 37 | CMD [ "/deployments/run-java.sh" ] 38 | -------------------------------------------------------------------------------- /images/alpine/openjdk7/jre/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/alpine/openjdk7/jre/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/alpine/openjdk8/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.11.12 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=8 10 | 11 | 12 | # /dev/urandom is used as random source, which is perfectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN apk add --update \ 15 | curl \ 16 | openjdk8=8.275.01-r0 \ 17 | && rm /var/cache/apk/* \ 18 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/default-jvm/jre/lib/security/java.security 19 | 20 | # Agent bond including Jolokia and jmx_exporter 21 | ADD agent-bond-opts /opt/run-java-options 22 | RUN mkdir -p /opt/agent-bond \ 23 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 24 | -o /opt/agent-bond/agent-bond.jar \ 25 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 26 | && chmod 755 /opt/run-java-options 27 | ADD jmx_exporter_config.yml /opt/agent-bond/ 28 | EXPOSE 8778 9779 29 | 30 | # Add run script as /deployments/run-java.sh and make it executable 31 | COPY run-java.sh /deployments/ 32 | RUN chmod 755 /deployments/run-java.sh 33 | 34 | 35 | 36 | 37 | CMD [ "/deployments/run-java.sh" ] 38 | -------------------------------------------------------------------------------- /images/alpine/openjdk8/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/alpine/openjdk8/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/alpine/openjdk8/jre/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.11.12 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=8 10 | 11 | 12 | # /dev/urandom is used as random source, which is perfectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN apk add --update \ 15 | curl \ 16 | openjdk8-jre=8.275.01-r0 \ 17 | && rm /var/cache/apk/* \ 18 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/default-jvm/jre/lib/security/java.security 19 | 20 | # Agent bond including Jolokia and jmx_exporter 21 | ADD agent-bond-opts /opt/run-java-options 22 | RUN mkdir -p /opt/agent-bond \ 23 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 24 | -o /opt/agent-bond/agent-bond.jar \ 25 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 26 | && chmod 755 /opt/run-java-options 27 | ADD jmx_exporter_config.yml /opt/agent-bond/ 28 | EXPOSE 8778 9779 29 | 30 | # Add run script as /deployments/run-java.sh and make it executable 31 | COPY run-java.sh /deployments/ 32 | RUN chmod 755 /deployments/run-java.sh 33 | 34 | 35 | 36 | 37 | CMD [ "/deployments/run-java.sh" ] 38 | -------------------------------------------------------------------------------- /images/alpine/openjdk8/jre/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/alpine/openjdk8/jre/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/centos/openjdk11/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7.9.2009 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=11 10 | 11 | 12 | # /dev/urandom is used as random source, which is prefectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN yum install -y \ 15 | java-11-openjdk-11.0.18.0.10-1.el7_9 \ 16 | java-11-openjdk-devel-11.0.18.0.10-1.el7_9 \ 17 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 18 | && yum clean all 19 | 20 | ENV JAVA_HOME /etc/alternatives/jre 21 | 22 | # Agent bond including Jolokia and jmx_exporter 23 | ADD agent-bond-opts /opt/run-java-options 24 | RUN mkdir -p /opt/agent-bond \ 25 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 26 | -o /opt/agent-bond/agent-bond.jar \ 27 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 28 | && chmod 755 /opt/run-java-options 29 | ADD jmx_exporter_config.yml /opt/agent-bond/ 30 | EXPOSE 8778 9779 31 | 32 | # Add run script as /deployments/run-java.sh and make it executable 33 | COPY run-java.sh /deployments/ 34 | RUN chmod 755 /deployments/run-java.sh 35 | 36 | 37 | 38 | # Run under user "jboss" and prepare for be running 39 | # under OpenShift, too 40 | RUN groupadd -r jboss -g 1000 \ 41 | && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin jboss \ 42 | && chmod 755 /opt/jboss \ 43 | && chown -R jboss /deployments \ 44 | && usermod -g root -G `id -g jboss` jboss \ 45 | && chmod -R "g+rwX" /deployments \ 46 | && chown -R jboss:root /deployments 47 | 48 | USER jboss 49 | 50 | 51 | CMD [ "/deployments/run-java.sh" ] 52 | -------------------------------------------------------------------------------- /images/centos/openjdk11/jdk/README.md: -------------------------------------------------------------------------------- 1 | ## Fabric8 Java Base Image OpenJDK 11 (JDK) 2 | 3 | 4 | 5 | This image is based on CentOS and provides OpenJDK 11 (JDK) 6 | 7 | It includes: 8 | 9 | 10 | * An [Agent Bond](https://github.com/fabric8io/agent-bond) agent with [Jolokia](http://www.jolokia.org) and Prometheus' [jmx_exporter](https://github.com/prometheus/jmx_exporter). The agent is installed as `/opt/agent-bond/agent-bond.jar`. See below for configuration options. 11 | 12 | 13 | * A startup script [`/deployments/run-java.sh`](#startup-script-run-javash) for starting up Java applications. 14 | 15 | ### Agent Bond 16 | 17 | In order to enable Jolokia for your application you should use this image as a base image (via `FROM`) and use the output of `agent-bond-opts` in your startup scripts to include it in for the Java startup options. 18 | 19 | For example, the following snippet can be added to a script starting up your Java application 20 | 21 | # ... 22 | export JAVA_OPTIONS="$JAVA_OPTIONS $(agent-bond-opts)" 23 | # .... use JAVA_OPTIONS when starting your app, e.g. as Tomcat does 24 | 25 | The following versions and defaults are used: 26 | 27 | * [Jolokia](http://www.jolokia.org) : version **1.7.1** and port **8778** 28 | * [jmx_exporter](https://github.com/prometheus/jmx_exporter): version **0.3.1** and port **9779** 29 | 30 | You can influence the behaviour of `agent-bond-opts` by setting various environment variables: 31 | 32 | ### Agent-Bond Options 33 | 34 | Agent bond itself can be influenced with the following environment variables: 35 | 36 | * **AB_OFF** : If set disables activation of agent-bond (i.e. echos an empty value). By default, agent-bond is enabled. 37 | * **AB_ENABLED** : Comma separated list of sub-agents enabled. Currently allowed values are `jolokia` and `jmx_exporter`. 38 | By default both are enabled. 39 | 40 | 41 | #### Jolokia configuration 42 | 43 | * **AB_JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 44 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 45 | By default this is `/opt/jolokia/jolokia.properties`. 46 | * **AB_JOLOKIA_HOST** : Host address to bind to (Default: `0.0.0.0`) 47 | * **AB_JOLOKIA_PORT** : Port to use (Default: `8778`) 48 | * **AB_JOLOKIA_USER** : User for authentication. By default authentication is switched off. 49 | * **AB_JOLOKIA_HTTPS** : Switch on secure communication with https. By default self signed server certificates are generated 50 | if no `serverCert` configuration is given in `AB_JOLOKIA_OPTS` 51 | * **AB_JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 52 | * **AB_JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 53 | * **AB_JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 54 | "key=value,key=value,..." 55 | 56 | Some options for integration in various environments: 57 | 58 | * **AB_JOLOKIA_AUTH_OPENSHIFT** : Switch on client authentication for OpenShift TLS communication. The value of this 59 | parameter can be a relative distinguished name which must be contained in a presented client certificate. Enabling this 60 | parameter will automatically switch Jolokia into https communication mode. The default CA cert is set to 61 | `/var/run/secrets/kubernetes.io/serviceaccount/ca.crt` 62 | 63 | #### jmx_exporter configuration 64 | 65 | * **AB_JMX_EXPORTER_OPTS** : Configuration to use for `jmx_exporter` (in the format `:`) 66 | * **AB_JMX_EXPORTER_PORT** : Port to use for the JMX Exporter. Default: `9779` 67 | * **AB_JMX_EXPORTER_CONFIG** : Path to configuration to use for `jmx_exporter`: Default: `/opt/agent-bond/jmx_exporter_config.json` 68 | 69 | 70 | 71 | ### Startup Script run-java.sh 72 | 73 | The default command for this image is [/deployments/run-java.sh](https://github.com/fabric8io/run-java-sh). Its purpose it to fire up Java applications which are provided as fat-jars, including all dependencies or more classical from a main class, where the classpath is build up from all jars within a directory. 74 | 75 | For these images the variable **JAVA_APP_DIR** has the default value `/deployments` 76 | 77 | 78 | ### run-java.sh 79 | 80 | This general purpose startup script is optimized for running Java application from within containers. It is called like 81 | 82 | ``` 83 | ./run-java.sh 84 | ``` 85 | `run-java.sh` knows two sub-commands: 86 | 87 | * `options` to print out JVM option which can be used for own invocation of Java apps (like Maven or Tomcat). It respects container constraints and includes all magic which is used by this script 88 | * `run` executes a Java application as described below. This is also the default command so you can skip adding this command. 89 | 90 | ### Running a Java application 91 | 92 | When no subcommand is given (or when you provide the default subcommand `run`), then by default this scripts starts up Java application. 93 | 94 | The startup process is configured mostly via environment variables: 95 | 96 | * **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides. 97 | * **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**. 98 | * **JAVA_OPTIONS** options to add when calling `java` 99 | * **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output. 100 | * **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added. 101 | * **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set. 102 | * **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed. 103 | * **JAVA_DIAGNOSTICS** set this to get some diagnostics information to standard out when things are happening 104 | * **JAVA_MAIN_CLASS** A main class to use as argument for `java`. When this environment variable is given, all jar files in `$JAVA_APP_DIR` are added to the classpath as well as `$JAVA_LIB_DIR`. 105 | * **JAVA_APP_JAR** A jar file with an appropriate manifest so that it can be started with `java -jar` if no `$JAVA_MAIN_CLASS` is set. In all cases this jar file is added to the classpath, too. 106 | * **JAVA_APP_NAME** Name to use for the process 107 | * **JAVA_CLASSPATH** the classpath to use. If not given, the startup script checks for a file `${JAVA_APP_DIR}/classpath` and use its content literally as classpath. If this file doesn't exists all jars in the app dir are added (`classes:${JAVA_APP_DIR}/*`). 108 | * **JAVA_DEBUG** If set remote debugging will be switched on 109 | * **JAVA_DEBUG_SUSPEND** If set enables suspend mode in remote debugging 110 | * **JAVA_DEBUG_PORT** Port used for remote debugging. Default: 5005 111 | * **HTTP_PROXY** The URL of the proxy server that translates into the `http.proxyHost` and `http.proxyPort` system properties. 112 | * **HTTPS_PROXY** The URL of the proxy server that translates into the `https.proxyHost` and `https.proxyPort` system properties. 113 | * **no_proxy**, **NO_PROXY** The list of hosts that should be reached directly, bypassing the proxy, that translates into the `http.nonProxyHosts` system property. 114 | 115 | If neither `$JAVA_APP_JAR` nor `$JAVA_MAIN_CLASS` is given, `$JAVA_APP_DIR` is checked for a single JAR file which is taken as `$JAVA_APP_JAR`. If no or more then one jar file is found, an error is thrown. 116 | 117 | The classpath is build up with the following parts: 118 | 119 | * If `$JAVA_CLASSPATH` is set, this classpath is taken. 120 | * The current directory (".") is added first. 121 | * If the current directory is not the same as `$JAVA_APP_DIR`, `$JAVA_APP_DIR` is added. 122 | * If `$JAVA_MAIN_CLASS` is set, then 123 | - A `$JAVA_APP_JAR` is added if set 124 | - If a file `$JAVA_APP_DIR/classpath` exists, its content is appended to the classpath. This file 125 | can be either a single line with the jar files colon separated or a multi-line file where each line 126 | holds the path of the jar file relative to `$JAVA_LIB_DIR` (which by default is the `$JAVA_APP_DIR`) 127 | - If this file is not set, a `${JAVA_APP_DIR}/*` is added which effectively adds all 128 | jars in this directory in alphabetical order. 129 | 130 | These variables can be also set in a shell config file `run-env.sh`, which will be sourced by the startup script. This file can be located in the directory where the startup script is located and in `${JAVA_APP_DIR}`, whereas environment variables in the latter override the ones in `run-env.sh` from the script directory. 131 | 132 | This startup script also checks for a command `run-java-options`. If existent it will be called and the output is added to the environment variable `$JAVA_OPTIONS`. 133 | 134 | The startup script also exposes some environment variables describing container limits which can be used by applications: 135 | 136 | * **CONTAINER_CORE_LIMIT** a calculated core limit as described in https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt 137 | * **CONTAINER_MAX_MEMORY** memory limit given to the container 138 | 139 | Any arguments given to the script are given through directly as argument to the Java application. 140 | 141 | Example: 142 | 143 | ``` 144 | # Set the application directory directly 145 | export JAVA_APP_DIR=/deployments 146 | # Set -Xmx based on container constraints 147 | export JAVA_MAX_MEM_RATIO=40 148 | # Start the jar in JAVA_APP_DIR with the given arguments 149 | ./run-java.sh --user maxmorlock --password secret 150 | ``` 151 | 152 | ### Options 153 | 154 | This script can also be used to calculate reasonable, best-practice options for starting Java apps in general. For example, when running Maven in a container it makes sense to respect container Memory constraints. 155 | 156 | The subcommand `options` can be used to print options to standard output so that is can be easily used to feed it to another, Java based application. 157 | 158 | When no extra arguments are given, all defaults will be used, which can be influenced with the environment variables described above. 159 | 160 | You can select specific sets of options by providing additional arguments: 161 | 162 | * `--debug` : Java debug options if `JAVA_DEBUG` is set 163 | * `--memory` : Memory settings based on the environment variables given 164 | * `--proxy` : Evaluate proxy environments variables 165 | * `--cpu` : Tuning when the number of cores is limited 166 | * `--gc` : GC tuning parameters 167 | * `--jit` : JIT options 168 | * `--diagnostics` : Print diagnostics options when `JAVA_DIAGNOSTICS` is set 169 | * `--java-default` : Same as `--memory --jit --diagnostic --cpu --gc` 170 | 171 | Example: 172 | 173 | ``` 174 | # Call Maven with the proper memory settings when running in an container 175 | export MAVEN_OPTS="$(run-java.sh options --memory)" 176 | mvn clean install 177 | ``` 178 | 179 | 180 | ### Versions: 181 | 182 | * Base-Image: **CentOS 7** 183 | * Java: **OpenJDK 11 11** (Java Development Kit (JDK)) 184 | * Agent-Bond: **1.2.0** (Jolokia 1.7.1, jmx_exporter 0.3.1) 185 | -------------------------------------------------------------------------------- /images/centos/openjdk11/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/centos/openjdk11/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/centos/openjdk11/jre/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7.9.2009 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=11 10 | 11 | 12 | # /dev/urandom is used as random source, which is prefectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN yum install -y \ 15 | java-11-openjdk-11.0.18.0.10-1.el7_9 \ 16 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 17 | && yum clean all 18 | 19 | ENV JAVA_HOME /etc/alternatives/jre 20 | 21 | # Agent bond including Jolokia and jmx_exporter 22 | ADD agent-bond-opts /opt/run-java-options 23 | RUN mkdir -p /opt/agent-bond \ 24 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 25 | -o /opt/agent-bond/agent-bond.jar \ 26 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 27 | && chmod 755 /opt/run-java-options 28 | ADD jmx_exporter_config.yml /opt/agent-bond/ 29 | EXPOSE 8778 9779 30 | 31 | # Add run script as /deployments/run-java.sh and make it executable 32 | COPY run-java.sh /deployments/ 33 | RUN chmod 755 /deployments/run-java.sh 34 | 35 | 36 | 37 | # Run under user "jboss" and prepare for be running 38 | # under OpenShift, too 39 | RUN groupadd -r jboss -g 1000 \ 40 | && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin jboss \ 41 | && chmod 755 /opt/jboss \ 42 | && chown -R jboss /deployments \ 43 | && usermod -g root -G `id -g jboss` jboss \ 44 | && chmod -R "g+rwX" /deployments \ 45 | && chown -R jboss:root /deployments 46 | 47 | USER jboss 48 | 49 | 50 | CMD [ "/deployments/run-java.sh" ] 51 | -------------------------------------------------------------------------------- /images/centos/openjdk11/jre/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/centos/openjdk11/jre/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/centos/openjdk7/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7.9.2009 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=7 10 | 11 | 12 | # /dev/urandom is used as random source, which is prefectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN yum install -y \ 15 | java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8 \ 16 | java-1.7.0-openjdk-devel-1.7.0.261-2.6.22.2.el7_8 \ 17 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 18 | && yum clean all 19 | 20 | ENV JAVA_HOME /etc/alternatives/jre 21 | 22 | # Agent bond including Jolokia and jmx_exporter 23 | ADD agent-bond-opts /opt/run-java-options 24 | RUN mkdir -p /opt/agent-bond \ 25 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 26 | -o /opt/agent-bond/agent-bond.jar \ 27 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 28 | && chmod 755 /opt/run-java-options 29 | ADD jmx_exporter_config.yml /opt/agent-bond/ 30 | EXPOSE 8778 9779 31 | 32 | # Add run script as /deployments/run-java.sh and make it executable 33 | COPY run-java.sh /deployments/ 34 | RUN chmod 755 /deployments/run-java.sh 35 | 36 | 37 | 38 | # Run under user "jboss" and prepare for be running 39 | # under OpenShift, too 40 | RUN groupadd -r jboss -g 1000 \ 41 | && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin jboss \ 42 | && chmod 755 /opt/jboss \ 43 | && chown -R jboss /deployments \ 44 | && usermod -g root -G `id -g jboss` jboss \ 45 | && chmod -R "g+rwX" /deployments \ 46 | && chown -R jboss:root /deployments 47 | 48 | USER jboss 49 | 50 | 51 | CMD [ "/deployments/run-java.sh" ] 52 | -------------------------------------------------------------------------------- /images/centos/openjdk7/jdk/README.md: -------------------------------------------------------------------------------- 1 | ## Fabric8 Java Base Image OpenJDK 7 (JDK) 2 | 3 | 4 | 5 | This image is based on CentOS and provides OpenJDK 7 (JDK) 6 | 7 | It includes: 8 | 9 | 10 | * An [Agent Bond](https://github.com/fabric8io/agent-bond) agent with [Jolokia](http://www.jolokia.org) and Prometheus' [jmx_exporter](https://github.com/prometheus/jmx_exporter). The agent is installed as `/opt/agent-bond/agent-bond.jar`. See below for configuration options. 11 | 12 | 13 | * A startup script [`/deployments/run-java.sh`](#startup-script-run-javash) for starting up Java applications. 14 | 15 | ### Agent Bond 16 | 17 | In order to enable Jolokia for your application you should use this image as a base image (via `FROM`) and use the output of `agent-bond-opts` in your startup scripts to include it in for the Java startup options. 18 | 19 | For example, the following snippet can be added to a script starting up your Java application 20 | 21 | # ... 22 | export JAVA_OPTIONS="$JAVA_OPTIONS $(agent-bond-opts)" 23 | # .... use JAVA_OPTIONS when starting your app, e.g. as Tomcat does 24 | 25 | The following versions and defaults are used: 26 | 27 | * [Jolokia](http://www.jolokia.org) : version **1.7.1** and port **8778** 28 | * [jmx_exporter](https://github.com/prometheus/jmx_exporter): version **0.3.1** and port **9779** 29 | 30 | You can influence the behaviour of `agent-bond-opts` by setting various environment variables: 31 | 32 | ### Agent-Bond Options 33 | 34 | Agent bond itself can be influenced with the following environment variables: 35 | 36 | * **AB_OFF** : If set disables activation of agent-bond (i.e. echos an empty value). By default, agent-bond is enabled. 37 | * **AB_ENABLED** : Comma separated list of sub-agents enabled. Currently allowed values are `jolokia` and `jmx_exporter`. 38 | By default both are enabled. 39 | 40 | 41 | #### Jolokia configuration 42 | 43 | * **AB_JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 44 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 45 | By default this is `/opt/jolokia/jolokia.properties`. 46 | * **AB_JOLOKIA_HOST** : Host address to bind to (Default: `0.0.0.0`) 47 | * **AB_JOLOKIA_PORT** : Port to use (Default: `8778`) 48 | * **AB_JOLOKIA_USER** : User for authentication. By default authentication is switched off. 49 | * **AB_JOLOKIA_HTTPS** : Switch on secure communication with https. By default self signed server certificates are generated 50 | if no `serverCert` configuration is given in `AB_JOLOKIA_OPTS` 51 | * **AB_JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 52 | * **AB_JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 53 | * **AB_JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 54 | "key=value,key=value,..." 55 | 56 | Some options for integration in various environments: 57 | 58 | * **AB_JOLOKIA_AUTH_OPENSHIFT** : Switch on client authentication for OpenShift TLS communication. The value of this 59 | parameter can be a relative distinguished name which must be contained in a presented client certificate. Enabling this 60 | parameter will automatically switch Jolokia into https communication mode. The default CA cert is set to 61 | `/var/run/secrets/kubernetes.io/serviceaccount/ca.crt` 62 | 63 | #### jmx_exporter configuration 64 | 65 | * **AB_JMX_EXPORTER_OPTS** : Configuration to use for `jmx_exporter` (in the format `:`) 66 | * **AB_JMX_EXPORTER_PORT** : Port to use for the JMX Exporter. Default: `9779` 67 | * **AB_JMX_EXPORTER_CONFIG** : Path to configuration to use for `jmx_exporter`: Default: `/opt/agent-bond/jmx_exporter_config.json` 68 | 69 | 70 | 71 | ### Startup Script run-java.sh 72 | 73 | The default command for this image is [/deployments/run-java.sh](https://github.com/fabric8io/run-java-sh). Its purpose it to fire up Java applications which are provided as fat-jars, including all dependencies or more classical from a main class, where the classpath is build up from all jars within a directory. 74 | 75 | For these images the variable **JAVA_APP_DIR** has the default value `/deployments` 76 | 77 | 78 | ### run-java.sh 79 | 80 | This general purpose startup script is optimized for running Java application from within containers. It is called like 81 | 82 | ``` 83 | ./run-java.sh 84 | ``` 85 | `run-java.sh` knows two sub-commands: 86 | 87 | * `options` to print out JVM option which can be used for own invocation of Java apps (like Maven or Tomcat). It respects container constraints and includes all magic which is used by this script 88 | * `run` executes a Java application as described below. This is also the default command so you can skip adding this command. 89 | 90 | ### Running a Java application 91 | 92 | When no subcommand is given (or when you provide the default subcommand `run`), then by default this scripts starts up Java application. 93 | 94 | The startup process is configured mostly via environment variables: 95 | 96 | * **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides. 97 | * **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**. 98 | * **JAVA_OPTIONS** options to add when calling `java` 99 | * **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output. 100 | * **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added. 101 | * **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set. 102 | * **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed. 103 | * **JAVA_DIAGNOSTICS** set this to get some diagnostics information to standard out when things are happening 104 | * **JAVA_MAIN_CLASS** A main class to use as argument for `java`. When this environment variable is given, all jar files in `$JAVA_APP_DIR` are added to the classpath as well as `$JAVA_LIB_DIR`. 105 | * **JAVA_APP_JAR** A jar file with an appropriate manifest so that it can be started with `java -jar` if no `$JAVA_MAIN_CLASS` is set. In all cases this jar file is added to the classpath, too. 106 | * **JAVA_APP_NAME** Name to use for the process 107 | * **JAVA_CLASSPATH** the classpath to use. If not given, the startup script checks for a file `${JAVA_APP_DIR}/classpath` and use its content literally as classpath. If this file doesn't exists all jars in the app dir are added (`classes:${JAVA_APP_DIR}/*`). 108 | * **JAVA_DEBUG** If set remote debugging will be switched on 109 | * **JAVA_DEBUG_SUSPEND** If set enables suspend mode in remote debugging 110 | * **JAVA_DEBUG_PORT** Port used for remote debugging. Default: 5005 111 | * **HTTP_PROXY** The URL of the proxy server that translates into the `http.proxyHost` and `http.proxyPort` system properties. 112 | * **HTTPS_PROXY** The URL of the proxy server that translates into the `https.proxyHost` and `https.proxyPort` system properties. 113 | * **no_proxy**, **NO_PROXY** The list of hosts that should be reached directly, bypassing the proxy, that translates into the `http.nonProxyHosts` system property. 114 | 115 | If neither `$JAVA_APP_JAR` nor `$JAVA_MAIN_CLASS` is given, `$JAVA_APP_DIR` is checked for a single JAR file which is taken as `$JAVA_APP_JAR`. If no or more then one jar file is found, an error is thrown. 116 | 117 | The classpath is build up with the following parts: 118 | 119 | * If `$JAVA_CLASSPATH` is set, this classpath is taken. 120 | * The current directory (".") is added first. 121 | * If the current directory is not the same as `$JAVA_APP_DIR`, `$JAVA_APP_DIR` is added. 122 | * If `$JAVA_MAIN_CLASS` is set, then 123 | - A `$JAVA_APP_JAR` is added if set 124 | - If a file `$JAVA_APP_DIR/classpath` exists, its content is appended to the classpath. This file 125 | can be either a single line with the jar files colon separated or a multi-line file where each line 126 | holds the path of the jar file relative to `$JAVA_LIB_DIR` (which by default is the `$JAVA_APP_DIR`) 127 | - If this file is not set, a `${JAVA_APP_DIR}/*` is added which effectively adds all 128 | jars in this directory in alphabetical order. 129 | 130 | These variables can be also set in a shell config file `run-env.sh`, which will be sourced by the startup script. This file can be located in the directory where the startup script is located and in `${JAVA_APP_DIR}`, whereas environment variables in the latter override the ones in `run-env.sh` from the script directory. 131 | 132 | This startup script also checks for a command `run-java-options`. If existent it will be called and the output is added to the environment variable `$JAVA_OPTIONS`. 133 | 134 | The startup script also exposes some environment variables describing container limits which can be used by applications: 135 | 136 | * **CONTAINER_CORE_LIMIT** a calculated core limit as described in https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt 137 | * **CONTAINER_MAX_MEMORY** memory limit given to the container 138 | 139 | Any arguments given to the script are given through directly as argument to the Java application. 140 | 141 | Example: 142 | 143 | ``` 144 | # Set the application directory directly 145 | export JAVA_APP_DIR=/deployments 146 | # Set -Xmx based on container constraints 147 | export JAVA_MAX_MEM_RATIO=40 148 | # Start the jar in JAVA_APP_DIR with the given arguments 149 | ./run-java.sh --user maxmorlock --password secret 150 | ``` 151 | 152 | ### Options 153 | 154 | This script can also be used to calculate reasonable, best-practice options for starting Java apps in general. For example, when running Maven in a container it makes sense to respect container Memory constraints. 155 | 156 | The subcommand `options` can be used to print options to standard output so that is can be easily used to feed it to another, Java based application. 157 | 158 | When no extra arguments are given, all defaults will be used, which can be influenced with the environment variables described above. 159 | 160 | You can select specific sets of options by providing additional arguments: 161 | 162 | * `--debug` : Java debug options if `JAVA_DEBUG` is set 163 | * `--memory` : Memory settings based on the environment variables given 164 | * `--proxy` : Evaluate proxy environments variables 165 | * `--cpu` : Tuning when the number of cores is limited 166 | * `--gc` : GC tuning parameters 167 | * `--jit` : JIT options 168 | * `--diagnostics` : Print diagnostics options when `JAVA_DIAGNOSTICS` is set 169 | * `--java-default` : Same as `--memory --jit --diagnostic --cpu --gc` 170 | 171 | Example: 172 | 173 | ``` 174 | # Call Maven with the proper memory settings when running in an container 175 | export MAVEN_OPTS="$(run-java.sh options --memory)" 176 | mvn clean install 177 | ``` 178 | 179 | 180 | ### Versions: 181 | 182 | * Base-Image: **CentOS 7** 183 | * Java: **OpenJDK 7 1.7.0** (Java Development Kit (JDK)) 184 | * Agent-Bond: **1.2.0** (Jolokia 1.7.1, jmx_exporter 0.3.1) 185 | -------------------------------------------------------------------------------- /images/centos/openjdk7/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/centos/openjdk7/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/centos/openjdk7/jre/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7.9.2009 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=7 10 | 11 | 12 | # /dev/urandom is used as random source, which is prefectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN yum install -y \ 15 | java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8 \ 16 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 17 | && yum clean all 18 | 19 | ENV JAVA_HOME /etc/alternatives/jre 20 | 21 | # Agent bond including Jolokia and jmx_exporter 22 | ADD agent-bond-opts /opt/run-java-options 23 | RUN mkdir -p /opt/agent-bond \ 24 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 25 | -o /opt/agent-bond/agent-bond.jar \ 26 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 27 | && chmod 755 /opt/run-java-options 28 | ADD jmx_exporter_config.yml /opt/agent-bond/ 29 | EXPOSE 8778 9779 30 | 31 | # Add run script as /deployments/run-java.sh and make it executable 32 | COPY run-java.sh /deployments/ 33 | RUN chmod 755 /deployments/run-java.sh 34 | 35 | 36 | 37 | # Run under user "jboss" and prepare for be running 38 | # under OpenShift, too 39 | RUN groupadd -r jboss -g 1000 \ 40 | && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin jboss \ 41 | && chmod 755 /opt/jboss \ 42 | && chown -R jboss /deployments \ 43 | && usermod -g root -G `id -g jboss` jboss \ 44 | && chmod -R "g+rwX" /deployments \ 45 | && chown -R jboss:root /deployments 46 | 47 | USER jboss 48 | 49 | 50 | CMD [ "/deployments/run-java.sh" ] 51 | -------------------------------------------------------------------------------- /images/centos/openjdk7/jre/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/centos/openjdk7/jre/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/centos/openjdk8/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7.9.2009 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=8 10 | 11 | 12 | # /dev/urandom is used as random source, which is prefectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN yum install -y \ 15 | java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9 \ 16 | java-1.8.0-openjdk-devel-1.8.0.312.b07-1.el7_9 \ 17 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 18 | && yum clean all 19 | 20 | ENV JAVA_HOME /etc/alternatives/jre 21 | 22 | # Agent bond including Jolokia and jmx_exporter 23 | ADD agent-bond-opts /opt/run-java-options 24 | RUN mkdir -p /opt/agent-bond \ 25 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 26 | -o /opt/agent-bond/agent-bond.jar \ 27 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 28 | && chmod 755 /opt/run-java-options 29 | ADD jmx_exporter_config.yml /opt/agent-bond/ 30 | EXPOSE 8778 9779 31 | 32 | # Add run script as /deployments/run-java.sh and make it executable 33 | COPY run-java.sh /deployments/ 34 | RUN chmod 755 /deployments/run-java.sh 35 | 36 | 37 | 38 | # Run under user "jboss" and prepare for be running 39 | # under OpenShift, too 40 | RUN groupadd -r jboss -g 1000 \ 41 | && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin jboss \ 42 | && chmod 755 /opt/jboss \ 43 | && chown -R jboss /deployments \ 44 | && usermod -g root -G `id -g jboss` jboss \ 45 | && chmod -R "g+rwX" /deployments \ 46 | && chown -R jboss:root /deployments 47 | 48 | USER jboss 49 | 50 | 51 | CMD [ "/deployments/run-java.sh" ] 52 | -------------------------------------------------------------------------------- /images/centos/openjdk8/jdk/README.md: -------------------------------------------------------------------------------- 1 | ## Fabric8 Java Base Image OpenJDK 8 (JDK) 2 | 3 | 4 | 5 | This image is based on CentOS and provides OpenJDK 8 (JDK) 6 | 7 | It includes: 8 | 9 | 10 | * An [Agent Bond](https://github.com/fabric8io/agent-bond) agent with [Jolokia](http://www.jolokia.org) and Prometheus' [jmx_exporter](https://github.com/prometheus/jmx_exporter). The agent is installed as `/opt/agent-bond/agent-bond.jar`. See below for configuration options. 11 | 12 | 13 | * A startup script [`/deployments/run-java.sh`](#startup-script-run-javash) for starting up Java applications. 14 | 15 | ### Agent Bond 16 | 17 | In order to enable Jolokia for your application you should use this image as a base image (via `FROM`) and use the output of `agent-bond-opts` in your startup scripts to include it in for the Java startup options. 18 | 19 | For example, the following snippet can be added to a script starting up your Java application 20 | 21 | # ... 22 | export JAVA_OPTIONS="$JAVA_OPTIONS $(agent-bond-opts)" 23 | # .... use JAVA_OPTIONS when starting your app, e.g. as Tomcat does 24 | 25 | The following versions and defaults are used: 26 | 27 | * [Jolokia](http://www.jolokia.org) : version **1.7.1** and port **8778** 28 | * [jmx_exporter](https://github.com/prometheus/jmx_exporter): version **0.3.1** and port **9779** 29 | 30 | You can influence the behaviour of `agent-bond-opts` by setting various environment variables: 31 | 32 | ### Agent-Bond Options 33 | 34 | Agent bond itself can be influenced with the following environment variables: 35 | 36 | * **AB_OFF** : If set disables activation of agent-bond (i.e. echos an empty value). By default, agent-bond is enabled. 37 | * **AB_ENABLED** : Comma separated list of sub-agents enabled. Currently allowed values are `jolokia` and `jmx_exporter`. 38 | By default both are enabled. 39 | 40 | 41 | #### Jolokia configuration 42 | 43 | * **AB_JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 44 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 45 | By default this is `/opt/jolokia/jolokia.properties`. 46 | * **AB_JOLOKIA_HOST** : Host address to bind to (Default: `0.0.0.0`) 47 | * **AB_JOLOKIA_PORT** : Port to use (Default: `8778`) 48 | * **AB_JOLOKIA_USER** : User for authentication. By default authentication is switched off. 49 | * **AB_JOLOKIA_HTTPS** : Switch on secure communication with https. By default self signed server certificates are generated 50 | if no `serverCert` configuration is given in `AB_JOLOKIA_OPTS` 51 | * **AB_JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 52 | * **AB_JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 53 | * **AB_JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 54 | "key=value,key=value,..." 55 | 56 | Some options for integration in various environments: 57 | 58 | * **AB_JOLOKIA_AUTH_OPENSHIFT** : Switch on client authentication for OpenShift TLS communication. The value of this 59 | parameter can be a relative distinguished name which must be contained in a presented client certificate. Enabling this 60 | parameter will automatically switch Jolokia into https communication mode. The default CA cert is set to 61 | `/var/run/secrets/kubernetes.io/serviceaccount/ca.crt` 62 | 63 | #### jmx_exporter configuration 64 | 65 | * **AB_JMX_EXPORTER_OPTS** : Configuration to use for `jmx_exporter` (in the format `:`) 66 | * **AB_JMX_EXPORTER_PORT** : Port to use for the JMX Exporter. Default: `9779` 67 | * **AB_JMX_EXPORTER_CONFIG** : Path to configuration to use for `jmx_exporter`: Default: `/opt/agent-bond/jmx_exporter_config.json` 68 | 69 | 70 | 71 | ### Startup Script run-java.sh 72 | 73 | The default command for this image is [/deployments/run-java.sh](https://github.com/fabric8io/run-java-sh). Its purpose it to fire up Java applications which are provided as fat-jars, including all dependencies or more classical from a main class, where the classpath is build up from all jars within a directory. 74 | 75 | For these images the variable **JAVA_APP_DIR** has the default value `/deployments` 76 | 77 | 78 | ### run-java.sh 79 | 80 | This general purpose startup script is optimized for running Java application from within containers. It is called like 81 | 82 | ``` 83 | ./run-java.sh 84 | ``` 85 | `run-java.sh` knows two sub-commands: 86 | 87 | * `options` to print out JVM option which can be used for own invocation of Java apps (like Maven or Tomcat). It respects container constraints and includes all magic which is used by this script 88 | * `run` executes a Java application as described below. This is also the default command so you can skip adding this command. 89 | 90 | ### Running a Java application 91 | 92 | When no subcommand is given (or when you provide the default subcommand `run`), then by default this scripts starts up Java application. 93 | 94 | The startup process is configured mostly via environment variables: 95 | 96 | * **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides. 97 | * **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**. 98 | * **JAVA_OPTIONS** options to add when calling `java` 99 | * **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output. 100 | * **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added. 101 | * **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set. 102 | * **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed. 103 | * **JAVA_DIAGNOSTICS** set this to get some diagnostics information to standard out when things are happening 104 | * **JAVA_MAIN_CLASS** A main class to use as argument for `java`. When this environment variable is given, all jar files in `$JAVA_APP_DIR` are added to the classpath as well as `$JAVA_LIB_DIR`. 105 | * **JAVA_APP_JAR** A jar file with an appropriate manifest so that it can be started with `java -jar` if no `$JAVA_MAIN_CLASS` is set. In all cases this jar file is added to the classpath, too. 106 | * **JAVA_APP_NAME** Name to use for the process 107 | * **JAVA_CLASSPATH** the classpath to use. If not given, the startup script checks for a file `${JAVA_APP_DIR}/classpath` and use its content literally as classpath. If this file doesn't exists all jars in the app dir are added (`classes:${JAVA_APP_DIR}/*`). 108 | * **JAVA_DEBUG** If set remote debugging will be switched on 109 | * **JAVA_DEBUG_SUSPEND** If set enables suspend mode in remote debugging 110 | * **JAVA_DEBUG_PORT** Port used for remote debugging. Default: 5005 111 | * **HTTP_PROXY** The URL of the proxy server that translates into the `http.proxyHost` and `http.proxyPort` system properties. 112 | * **HTTPS_PROXY** The URL of the proxy server that translates into the `https.proxyHost` and `https.proxyPort` system properties. 113 | * **no_proxy**, **NO_PROXY** The list of hosts that should be reached directly, bypassing the proxy, that translates into the `http.nonProxyHosts` system property. 114 | 115 | If neither `$JAVA_APP_JAR` nor `$JAVA_MAIN_CLASS` is given, `$JAVA_APP_DIR` is checked for a single JAR file which is taken as `$JAVA_APP_JAR`. If no or more then one jar file is found, an error is thrown. 116 | 117 | The classpath is build up with the following parts: 118 | 119 | * If `$JAVA_CLASSPATH` is set, this classpath is taken. 120 | * The current directory (".") is added first. 121 | * If the current directory is not the same as `$JAVA_APP_DIR`, `$JAVA_APP_DIR` is added. 122 | * If `$JAVA_MAIN_CLASS` is set, then 123 | - A `$JAVA_APP_JAR` is added if set 124 | - If a file `$JAVA_APP_DIR/classpath` exists, its content is appended to the classpath. This file 125 | can be either a single line with the jar files colon separated or a multi-line file where each line 126 | holds the path of the jar file relative to `$JAVA_LIB_DIR` (which by default is the `$JAVA_APP_DIR`) 127 | - If this file is not set, a `${JAVA_APP_DIR}/*` is added which effectively adds all 128 | jars in this directory in alphabetical order. 129 | 130 | These variables can be also set in a shell config file `run-env.sh`, which will be sourced by the startup script. This file can be located in the directory where the startup script is located and in `${JAVA_APP_DIR}`, whereas environment variables in the latter override the ones in `run-env.sh` from the script directory. 131 | 132 | This startup script also checks for a command `run-java-options`. If existent it will be called and the output is added to the environment variable `$JAVA_OPTIONS`. 133 | 134 | The startup script also exposes some environment variables describing container limits which can be used by applications: 135 | 136 | * **CONTAINER_CORE_LIMIT** a calculated core limit as described in https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt 137 | * **CONTAINER_MAX_MEMORY** memory limit given to the container 138 | 139 | Any arguments given to the script are given through directly as argument to the Java application. 140 | 141 | Example: 142 | 143 | ``` 144 | # Set the application directory directly 145 | export JAVA_APP_DIR=/deployments 146 | # Set -Xmx based on container constraints 147 | export JAVA_MAX_MEM_RATIO=40 148 | # Start the jar in JAVA_APP_DIR with the given arguments 149 | ./run-java.sh --user maxmorlock --password secret 150 | ``` 151 | 152 | ### Options 153 | 154 | This script can also be used to calculate reasonable, best-practice options for starting Java apps in general. For example, when running Maven in a container it makes sense to respect container Memory constraints. 155 | 156 | The subcommand `options` can be used to print options to standard output so that is can be easily used to feed it to another, Java based application. 157 | 158 | When no extra arguments are given, all defaults will be used, which can be influenced with the environment variables described above. 159 | 160 | You can select specific sets of options by providing additional arguments: 161 | 162 | * `--debug` : Java debug options if `JAVA_DEBUG` is set 163 | * `--memory` : Memory settings based on the environment variables given 164 | * `--proxy` : Evaluate proxy environments variables 165 | * `--cpu` : Tuning when the number of cores is limited 166 | * `--gc` : GC tuning parameters 167 | * `--jit` : JIT options 168 | * `--diagnostics` : Print diagnostics options when `JAVA_DIAGNOSTICS` is set 169 | * `--java-default` : Same as `--memory --jit --diagnostic --cpu --gc` 170 | 171 | Example: 172 | 173 | ``` 174 | # Call Maven with the proper memory settings when running in an container 175 | export MAVEN_OPTS="$(run-java.sh options --memory)" 176 | mvn clean install 177 | ``` 178 | 179 | 180 | ### Versions: 181 | 182 | * Base-Image: **CentOS 7** 183 | * Java: **OpenJDK 8 1.8.0** (Java Development Kit (JDK)) 184 | * Agent-Bond: **1.2.0** (Jolokia 1.7.1, jmx_exporter 0.3.1) 185 | -------------------------------------------------------------------------------- /images/centos/openjdk8/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/centos/openjdk8/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/centos/openjdk8/jre/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7.9.2009 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=8 10 | 11 | 12 | # /dev/urandom is used as random source, which is prefectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN yum install -y \ 15 | java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9 \ 16 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 17 | && yum clean all 18 | 19 | ENV JAVA_HOME /etc/alternatives/jre 20 | 21 | # Agent bond including Jolokia and jmx_exporter 22 | ADD agent-bond-opts /opt/run-java-options 23 | RUN mkdir -p /opt/agent-bond \ 24 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 25 | -o /opt/agent-bond/agent-bond.jar \ 26 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 27 | && chmod 755 /opt/run-java-options 28 | ADD jmx_exporter_config.yml /opt/agent-bond/ 29 | EXPOSE 8778 9779 30 | 31 | # Add run script as /deployments/run-java.sh and make it executable 32 | COPY run-java.sh /deployments/ 33 | RUN chmod 755 /deployments/run-java.sh 34 | 35 | 36 | 37 | # Run under user "jboss" and prepare for be running 38 | # under OpenShift, too 39 | RUN groupadd -r jboss -g 1000 \ 40 | && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin jboss \ 41 | && chmod 755 /opt/jboss \ 42 | && chown -R jboss /deployments \ 43 | && usermod -g root -G `id -g jboss` jboss \ 44 | && chmod -R "g+rwX" /deployments \ 45 | && chown -R jboss:root /deployments 46 | 47 | USER jboss 48 | 49 | 50 | CMD [ "/deployments/run-java.sh" ] 51 | -------------------------------------------------------------------------------- /images/centos/openjdk8/jre/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/centos/openjdk8/jre/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/jboss/openjdk7/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jboss/base-jdk:7 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=7 10 | 11 | 12 | # Agent bond including Jolokia and jmx_exporter 13 | ADD agent-bond-opts /opt/run-java-options 14 | RUN mkdir -p /opt/agent-bond \ 15 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 16 | -o /opt/agent-bond/agent-bond.jar \ 17 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 18 | && chmod 755 /opt/run-java-options 19 | ADD jmx_exporter_config.yml /opt/agent-bond/ 20 | EXPOSE 8778 9779 21 | 22 | # Add run script as /deployments/run-java.sh and make it executable 23 | COPY run-java.sh /deployments/ 24 | RUN chmod 755 /deployments/run-java.sh 25 | 26 | 27 | 28 | # Run under user "jboss" and prepare for be running 29 | # under OpenShift, too 30 | RUN chown -R jboss /deployments \ 31 | && usermod -g root -G `id -g jboss` jboss \ 32 | && chmod -R "g+rwX" /deployments \ 33 | && chown -R jboss:root /deployments 34 | 35 | USER jboss 36 | 37 | 38 | CMD [ "/deployments/run-java.sh" ] 39 | -------------------------------------------------------------------------------- /images/jboss/openjdk7/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/jboss/openjdk7/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/jboss/openjdk8/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jboss/base-jdk:8 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=8 10 | 11 | 12 | # Agent bond including Jolokia and jmx_exporter 13 | ADD agent-bond-opts /opt/run-java-options 14 | RUN mkdir -p /opt/agent-bond \ 15 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 16 | -o /opt/agent-bond/agent-bond.jar \ 17 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 18 | && chmod 755 /opt/run-java-options 19 | ADD jmx_exporter_config.yml /opt/agent-bond/ 20 | EXPOSE 8778 9779 21 | 22 | # Add run script as /deployments/run-java.sh and make it executable 23 | COPY run-java.sh /deployments/ 24 | RUN chmod 755 /deployments/run-java.sh 25 | 26 | 27 | 28 | # Run under user "jboss" and prepare for be running 29 | # under OpenShift, too 30 | RUN chown -R jboss /deployments \ 31 | && usermod -g root -G `id -g jboss` jboss \ 32 | && chmod -R "g+rwX" /deployments \ 33 | && chown -R jboss:root /deployments 34 | 35 | USER jboss 36 | 37 | 38 | CMD [ "/deployments/run-java.sh" ] 39 | -------------------------------------------------------------------------------- /images/jboss/openjdk8/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/jboss/openjdk8/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/ubi/openjdk11/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4-212 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=11 10 | 11 | 12 | # /dev/urandom is used as random source, which is prefectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN microdnf install java-11-openjdk-headless-11.0.13.0.8-1.el8_4 \ 15 | openssl curl ca-certificates \ 16 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 17 | && microdnf clean all 18 | 19 | ENV JAVA_HOME /etc/alternatives/jre 20 | 21 | # Agent bond including Jolokia and jmx_exporter 22 | ADD agent-bond-opts /opt/run-java-options 23 | RUN mkdir -p /opt/agent-bond \ 24 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 25 | -o /opt/agent-bond/agent-bond.jar \ 26 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 27 | && chmod 755 /opt/run-java-options 28 | ADD jmx_exporter_config.yml /opt/agent-bond/ 29 | EXPOSE 8778 9779 30 | 31 | # Add run script as /deployments/run-java.sh and make it executable 32 | COPY run-java.sh /deployments/ 33 | RUN chmod 755 /deployments/run-java.sh 34 | 35 | 36 | 37 | 38 | # Run under user "1001" and prepare for be running 39 | # under OpenShift, too 40 | RUN chown 1001 /deployments \ 41 | && chmod "g+rwX" /deployments \ 42 | && chown 1001:root /deployments \ 43 | && chmod g+rw /etc/passwd \ 44 | && mkdir -p /deployments/data \ 45 | && chown 1001 /deployments/run-java.sh 46 | 47 | # Gives uid 48 | USER 1001 49 | 50 | CMD [ "/deployments/run-java.sh" ] 51 | -------------------------------------------------------------------------------- /images/ubi/openjdk11/jdk/README.md: -------------------------------------------------------------------------------- 1 | ## Fabric8 Java Base Image OpenJDK 11 (JDK) 2 | 3 | 4 | 5 | This image is based on UBI and provides OpenJDK 11 (JDK) 6 | 7 | It includes: 8 | 9 | 10 | * An [Agent Bond](https://github.com/fabric8io/agent-bond) agent with [Jolokia](http://www.jolokia.org) and Prometheus' [jmx_exporter](https://github.com/prometheus/jmx_exporter). The agent is installed as `/opt/agent-bond/agent-bond.jar`. See below for configuration options. 11 | 12 | 13 | * A startup script [`/deployments/run-java.sh`](#startup-script-run-javash) for starting up Java applications. 14 | 15 | ### Agent Bond 16 | 17 | In order to enable Jolokia for your application you should use this image as a base image (via `FROM`) and use the output of `agent-bond-opts` in your startup scripts to include it in for the Java startup options. 18 | 19 | For example, the following snippet can be added to a script starting up your Java application 20 | 21 | # ... 22 | export JAVA_OPTIONS="$JAVA_OPTIONS $(agent-bond-opts)" 23 | # .... use JAVA_OPTIONS when starting your app, e.g. as Tomcat does 24 | 25 | The following versions and defaults are used: 26 | 27 | * [Jolokia](http://www.jolokia.org) : version **1.7.1** and port **8778** 28 | * [jmx_exporter](https://github.com/prometheus/jmx_exporter): version **0.3.1** and port **9779** 29 | 30 | You can influence the behaviour of `agent-bond-opts` by setting various environment variables: 31 | 32 | ### Agent-Bond Options 33 | 34 | Agent bond itself can be influenced with the following environment variables: 35 | 36 | * **AB_OFF** : If set disables activation of agent-bond (i.e. echos an empty value). By default, agent-bond is enabled. 37 | * **AB_ENABLED** : Comma separated list of sub-agents enabled. Currently allowed values are `jolokia` and `jmx_exporter`. 38 | By default both are enabled. 39 | 40 | 41 | #### Jolokia configuration 42 | 43 | * **AB_JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 44 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 45 | By default this is `/opt/jolokia/jolokia.properties`. 46 | * **AB_JOLOKIA_HOST** : Host address to bind to (Default: `0.0.0.0`) 47 | * **AB_JOLOKIA_PORT** : Port to use (Default: `8778`) 48 | * **AB_JOLOKIA_USER** : User for authentication. By default authentication is switched off. 49 | * **AB_JOLOKIA_HTTPS** : Switch on secure communication with https. By default self signed server certificates are generated 50 | if no `serverCert` configuration is given in `AB_JOLOKIA_OPTS` 51 | * **AB_JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 52 | * **AB_JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 53 | * **AB_JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 54 | "key=value,key=value,..." 55 | 56 | Some options for integration in various environments: 57 | 58 | * **AB_JOLOKIA_AUTH_OPENSHIFT** : Switch on client authentication for OpenShift TLS communication. The value of this 59 | parameter can be a relative distinguished name which must be contained in a presented client certificate. Enabling this 60 | parameter will automatically switch Jolokia into https communication mode. The default CA cert is set to 61 | `/var/run/secrets/kubernetes.io/serviceaccount/ca.crt` 62 | 63 | #### jmx_exporter configuration 64 | 65 | * **AB_JMX_EXPORTER_OPTS** : Configuration to use for `jmx_exporter` (in the format `:`) 66 | * **AB_JMX_EXPORTER_PORT** : Port to use for the JMX Exporter. Default: `9779` 67 | * **AB_JMX_EXPORTER_CONFIG** : Path to configuration to use for `jmx_exporter`: Default: `/opt/agent-bond/jmx_exporter_config.json` 68 | 69 | 70 | 71 | ### Startup Script run-java.sh 72 | 73 | The default command for this image is [/deployments/run-java.sh](https://github.com/fabric8io/run-java-sh). Its purpose it to fire up Java applications which are provided as fat-jars, including all dependencies or more classical from a main class, where the classpath is build up from all jars within a directory. 74 | 75 | For these images the variable **JAVA_APP_DIR** has the default value `/deployments` 76 | 77 | 78 | ### run-java.sh 79 | 80 | This general purpose startup script is optimized for running Java application from within containers. It is called like 81 | 82 | ``` 83 | ./run-java.sh 84 | ``` 85 | `run-java.sh` knows two sub-commands: 86 | 87 | * `options` to print out JVM option which can be used for own invocation of Java apps (like Maven or Tomcat). It respects container constraints and includes all magic which is used by this script 88 | * `run` executes a Java application as described below. This is also the default command so you can skip adding this command. 89 | 90 | ### Running a Java application 91 | 92 | When no subcommand is given (or when you provide the default subcommand `run`), then by default this scripts starts up Java application. 93 | 94 | The startup process is configured mostly via environment variables: 95 | 96 | * **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides. 97 | * **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**. 98 | * **JAVA_OPTIONS** options to add when calling `java` 99 | * **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output. 100 | * **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added. 101 | * **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set. 102 | * **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed. 103 | * **JAVA_DIAGNOSTICS** set this to get some diagnostics information to standard out when things are happening 104 | * **JAVA_MAIN_CLASS** A main class to use as argument for `java`. When this environment variable is given, all jar files in `$JAVA_APP_DIR` are added to the classpath as well as `$JAVA_LIB_DIR`. 105 | * **JAVA_APP_JAR** A jar file with an appropriate manifest so that it can be started with `java -jar` if no `$JAVA_MAIN_CLASS` is set. In all cases this jar file is added to the classpath, too. 106 | * **JAVA_APP_NAME** Name to use for the process 107 | * **JAVA_CLASSPATH** the classpath to use. If not given, the startup script checks for a file `${JAVA_APP_DIR}/classpath` and use its content literally as classpath. If this file doesn't exists all jars in the app dir are added (`classes:${JAVA_APP_DIR}/*`). 108 | * **JAVA_DEBUG** If set remote debugging will be switched on 109 | * **JAVA_DEBUG_SUSPEND** If set enables suspend mode in remote debugging 110 | * **JAVA_DEBUG_PORT** Port used for remote debugging. Default: 5005 111 | * **HTTP_PROXY** The URL of the proxy server that translates into the `http.proxyHost` and `http.proxyPort` system properties. 112 | * **HTTPS_PROXY** The URL of the proxy server that translates into the `https.proxyHost` and `https.proxyPort` system properties. 113 | * **no_proxy**, **NO_PROXY** The list of hosts that should be reached directly, bypassing the proxy, that translates into the `http.nonProxyHosts` system property. 114 | 115 | If neither `$JAVA_APP_JAR` nor `$JAVA_MAIN_CLASS` is given, `$JAVA_APP_DIR` is checked for a single JAR file which is taken as `$JAVA_APP_JAR`. If no or more then one jar file is found, an error is thrown. 116 | 117 | The classpath is build up with the following parts: 118 | 119 | * If `$JAVA_CLASSPATH` is set, this classpath is taken. 120 | * The current directory (".") is added first. 121 | * If the current directory is not the same as `$JAVA_APP_DIR`, `$JAVA_APP_DIR` is added. 122 | * If `$JAVA_MAIN_CLASS` is set, then 123 | - A `$JAVA_APP_JAR` is added if set 124 | - If a file `$JAVA_APP_DIR/classpath` exists, its content is appended to the classpath. This file 125 | can be either a single line with the jar files colon separated or a multi-line file where each line 126 | holds the path of the jar file relative to `$JAVA_LIB_DIR` (which by default is the `$JAVA_APP_DIR`) 127 | - If this file is not set, a `${JAVA_APP_DIR}/*` is added which effectively adds all 128 | jars in this directory in alphabetical order. 129 | 130 | These variables can be also set in a shell config file `run-env.sh`, which will be sourced by the startup script. This file can be located in the directory where the startup script is located and in `${JAVA_APP_DIR}`, whereas environment variables in the latter override the ones in `run-env.sh` from the script directory. 131 | 132 | This startup script also checks for a command `run-java-options`. If existent it will be called and the output is added to the environment variable `$JAVA_OPTIONS`. 133 | 134 | The startup script also exposes some environment variables describing container limits which can be used by applications: 135 | 136 | * **CONTAINER_CORE_LIMIT** a calculated core limit as described in https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt 137 | * **CONTAINER_MAX_MEMORY** memory limit given to the container 138 | 139 | Any arguments given to the script are given through directly as argument to the Java application. 140 | 141 | Example: 142 | 143 | ``` 144 | # Set the application directory directly 145 | export JAVA_APP_DIR=/deployments 146 | # Set -Xmx based on container constraints 147 | export JAVA_MAX_MEM_RATIO=40 148 | # Start the jar in JAVA_APP_DIR with the given arguments 149 | ./run-java.sh --user maxmorlock --password secret 150 | ``` 151 | 152 | ### Options 153 | 154 | This script can also be used to calculate reasonable, best-practice options for starting Java apps in general. For example, when running Maven in a container it makes sense to respect container Memory constraints. 155 | 156 | The subcommand `options` can be used to print options to standard output so that is can be easily used to feed it to another, Java based application. 157 | 158 | When no extra arguments are given, all defaults will be used, which can be influenced with the environment variables described above. 159 | 160 | You can select specific sets of options by providing additional arguments: 161 | 162 | * `--debug` : Java debug options if `JAVA_DEBUG` is set 163 | * `--memory` : Memory settings based on the environment variables given 164 | * `--proxy` : Evaluate proxy environments variables 165 | * `--cpu` : Tuning when the number of cores is limited 166 | * `--gc` : GC tuning parameters 167 | * `--jit` : JIT options 168 | * `--diagnostics` : Print diagnostics options when `JAVA_DIAGNOSTICS` is set 169 | * `--java-default` : Same as `--memory --jit --diagnostic --cpu --gc` 170 | 171 | Example: 172 | 173 | ``` 174 | # Call Maven with the proper memory settings when running in an container 175 | export MAVEN_OPTS="$(run-java.sh options --memory)" 176 | mvn clean install 177 | ``` 178 | 179 | 180 | ### Versions: 181 | 182 | * Base-Image: **UBI 8.4** 183 | * Java: **OpenJDK 11 11** (Java Development Kit (JDK)) 184 | * Agent-Bond: **1.2.0** (Jolokia 1.7.1, jmx_exporter 0.3.1) 185 | -------------------------------------------------------------------------------- /images/ubi/openjdk11/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/ubi/openjdk11/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /images/ubi/openjdk8/jdk/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4-212 2 | 3 | USER root 4 | 5 | RUN mkdir -p /deployments 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR=/deployments \ 9 | JAVA_MAJOR_VERSION=8 10 | 11 | 12 | # /dev/urandom is used as random source, which is prefectly safe 13 | # according to http://www.2uo.de/myths-about-urandom/ 14 | RUN microdnf install java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el8_4 \ 15 | openssl curl ca-certificates \ 16 | && echo "securerandom.source=file:/dev/urandom" >> /usr/lib/jvm/jre/lib/security/java.security \ 17 | && microdnf clean all 18 | 19 | ENV JAVA_HOME /etc/alternatives/jre 20 | 21 | # Agent bond including Jolokia and jmx_exporter 22 | ADD agent-bond-opts /opt/run-java-options 23 | RUN mkdir -p /opt/agent-bond \ 24 | && curl https://repo.maven.apache.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar \ 25 | -o /opt/agent-bond/agent-bond.jar \ 26 | && chmod 444 /opt/agent-bond/agent-bond.jar \ 27 | && chmod 755 /opt/run-java-options 28 | ADD jmx_exporter_config.yml /opt/agent-bond/ 29 | EXPOSE 8778 9779 30 | 31 | # Add run script as /deployments/run-java.sh and make it executable 32 | COPY run-java.sh /deployments/ 33 | RUN chmod 755 /deployments/run-java.sh 34 | 35 | 36 | 37 | 38 | # Run under user "1001" and prepare for be running 39 | # under OpenShift, too 40 | RUN chown 1001 /deployments \ 41 | && chmod "g+rwX" /deployments \ 42 | && chown 1001:root /deployments \ 43 | && chmod g+rw /etc/passwd \ 44 | && mkdir -p /deployments/data \ 45 | && chown 1001 /deployments/run-java.sh 46 | 47 | # Gives uid 48 | USER 1001 49 | 50 | CMD [ "/deployments/run-java.sh" ] 51 | -------------------------------------------------------------------------------- /images/ubi/openjdk8/jdk/README.md: -------------------------------------------------------------------------------- 1 | ## Fabric8 Java Base Image OpenJDK 8 (JDK) 2 | 3 | 4 | 5 | This image is based on UBI and provides OpenJDK 8 (JDK) 6 | 7 | It includes: 8 | 9 | 10 | * An [Agent Bond](https://github.com/fabric8io/agent-bond) agent with [Jolokia](http://www.jolokia.org) and Prometheus' [jmx_exporter](https://github.com/prometheus/jmx_exporter). The agent is installed as `/opt/agent-bond/agent-bond.jar`. See below for configuration options. 11 | 12 | 13 | * A startup script [`/deployments/run-java.sh`](#startup-script-run-javash) for starting up Java applications. 14 | 15 | ### Agent Bond 16 | 17 | In order to enable Jolokia for your application you should use this image as a base image (via `FROM`) and use the output of `agent-bond-opts` in your startup scripts to include it in for the Java startup options. 18 | 19 | For example, the following snippet can be added to a script starting up your Java application 20 | 21 | # ... 22 | export JAVA_OPTIONS="$JAVA_OPTIONS $(agent-bond-opts)" 23 | # .... use JAVA_OPTIONS when starting your app, e.g. as Tomcat does 24 | 25 | The following versions and defaults are used: 26 | 27 | * [Jolokia](http://www.jolokia.org) : version **1.7.1** and port **8778** 28 | * [jmx_exporter](https://github.com/prometheus/jmx_exporter): version **0.3.1** and port **9779** 29 | 30 | You can influence the behaviour of `agent-bond-opts` by setting various environment variables: 31 | 32 | ### Agent-Bond Options 33 | 34 | Agent bond itself can be influenced with the following environment variables: 35 | 36 | * **AB_OFF** : If set disables activation of agent-bond (i.e. echos an empty value). By default, agent-bond is enabled. 37 | * **AB_ENABLED** : Comma separated list of sub-agents enabled. Currently allowed values are `jolokia` and `jmx_exporter`. 38 | By default both are enabled. 39 | 40 | 41 | #### Jolokia configuration 42 | 43 | * **AB_JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 44 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 45 | By default this is `/opt/jolokia/jolokia.properties`. 46 | * **AB_JOLOKIA_HOST** : Host address to bind to (Default: `0.0.0.0`) 47 | * **AB_JOLOKIA_PORT** : Port to use (Default: `8778`) 48 | * **AB_JOLOKIA_USER** : User for authentication. By default authentication is switched off. 49 | * **AB_JOLOKIA_HTTPS** : Switch on secure communication with https. By default self signed server certificates are generated 50 | if no `serverCert` configuration is given in `AB_JOLOKIA_OPTS` 51 | * **AB_JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 52 | * **AB_JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 53 | * **AB_JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 54 | "key=value,key=value,..." 55 | 56 | Some options for integration in various environments: 57 | 58 | * **AB_JOLOKIA_AUTH_OPENSHIFT** : Switch on client authentication for OpenShift TLS communication. The value of this 59 | parameter can be a relative distinguished name which must be contained in a presented client certificate. Enabling this 60 | parameter will automatically switch Jolokia into https communication mode. The default CA cert is set to 61 | `/var/run/secrets/kubernetes.io/serviceaccount/ca.crt` 62 | 63 | #### jmx_exporter configuration 64 | 65 | * **AB_JMX_EXPORTER_OPTS** : Configuration to use for `jmx_exporter` (in the format `:`) 66 | * **AB_JMX_EXPORTER_PORT** : Port to use for the JMX Exporter. Default: `9779` 67 | * **AB_JMX_EXPORTER_CONFIG** : Path to configuration to use for `jmx_exporter`: Default: `/opt/agent-bond/jmx_exporter_config.json` 68 | 69 | 70 | 71 | ### Startup Script run-java.sh 72 | 73 | The default command for this image is [/deployments/run-java.sh](https://github.com/fabric8io/run-java-sh). Its purpose it to fire up Java applications which are provided as fat-jars, including all dependencies or more classical from a main class, where the classpath is build up from all jars within a directory. 74 | 75 | For these images the variable **JAVA_APP_DIR** has the default value `/deployments` 76 | 77 | 78 | ### run-java.sh 79 | 80 | This general purpose startup script is optimized for running Java application from within containers. It is called like 81 | 82 | ``` 83 | ./run-java.sh 84 | ``` 85 | `run-java.sh` knows two sub-commands: 86 | 87 | * `options` to print out JVM option which can be used for own invocation of Java apps (like Maven or Tomcat). It respects container constraints and includes all magic which is used by this script 88 | * `run` executes a Java application as described below. This is also the default command so you can skip adding this command. 89 | 90 | ### Running a Java application 91 | 92 | When no subcommand is given (or when you provide the default subcommand `run`), then by default this scripts starts up Java application. 93 | 94 | The startup process is configured mostly via environment variables: 95 | 96 | * **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides. 97 | * **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**. 98 | * **JAVA_OPTIONS** options to add when calling `java` 99 | * **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output. 100 | * **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added. 101 | * **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set. 102 | * **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed. 103 | * **JAVA_DIAGNOSTICS** set this to get some diagnostics information to standard out when things are happening 104 | * **JAVA_MAIN_CLASS** A main class to use as argument for `java`. When this environment variable is given, all jar files in `$JAVA_APP_DIR` are added to the classpath as well as `$JAVA_LIB_DIR`. 105 | * **JAVA_APP_JAR** A jar file with an appropriate manifest so that it can be started with `java -jar` if no `$JAVA_MAIN_CLASS` is set. In all cases this jar file is added to the classpath, too. 106 | * **JAVA_APP_NAME** Name to use for the process 107 | * **JAVA_CLASSPATH** the classpath to use. If not given, the startup script checks for a file `${JAVA_APP_DIR}/classpath` and use its content literally as classpath. If this file doesn't exists all jars in the app dir are added (`classes:${JAVA_APP_DIR}/*`). 108 | * **JAVA_DEBUG** If set remote debugging will be switched on 109 | * **JAVA_DEBUG_SUSPEND** If set enables suspend mode in remote debugging 110 | * **JAVA_DEBUG_PORT** Port used for remote debugging. Default: 5005 111 | * **HTTP_PROXY** The URL of the proxy server that translates into the `http.proxyHost` and `http.proxyPort` system properties. 112 | * **HTTPS_PROXY** The URL of the proxy server that translates into the `https.proxyHost` and `https.proxyPort` system properties. 113 | * **no_proxy**, **NO_PROXY** The list of hosts that should be reached directly, bypassing the proxy, that translates into the `http.nonProxyHosts` system property. 114 | 115 | If neither `$JAVA_APP_JAR` nor `$JAVA_MAIN_CLASS` is given, `$JAVA_APP_DIR` is checked for a single JAR file which is taken as `$JAVA_APP_JAR`. If no or more then one jar file is found, an error is thrown. 116 | 117 | The classpath is build up with the following parts: 118 | 119 | * If `$JAVA_CLASSPATH` is set, this classpath is taken. 120 | * The current directory (".") is added first. 121 | * If the current directory is not the same as `$JAVA_APP_DIR`, `$JAVA_APP_DIR` is added. 122 | * If `$JAVA_MAIN_CLASS` is set, then 123 | - A `$JAVA_APP_JAR` is added if set 124 | - If a file `$JAVA_APP_DIR/classpath` exists, its content is appended to the classpath. This file 125 | can be either a single line with the jar files colon separated or a multi-line file where each line 126 | holds the path of the jar file relative to `$JAVA_LIB_DIR` (which by default is the `$JAVA_APP_DIR`) 127 | - If this file is not set, a `${JAVA_APP_DIR}/*` is added which effectively adds all 128 | jars in this directory in alphabetical order. 129 | 130 | These variables can be also set in a shell config file `run-env.sh`, which will be sourced by the startup script. This file can be located in the directory where the startup script is located and in `${JAVA_APP_DIR}`, whereas environment variables in the latter override the ones in `run-env.sh` from the script directory. 131 | 132 | This startup script also checks for a command `run-java-options`. If existent it will be called and the output is added to the environment variable `$JAVA_OPTIONS`. 133 | 134 | The startup script also exposes some environment variables describing container limits which can be used by applications: 135 | 136 | * **CONTAINER_CORE_LIMIT** a calculated core limit as described in https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt 137 | * **CONTAINER_MAX_MEMORY** memory limit given to the container 138 | 139 | Any arguments given to the script are given through directly as argument to the Java application. 140 | 141 | Example: 142 | 143 | ``` 144 | # Set the application directory directly 145 | export JAVA_APP_DIR=/deployments 146 | # Set -Xmx based on container constraints 147 | export JAVA_MAX_MEM_RATIO=40 148 | # Start the jar in JAVA_APP_DIR with the given arguments 149 | ./run-java.sh --user maxmorlock --password secret 150 | ``` 151 | 152 | ### Options 153 | 154 | This script can also be used to calculate reasonable, best-practice options for starting Java apps in general. For example, when running Maven in a container it makes sense to respect container Memory constraints. 155 | 156 | The subcommand `options` can be used to print options to standard output so that is can be easily used to feed it to another, Java based application. 157 | 158 | When no extra arguments are given, all defaults will be used, which can be influenced with the environment variables described above. 159 | 160 | You can select specific sets of options by providing additional arguments: 161 | 162 | * `--debug` : Java debug options if `JAVA_DEBUG` is set 163 | * `--memory` : Memory settings based on the environment variables given 164 | * `--proxy` : Evaluate proxy environments variables 165 | * `--cpu` : Tuning when the number of cores is limited 166 | * `--gc` : GC tuning parameters 167 | * `--jit` : JIT options 168 | * `--diagnostics` : Print diagnostics options when `JAVA_DIAGNOSTICS` is set 169 | * `--java-default` : Same as `--memory --jit --diagnostic --cpu --gc` 170 | 171 | Example: 172 | 173 | ``` 174 | # Call Maven with the proper memory settings when running in an container 175 | export MAVEN_OPTS="$(run-java.sh options --memory)" 176 | mvn clean install 177 | ``` 178 | 179 | 180 | ### Versions: 181 | 182 | * Base-Image: **UBI 8.4** 183 | * Java: **OpenJDK 8 1.8.0** (Java Development Kit (JDK)) 184 | * Agent-Bond: **1.2.0** (Jolokia 1.7.1, jmx_exporter 0.3.1) 185 | -------------------------------------------------------------------------------- /images/ubi/openjdk8/jdk/agent-bond-opts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Parse options 4 | while [ $# -gt 0 ] 5 | do 6 | key="$1" 7 | case ${key} in 8 | # Escape for scripts which eval the output of this script 9 | -e|--escape) 10 | escape_sep=1 11 | ;; 12 | esac 13 | shift 14 | done 15 | 16 | # Check whether a given config is contained in AB_JOLOKIA_OPTS 17 | is_in_jolokia_opts() { 18 | local prop=$1 19 | if [ -n "${AB_JOLOKIA_OPTS:-}" ] && [ "${AB_JOLOKIA_OPTS}" != "${AB_JOLOKIA_OPTS/${prop}/}" ]; then 20 | echo "yes" 21 | else 22 | echo "no" 23 | fi 24 | } 25 | 26 | dir=${AB_DIR:-/opt/agent-bond} 27 | sep="=" 28 | 29 | # Options separators defined to avoid clash with fish-pepper templating 30 | ab_open_del="{""{" 31 | ab_close_del="}""}" 32 | if [ -n "${escape_sep:-}" ]; then 33 | ab_open_del='\{\{' 34 | ab_close_del='\}\}' 35 | fi 36 | 37 | if [ -z "${AB_OFF:-}" ]; then 38 | opts="-javaagent:$dir/agent-bond.jar" 39 | config="${AB_CONFIG:-$dir/agent-bond.properties}" 40 | if [ -f "$config" ]; then 41 | # Configuration takes precedence 42 | opts="${opts}${sep}config=${config}" 43 | sep="," 44 | fi 45 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jolokia/}" ]; then 46 | # Direct options only if no configuration is found 47 | jsep="" 48 | jolokia_opts="" 49 | if [ -n "${AB_JOLOKIA_CONFIG:-}" ] && [ -f "${AB_JOLOKIA_CONFIG}" ]; then 50 | jolokia_opts="${jolokia_opts}${jsep}config=${AB_JOLOKIA_CONFIG}" 51 | jsep="," 52 | grep -q -e '^host' ${AB_JOLOKIA_CONFIG} && host_in_config=1 53 | fi 54 | if [ -z "${AB_JOLOKIA_HOST:-}" ] && [ -z "${host_in_config:-}" ]; then 55 | AB_JOLOKIA_HOST='0.0.0.0' 56 | fi 57 | if [ -n "${AB_JOLOKIA_HOST:-}" ]; then 58 | jolokia_opts="${jolokia_opts}${jsep}host=${AB_JOLOKIA_HOST}" 59 | jsep="," 60 | fi 61 | if [ -n "${AB_JOLOKIA_PORT:-}" ]; then 62 | jolokia_opts="${jolokia_opts}${jsep}port=${AB_JOLOKIA_PORT}" 63 | jsep="," 64 | fi 65 | if [ -n "${AB_JOLOKIA_USER:-}" ]; then 66 | jolokia_opts="${jolokia_opts}${jsep}user=${AB_JOLOKIA_USER}" 67 | jsep="," 68 | fi 69 | if [ -n "${AB_JOLOKIA_PASSWORD:-}" ]; then 70 | jolokia_opts="${jolokia_opts}${jsep}password=${AB_JOLOKIA_PASSWORD}" 71 | jsep="," 72 | fi 73 | if [ -n "${AB_JOLOKIA_HTTPS:-}" ]; then 74 | jolokia_opts="${jolokia_opts}${jsep}protocol=https" 75 | https_used=1 76 | jsep="," 77 | fi 78 | # Integration with OpenShift client cert auth 79 | if [ -n "${AB_JOLOKIA_AUTH_OPENSHIFT:-}" ]; then 80 | auth_opts="useSslClientAuthentication=true,extraClientCheck=true" 81 | if [ -z "${https_used+x}" ]; then 82 | auth_opts="${auth_opts},protocol=https" 83 | fi 84 | if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then 85 | auth_opts="${auth_opts},caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" 86 | fi 87 | if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then 88 | if [ "${AB_JOLOKIA_AUTH_OPENSHIFT}" != "${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then 89 | # Supposed to contain a principal name to check 90 | auth_opts="${auth_opts},clientPrincipal=$(echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g')" 91 | else 92 | auth_opts="${auth_opts},clientPrincipal=cn=system:master-proxy" 93 | fi 94 | fi 95 | jolokia_opts="${jolokia_opts}${jsep}${auth_opts}" 96 | jsep="," 97 | fi 98 | # Add extra opts to the end 99 | if [ -n "${AB_JOLOKIA_OPTS:-}" ]; then 100 | jolokia_opts="${jolokia_opts}${jsep}${AB_JOLOKIA_OPTS}" 101 | jsep="," 102 | fi 103 | 104 | opts="${opts}${sep}jolokia${ab_open_del}${jolokia_opts}${ab_close_del}" 105 | sep="," 106 | fi 107 | if [ -z "${AB_ENABLED:-}" ] || [ "${AB_ENABLED}" != "${AB_ENABLED/jmx_exporter/}" ]; then 108 | je_opts="" 109 | jsep="" 110 | if [ -n "${AB_JMX_EXPORTER_OPTS:-}" ]; then 111 | opts="${opts}${sep}jmx_exporter${ab_open_del}${AB_JMX_EXPORTER_OPTS}${ab_close_del}" 112 | sep="," 113 | else 114 | port=${AB_JMX_EXPORTER_PORT:-9779} 115 | config=${AB_JMX_EXPORTER_CONFIG:-/opt/agent-bond/jmx_exporter_config.yml} 116 | opts="${opts}${sep}jmx_exporter${ab_open_del}${port}:${config}${ab_close_del}" 117 | sep="," 118 | fi 119 | fi 120 | if [ "${sep:-}" != '=' ] ; then 121 | echo ${opts} 122 | fi 123 | fi 124 | -------------------------------------------------------------------------------- /images/ubi/openjdk8/jdk/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | -------------------------------------------------------------------------------- /templates/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM {{= fp.config.base.from + (fp.config.base.tagFromMajorVersion ? ":" + fp.config.version.major : "") }} 2 | 3 | USER root 4 | 5 | RUN mkdir -p {{= fp.config.base.baseDir }} 6 | 7 | # JAVA_APP_DIR is used by run-java.sh for finding the binaries 8 | ENV JAVA_APP_DIR={{= fp.config.base.baseDir }} \ 9 | JAVA_MAJOR_VERSION={{= fp.config.version.major }} 10 | 11 | {{= fp.block("java-pkg-" + fp.param.base) || ''}} 12 | {{= fp.block(fp.config.base.agent + "-install", { dest: "/opt/run-java-options" }) }} 13 | 14 | {{= fp.block("run-java-sh","copy",{dest: fp.config.base.baseDir}) }} 15 | 16 | {{? fp.config.base.user }} 17 | # Run under user "{{= fp.config.base.user}}" and prepare for be running 18 | # under OpenShift, too 19 | RUN {{? fp.config.base.createUser }}groupadd -r {{= fp.config.base.user }} -g 1000 \ 20 | && useradd -u 1000 -r -g {{= fp.config.base.user }} -m -d /opt/{{= fp.config.base.user}} -s /sbin/nologin {{= fp.config.base.user }} \ 21 | && chmod 755 /opt/{{= fp.config.base.user }} \ 22 | && {{?}}chown -R {{= fp.config.base.user}} {{= fp.config.base.baseDir }} \ 23 | && usermod -g root -G `id -g {{= fp.config.base.user }}` {{= fp.config.base.user }} \ 24 | && chmod -R "g+rwX" {{= fp.config.base.baseDir }} \ 25 | && chown -R {{= fp.config.base.user}}:root {{= fp.config.base.baseDir }} 26 | 27 | USER {{= fp.config.base.user }} 28 | {{?}} 29 | {{? fp.config.base.ubiUser }} 30 | # Run under user "{{= fp.config.base.ubiUser }}" and prepare for be running 31 | # under OpenShift, too 32 | RUN chown {{= fp.config.base.ubiUser }} {{= fp.config.base.baseDir }} \ 33 | && chmod "g+rwX" {{= fp.config.base.baseDir }} \ 34 | && chown {{= fp.config.base.ubiUser }}:root {{= fp.config.base.baseDir }} \ 35 | && chmod g+rw /etc/passwd \ 36 | && mkdir -p {{= fp.config.base.baseDir }}/data \ 37 | && chown {{= fp.config.base.ubiUser }} {{= fp.config.base.baseDir }}/run-java.sh 38 | 39 | # Gives uid 40 | USER {{= fp.config.base.ubiUser }} 41 | {{?}} 42 | CMD [ "{{= fp.config.base.baseDir }}/run-java.sh" ] 43 | -------------------------------------------------------------------------------- /templates/README.md: -------------------------------------------------------------------------------- 1 | ## Fabric8 Java Base Image {{= fp.config.version.description }} ({{= fp.param.type.toUpperCase() }}) 2 | 3 | {{? fp.config.base.deprecated }}> ** This image is deprecated and not maintained anymore. Please select one of the other flavors (alpine, centos).** 4 | 5 | ----- 6 | {{?}} 7 | 8 | This image is based on {{= fp.config.base.description }} and provides {{= fp.config.version.description }} ({{= fp.param.type.toUpperCase() }}) 9 | 10 | It includes: 11 | 12 | {{? fp.config.base.agent == "agent-bond" }} 13 | * An [Agent Bond](https://github.com/fabric8io/agent-bond) agent with [Jolokia](http://www.jolokia.org) and Prometheus' [jmx_exporter](https://github.com/prometheus/jmx_exporter). The agent is installed as `/opt/agent-bond/agent-bond.jar`. See below for configuration options. 14 | {{?? fp.config.base.agent == "jolokia" }} 15 | * A [Jolokia](http://www.jolokia.org) agent. See below how to configure this. 16 | {{?}} 17 | 18 | * A startup script [`{{= fp.config.base.baseDir }}/run-java.sh`](#startup-script-run-javash) for starting up Java applications. 19 | 20 | ### Agent Bond 21 | 22 | In order to enable Jolokia for your application you should use this image as a base image (via `FROM`) and use the output of `agent-bond-opts` in your startup scripts to include it in for the Java startup options. 23 | 24 | For example, the following snippet can be added to a script starting up your Java application 25 | 26 | # ... 27 | export JAVA_OPTIONS="$JAVA_OPTIONS $(agent-bond-opts)" 28 | # .... use JAVA_OPTIONS when starting your app, e.g. as Tomcat does 29 | 30 | The following versions and defaults are used: 31 | 32 | * [Jolokia](http://www.jolokia.org) : version **{{= fp.version.jolokia }}** and port **8778** 33 | * [jmx_exporter](https://github.com/prometheus/jmx_exporter): version **{{= fp.version.jmxExporter }}** and port **9779** 34 | 35 | You can influence the behaviour of `agent-bond-opts` by setting various environment variables: 36 | 37 | {{= fp.block(fp.config.base.agent,'readme',{ 'fp-no-files' : true }) }} 38 | 39 | ### Startup Script run-java.sh 40 | 41 | The default command for this image is [{{= fp.config.base.baseDir }}/run-java.sh](https://github.com/fabric8io/run-java-sh). Its purpose it to fire up Java applications which are provided as fat-jars, including all dependencies or more classical from a main class, where the classpath is build up from all jars within a directory. 42 | 43 | For these images the variable **JAVA_APP_DIR** has the default value `{{= fp.config.base.baseDir }}` 44 | 45 | {{= fp.block('run-java-sh','readme',{ 'fp-no-files' : true }) }} 46 | 47 | ### Versions: 48 | 49 | * Base-Image: **{{= fp.config.base.description + " " + fp.config.base.version }}** 50 | * Java: **{{= fp.config.version.description + " " + fp.config.version.version }}** ({{= fp.config.type.description }}){{? fp.config.base.agent == "agent-bond" }} 51 | * Agent-Bond: **{{= fp.version.agentBond }}** (Jolokia {{= fp.version.jolokia }}, jmx_exporter {{= fp.version.jmxExporter }}){{?? fp.config.base.agent == "jolokia" }} 52 | * Jolokia: **{{= fp.version.jolokia }}** 53 | {{?}} 54 | -------------------------------------------------------------------------------- /templates/jmx_exporter_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | lowercaseOutputName: true 3 | lowercaseOutputLabelNames: true 4 | whitelistObjectNames: 5 | - 'org.apache.camel:*' 6 | rules: 7 | - pattern: '^org.apache.camel<>((?:Min|Mean|Max|Last|Delta)(?:ProcessingTime)):' 8 | name: camel_routes_$3 9 | labels: 10 | name: $2 11 | context: $1 12 | - pattern: '^org.apache.camel<>(TotalProcessingTime):' 13 | type: COUNTER 14 | name: camel_routes_$3 15 | labels: 16 | name: $2 17 | context: $1 18 | - pattern: '^org.apache.camel<>(ExchangesInflight|LastProcessingTime):' 19 | name: camel_routes_$3 20 | labels: 21 | name: $2 22 | context: $1 23 | - pattern: '^org.apache.camel<>((?:Exchanges(?:Completed|Failed|Total))|FailuresHandled):' 24 | type: COUNTER 25 | name: camel_routes_$3 26 | labels: 27 | name: $2 28 | context: $1 29 | --------------------------------------------------------------------------------