├── .gitignore ├── LICENSE ├── README.md ├── base └── alpine │ └── jre │ └── 8 │ ├── Dockerfile │ └── README.md ├── build.js ├── config.json ├── openjdk-6 ├── Dockerfile ├── README.md ├── jolokia └── jolokia_opts ├── openjdk-7 ├── Dockerfile ├── README.md ├── jolokia └── jolokia_opts ├── openjdk-8 ├── Dockerfile ├── README.md ├── jolokia └── jolokia_opts ├── package.json └── templates ├── Dockerfile ├── README.md └── jolokia_opts /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | *.iml 4 | -------------------------------------------------------------------------------- /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 | # NOTE 2 | 3 | Please note that this project has been superseded by https://github.com/fabric8io-images/java which has some extra features like nice run script which respects the container boundaries. Its available for Java 8 and Java 7. 4 | 5 | So, when you require Java 6 or Java 7 then this project might still be of value for you. But please note that it is not maintained anymore. 6 | 7 | ------------- 8 | 9 | 10 | # Spicy Docker Java Image with Jolokia 11 | 12 | This repository holds automated builds for variants of the official [java](https://registry.hub.docker.com/_/java) 13 | Java docker image which allow to easily start a [Jolokia](http://www.jolokia.org) agent. 14 | 15 | In order to use the agent, a child image which inherits from this image should call `jolokia_opts`, which echos all 16 | relevant options which should be included as argument to the Java startup command. 17 | 18 | Here is a simple example for creating a Tomcat 7 images which starts Jolokia along with tomcat: 19 | 20 | ```` 21 | FROM jolokia/java-jolokia:7 22 | ENV TOMCAT_VERSION 7.0.55 23 | ENV TC apache-tomcat-${TOMCAT_VERSION} 24 | 25 | EXPOSE 8080 8778 26 | RUN wget http://archive.apache.org/dist/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/${TC}.tar.gz 27 | RUN tar xzf ${TC}.tar.gz -C /opt 28 | 29 | CMD env CATALINA_OPTS=$(jolokia_opts) /opt/${TC}/bin/catalina.sh run 30 | ```` 31 | 32 | (Don't forget to use `$(jolokia_opts)` or with backticks, but not `${jolokia_opts}`) 33 | 34 | The configuration of the Jolokia agent can be influenced with various environments variables. Please refer to the 35 | [README](openjdk-7)s of the various image variants. 36 | 37 | ## Build system 38 | 39 | For generating the images a simple node.js based templating script is used. The templates can be found in the 40 | directory `templates` which uses the [doT](http://olado.github.io/doT/index.html) templating library. All you need is 41 | to adapt `config.json` if to upgrade the version number or adding a new build. 42 | 43 | For the initial setup, `npm install` needs to install some dependencies. 44 | 45 | `./build.js` will create the final automated build from the configuration and the templates. When calling `./build.js -b` 46 | then all images are build locally when a Docker daemon is running (and `DOCKER_HOST` is set properly). With `./build.js -h` 47 | a short help message is printed. 48 | 49 | ## Drive-By Jolokia 50 | 51 | (*by courtesy of [@paoloantinori](https://github.com/paoloantinori)*) 52 | 53 | There a circumstance where you can't use these images as a base because you have to use ready-made images. 54 | In that case you can still use the Jolokia JVM agent capability to attach to an already running Java process by 55 | injecting the agent to an already running process. 56 | 57 | For example if use the stock [Wildfly](https://github.com/jboss/dockerfiles/blob/master/wildfly/Dockerfile) Image, then 58 | you can inject Jolokia with the following command: 59 | 60 | ```bash 61 | docker run \ 62 | -P -p 8778 \ 63 | -v /data/installers/jolokia-jvm-1.2.2-agent.jar:/opt/jolokia/jolokia.jar \ 64 | -it jboss/wildfly \ 65 | sh -c 'exec /opt/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 & \ 66 | while ! curl -m 10 http://localhost:8080 ; do echo still down ; sleep 1s ; done ; \ 67 | java -jar /opt/jolokia/jolokia.jar --host 0.0.0.0 ".*jboss-modules.*"; \ 68 | sh' 69 | ``` 70 | 71 | Where: 72 | - `/data/installers/jolokia-jvm-1.2.2-agent.jar` is a path on your host to the Jolokia JVM agent 73 | - `while ! curl -m 10 http://localhost:8080 ; do echo still down ; sleep 1s ; done ;` is needed due to peculiar behavior of Wildfly, classloading and agents. Basically we are just waiting for Wildfly to be up and running. 74 | - `".*jboss-modules.*"` is a regexp to identify a unique process in the output of `ps ax` 75 | - instead of using `-v` to inject a host file inside the container you could consider a more portable approach with **Docker data only containers**. See this [blog post](http://www.tech-d.net/2013/12/16/persistent-volumes-with-docker-container-as-volume-pattern/) for an explanation of this pattern. 76 | 77 | -------------------------------------------------------------------------------- /base/alpine/jre/8/Dockerfile: -------------------------------------------------------------------------------- 1 | # Build for 206 MB JRE 1.8.0_60 (192 MB in size) with Alping and glibc 2 | FROM alpine:3.2 3 | 4 | MAINTAINER roland@jolokia.org 5 | 6 | ENV JRE=jre1.8.0_60 \ 7 | JAVA_HOME=/opt/jre 8 | 9 | # That's an 1.8.0_60 JRE from OpenJDK.net 10 | # Courtesy to https://github.com/frol/docker-alpine-oraclejdk8 from where the setup of glibc is borrowed 11 | RUN apk add --update wget ca-certificates && \ 12 | cd /tmp && \ 13 | wget "https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk" \ 14 | "https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-bin-2.21-r2.apk" && \ 15 | apk add --allow-untrusted glibc-2.21-r2.apk glibc-bin-2.21-r2.apk && \ 16 | /usr/glibc/usr/bin/ldconfig /lib /usr/glibc/usr/lib && \ 17 | echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ 18 | mkdir /opt && \ 19 | wget http://www.java.net/download/jdk8u60/archive/b18/binaries/jre-8u60-ea-bin-b18-linux-x64-02_jun_2015.tar.gz -O /tmp/${JRE}.tgz && \ 20 | cd /opt && tar zxvf /tmp/${JRE}.tgz && \ 21 | ln -s /opt/${JRE} /opt/jre && \ 22 | ln -s /opt/jre/bin/java /usr/bin/java && \ 23 | apk del wget ca-certificates && \ 24 | cd /opt/jre/lib/amd64 && rm libjavafx_* libjfx* libfx* && \ 25 | cd /opt/jre/lib/ && rm -rf ext/jfxrt.jar jfxswt.jar javafx.properties font* && \ 26 | rm /tmp/* /var/cache/apk/* 27 | 28 | CMD ["java", "-version"] 29 | -------------------------------------------------------------------------------- /base/alpine/jre/8/README.md: -------------------------------------------------------------------------------- 1 | 2 | # A minimal JRE 8 base image 3 | 4 | * Based on [Alpine Linux](https://www.alpinelinux.org/) 3.2 5 | * Added glibc like [here](https://github.com/frol/docker-alpine-oraclejdk8) 6 | * OpenJDK JRE 8u60 Build b18 from [https://jdk8.java.net/download.html](https://jdk8.java.net/download.html) 7 | * JavaFX removed 8 | 9 | --> Result: 127 MB 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /build.js: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/node 2 | 3 | var dot = require('dot'); 4 | dot.templateSettings.strip = false; 5 | 6 | var fs = require('fs'); 7 | require('colors'); 8 | var _ = require('underscore'); 9 | var Docker = require('dockerode'); 10 | var tarCmd = "tar"; 11 | var child = require('child_process'); 12 | var stream = require('stream'); 13 | 14 | // Set to true for extra debugging 15 | var DEBUG = false; 16 | var IMAGE_NAME = "jolokia/java-jolokia"; 17 | 18 | JSON.minify = JSON.minify || require("node-json-minify"); 19 | 20 | (function() { 21 | var opts = parseOpts(); 22 | 23 | processBuild(opts) 24 | })(); 25 | 26 | // =============================================================================== 27 | 28 | function processBuild(opts) { 29 | var config = getConfig("config.json"); 30 | createAutomatedBuilds(config,opts); 31 | // If desired create Docker images 32 | if (opts.options.build) { 33 | buildImages(config,opts); 34 | } 35 | } 36 | 37 | 38 | function createAutomatedBuilds(config,opts) { 39 | console.log("Creating Automated Builds\n".cyan); 40 | 41 | execWithTemplates(function (templates) { 42 | config.versions.forEach(function (version) { 43 | console.log(version.green); 44 | ensureDir(__dirname + "/" + version); 45 | var changed = false; 46 | templates.forEach(function (template) { 47 | var file = checkForMapping(config, version, template.file); 48 | if (!file) { 49 | // Skip any file flagged as being mapped but no mapping was found 50 | return; 51 | } 52 | var templateHasChanged = 53 | fillTemplate(version + "/" + file, 54 | template.templ, 55 | _.extend( 56 | {}, 57 | config, 58 | { 59 | "version": version, 60 | "config": _.extend({}, config.config['default'], config.config[version]) 61 | } 62 | )); 63 | changed = changed || templateHasChanged; 64 | }); 65 | if (!changed) { 66 | console.log(" UNCHANGED".yellow); 67 | } 68 | }); 69 | }); 70 | } 71 | 72 | function getConfig(path) { 73 | var config = {}; 74 | if (fs.existsSync(path)) { 75 | config = JSON.parse(JSON.minify(fs.readFileSync(path, "utf8"))); 76 | } 77 | return config; 78 | } 79 | 80 | function buildImages(config,opts) { 81 | console.log("\n\nBuilding Images\n".cyan); 82 | 83 | var docker = new Docker(getDockerConnectionsParams(opts)); 84 | doBuildImages(docker,config.versions,opts.options.nocache,config); 85 | } 86 | 87 | // =================================================================================== 88 | 89 | function checkForMapping(config,version,file) { 90 | if (/^__.*$/.test(file)) { 91 | var mappings = config.config[version].mappings; 92 | if (!mappings) { 93 | mappings = config.config["default"].mappings; 94 | } 95 | if (!mappings) { 96 | return null; 97 | } 98 | return mappings[file]; 99 | } else { 100 | return file; 101 | } 102 | } 103 | 104 | function execWithTemplates(templFunc) { 105 | var templates = fs.readdirSync("templates"); 106 | var ret = []; 107 | templates.forEach(function (template) { 108 | ret.push({ 109 | "templ" : dot.template(fs.readFileSync("templates/" + template)), 110 | "file" : template 111 | }); 112 | }); 113 | templFunc(ret); 114 | } 115 | 116 | function fillTemplate(file,template,config) { 117 | var newContent = template(config).trim() + "\n"; 118 | var label = file.replace(/.*\/([^\/]+)$/,"$1"); 119 | if (!newContent.length) { 120 | console.log(" " + label + ": " + "SKIPPED".grey); 121 | return false; 122 | } else { 123 | var exists = fs.existsSync(file); 124 | var oldContent = exists ? fs.readFileSync(file, "utf8") : undefined; 125 | if (!oldContent || newContent.trim() !== oldContent.trim()) { 126 | console.log(" " + label + ": " + (exists ? "CHANGED".green : "NEW".yellow)); 127 | fs.writeFileSync(file,newContent,{ "encoding" : "utf8"}); 128 | return true; 129 | } 130 | } 131 | return false; 132 | } 133 | 134 | function ensureDir(dir) { 135 | if (!fs.existsSync(dir)) { 136 | fs.mkdirSync(dir,0755); 137 | } 138 | var stat = fs.statSync(dir); 139 | if (!stat.isDirectory()) { 140 | throw new Error(dir + " is not a directory"); 141 | } 142 | } 143 | 144 | 145 | function doBuildImages(docker,versions,nocache,config) { 146 | if (versions.length > 0) { 147 | var version = versions.shift(); 148 | console.log(version.magenta); 149 | var tar = child.spawn(tarCmd, ['-c', '.'], { cwd: __dirname + "/" + version }); 150 | var name = IMAGE_NAME + ":" + version; 151 | docker.buildImage( 152 | tar.stdout, { "t": name, "forcerm": true, "q": true, "nocache": nocache ? "true" : "false" }, 153 | function (error, stream) { 154 | if (error) { 155 | throw error; 156 | } 157 | stream.pipe(getResponseStream()); 158 | stream.on('end', function () { 159 | var tags = config.config[version].tags || []; 160 | tags.forEach(function(tag) { 161 | docker.getImage(name).tag({"repo": IMAGE_NAME, "tag": tag, "force": true }, function (error, result) { 162 | if (error) { 163 | throw error; 164 | } 165 | console.log(result); 166 | }); 167 | }); 168 | doBuildImages(docker,versions,nocache,config); 169 | }); 170 | }); 171 | } 172 | } 173 | 174 | function getResponseStream() { 175 | var buildResponseStream = new stream.Writable(); 176 | buildResponseStream._write = function (chunk, encoding, done) { 177 | var answer = chunk.toString(); 178 | var resp = JSON.parse(answer); 179 | 180 | debug("|| >>> " + answer); 181 | if (resp.stream) { 182 | process.stdout.write(resp.stream); 183 | } 184 | if (resp.errorDetail) { 185 | process.stderr.write("++++++++ ERROR +++++++++++\n"); 186 | process.stderr.write(resp.errorDetail.message); 187 | } 188 | done(); 189 | }; 190 | return buildResponseStream; 191 | } 192 | 193 | function addSslIfNeeded(param,opts) { 194 | var port = param.port; 195 | if (port === "2376") { 196 | // Its SSL 197 | var options = opts.options; 198 | var certPath = options.certPath || process.env.DOCKER_CERT_PATH || process.env.HOME + ".docker"; 199 | return _.extend(param,{ 200 | protocol: "https", 201 | ca: fs.readFileSync(certPath + '/ca.pem'), 202 | cert: fs.readFileSync(certPath + '/cert.pem'), 203 | key: fs.readFileSync(certPath + '/key.pem') 204 | }); 205 | } else { 206 | return _.extend(param,{ 207 | protocol: "http" 208 | }); 209 | } 210 | } 211 | 212 | function getDockerConnectionsParams(opts) { 213 | if (opts.options.host) { 214 | return addSslIfNeeded({ 215 | "host": opts.options.host, 216 | "port": opts.options.port || 2375 217 | },opts); 218 | } else if (process.env.DOCKER_HOST) { 219 | var parts = process.env.DOCKER_HOST.match(/^tcp:\/\/(.+?)\:?(\d+)?$/i); 220 | if (parts !== null) { 221 | return addSslIfNeeded({ 222 | "host" : parts[1], 223 | "port" : parts[2] || 2375 224 | },opts); 225 | } else { 226 | return { 227 | "socketPath" : process.env.DOCKER_HOST 228 | }; 229 | } 230 | } else { 231 | return { 232 | "host" : "http://localhost", 233 | "port" : 2375 234 | }; 235 | } 236 | } 237 | 238 | function debug(msg) { 239 | if (DEBUG) { 240 | process.stdout.write(msg + "\n"); 241 | } 242 | } 243 | 244 | 245 | function parseOpts() { 246 | var Getopt = require('node-getopt'); 247 | var getopt = new Getopt([ 248 | ['b' , 'build', 'Build image(s)'], 249 | ['d' , 'host', 'Docker hostname (default: localhost)'], 250 | ['p' , 'port', 'Docker port (default: 2375)'], 251 | ['n' , 'nocache', 'Dont cache when building images'], 252 | ['h' , 'help', 'display this help'] 253 | ]); 254 | 255 | var help = 256 | "Usage: node build.js [OPTION]\n" + 257 | "Generator for Docker builds.\n" + 258 | "\n" + 259 | "[[OPTIONS]]\n" + 260 | "\n" + 261 | "This script creates so called 'automated builds' for Java with integrated Jolokia\n" + 262 | "which can be registered at hub.docker.io\n\n" + 263 | "It uses templates for covering multiple tags of this image.\n\n" + 264 | "Supported servers:\n\n"; 265 | 266 | return getopt.bindHelp(help).parseSystem(); 267 | } 268 | 269 | 270 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "versions" : [ "openjdk-6", "openjdk-7", "openjdk-8" ], 3 | 4 | "name" : "jolokia/java-jolokia", 5 | 6 | "jolokiaBaseUrl": "http://central.maven.org/maven2/org/jolokia/jolokia-jvm", 7 | 8 | "jolokiaVersion": "1.3.1", 9 | 10 | "maintainer" : "roland@jolokia.org", 11 | 12 | "config": { 13 | "openjdk-6" : { 14 | "java": "java:6b35", 15 | "tags" : [ "6b35", "6", "openjdk-6" ], 16 | "fullVersion": "OpenJDK 1.6.0_35 (6b35-1.13.7-1~deb7u1)" 17 | }, 18 | "openjdk-7": { 19 | "java": "java:7u79", 20 | "tags" : [ "7u79", "7", "openjdk-7", "latest" ], 21 | "fullVersion": "OpenJDK 1.7.0_79 (7u79-2.5.5-1~deb8u)" 22 | }, 23 | "openjdk-8" : { 24 | "java": "java:8u45", 25 | "tags" : [ "8u45", "8", "openjdk-8" ], 26 | "fullVersion": "OpenJDK 1.8.0_45 (1.8.0_45-internal-b14)" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /openjdk-6/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:6b35 2 | 3 | MAINTAINER roland@jolokia.org 4 | 5 | ENV JOLOKIA_VERSION 1.3.1 6 | 7 | # Add environment setup script 8 | ADD jolokia_opts /bin/ 9 | 10 | RUN chmod 755 /bin/jolokia_opts && mkdir /opt/jolokia && wget http://central.maven.org/maven2/org/jolokia/jolokia-jvm/1.3.1/jolokia-jvm-1.3.1-agent.jar -O /opt/jolokia/jolokia.jar 11 | 12 | # Print out the version 13 | CMD java -jar /opt/jolokia/jolokia.jar --version 14 | -------------------------------------------------------------------------------- /openjdk-6/README.md: -------------------------------------------------------------------------------- 1 | ## Java Image with Jolokia 2 | 3 | This image is based on the official [java](https://registry.hub.docker.com/_/java) image and 4 | includes a Jolokia JVM agent. The agent is installed as `/opt/jolokia/jolokia.jar`. 5 | 6 | In order to enable Jolokia for your application you should use this 7 | image as a base image (via `FROM`) and use the output of `jolokia_opts` in 8 | your startup scripts to include it in your startup options. 9 | 10 | For example, the following snippet can be added to a script starting up your 11 | Java application 12 | 13 | # ... 14 | export JAVA_OPTIONS="$JAVA_OPTIONS $(jolokia_opts)" 15 | # .... us JAVA_OPTIONS when starting your app, e.g. as Tomcat does 16 | 17 | You can influence the behaviour `jolokia_opts` by setting various environment 18 | variables: 19 | 20 | * **JOLOKIA_OFF** : If set disables activation of Jolokia (i.e. echos an empty value). By default, Jolokia is enabled. 21 | * **JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 22 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 23 | By default this is `/opt/jolokia/jolokia.properties`. If this file exists, it be will taken 24 | as configuration and **any other config options are ignored**. 25 | * **JOLOKIA_HOST** : Host address to bind to (Default: 0.0.0.0) 26 | * **JOLOKIA_PORT** : Port to use (Default: 8778) 27 | * **JOLOKIA_USER** : User for authentication. By default authentication is switched off. 28 | * **JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 29 | * **JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 30 | * **JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 31 | "key=value,key=value,..." 32 | 33 | Some options for integration in various environments 34 | 35 | * **JOLOKIA_AUTH_OPENSHIFT** : Switch on OAuth2 authentication for OpenShift. The value of this parameter must be the OpenShift API's 36 | base URL (e.g. `https://localhost:8443/osapi/v1beta3/`) 37 | 38 | So, if you start the container with `docker run -e JOLOKIA_OFF ...` no agent will be launched. 39 | 40 | The following versions are used: 41 | 42 | * Java Version: **OpenJDK 1.6.0_35 (6b35-1.13.7-1~deb7u1)** (base image: *java:6b35*) 43 | * Jolokia Version: **1.3.1** 44 | * Jolokia Port: **8778** 45 | -------------------------------------------------------------------------------- /openjdk-6/jolokia: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | JOLOKIA_DIR=${JOLOKIA_DIR:-/opt/jolokia} 3 | if [ -n "${JOLOKIA_OFF}" ]; then 4 | JOLOKIA_OPTS="" 5 | else 6 | JOLOKIA_OPTS="-javaagent:${JOLOKIA_DIR}/jolokia.jar" 7 | JOLOKIA_CONFIG=${JOLOKIA_CONFIG:-$JOLOKIA_DIR/jolokia.properties} 8 | JOLOKIA_HOST=${JOLOKIA_HOST:-*} 9 | if [ -f "$JOLOKIA_CONFIG" ]; then 10 | JOLOKIA_ARGS="${JOLOKIA_ARGS},config=${JOLOKIA_CONFIG}" 11 | fi 12 | if [ -n "$JOLOKIA_PORT" ]; then 13 | JOLOKIA_ARGS="${JOLOKIA_ARGS},port=${JOLOKIA_PORT}" 14 | fi 15 | JOLOKIA_ARGS="${JOLOKIA_ARGS},host=${JOLOKIA_HOST}" 16 | if [ -n "$JOLOKIA_USER" ]; then 17 | JOLOKIA_ARGS="${JOLOKIA_ARGS},user=${JOLOKIA_USER}" 18 | fi 19 | if [ -n "$JOLOKIA_PASSWORD" ]; then 20 | JOLOKIA_ARGS="${JOLOKIA_ARGS},password=${JOLOKIA_PASSWORD}" 21 | fi 22 | if [ -n "$JOLOKIA_ARGS" ]; then 23 | JOLOKIA_OPTS="${JOLOKIA_OPTS}=${JOLOKIA_ARGS#?}" 24 | fi 25 | fi 26 | echo $JOLOKIA_OPTS 27 | -------------------------------------------------------------------------------- /openjdk-6/jolokia_opts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dir=${JOLOKIA_DIR:-/opt/jolokia} 3 | if [ -z ${JOLOKIA_OFF+x} ]; then 4 | opts="-javaagent:$dir/jolokia.jar" 5 | config=${JOLOKIA_CONFIG:-$dir/jolokia.properties} 6 | if [ -f "$JOLOKIA_CONFIG" ]; then 7 | # Configuration takes precedence 8 | opts="${opts}=config=${JOLOKIA_CONFIG}" 9 | else 10 | # Direct options only if no configuration is found 11 | opts="${opts}=host=${JOLOKIA_HOST:-*},agentId=${JOLOKIA_ID:-$HOSTNAME}" 12 | if [ -n "$JOLOKIA_PORT" ]; then 13 | opts="${opts},port=${JOLOKIA_PORT}" 14 | fi 15 | if [ -n "$JOLOKIA_USER" ]; then 16 | opts="${opts},user=${JOLOKIA_USER}" 17 | fi 18 | if [ -n "$JOLOKIA_PASSWORD" ]; then 19 | opts="${opts},password=${JOLOKIA_PASSWORD}" 20 | fi 21 | 22 | # Integration of 3rd party environments 23 | if [ -n "$JOLOKIA_AUTH_OPENSHIFT" ]; then 24 | opts="${opts},authMode=delegate,authUrl=${JOLOKIA_AUTH_OPENSHIFT%/}/users/~,authPrincipalSpec=json:metadata/user,authIgnoreCerts=true" 25 | fi 26 | 27 | # Add extra opts to the end 28 | if [ -n "$JOLOKIA_OPTS" ]; then 29 | opts="${opts},${JOLOKIA_OPTS}" 30 | fi 31 | fi 32 | echo $opts 33 | fi 34 | -------------------------------------------------------------------------------- /openjdk-7/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:7u79 2 | 3 | MAINTAINER roland@jolokia.org 4 | 5 | ENV JOLOKIA_VERSION 1.3.1 6 | 7 | # Add environment setup script 8 | ADD jolokia_opts /bin/ 9 | 10 | RUN chmod 755 /bin/jolokia_opts && mkdir /opt/jolokia && wget http://central.maven.org/maven2/org/jolokia/jolokia-jvm/1.3.1/jolokia-jvm-1.3.1-agent.jar -O /opt/jolokia/jolokia.jar 11 | 12 | # Print out the version 13 | CMD java -jar /opt/jolokia/jolokia.jar --version 14 | -------------------------------------------------------------------------------- /openjdk-7/README.md: -------------------------------------------------------------------------------- 1 | ## Java Image with Jolokia 2 | 3 | This image is based on the official [java](https://registry.hub.docker.com/_/java) image and 4 | includes a Jolokia JVM agent. The agent is installed as `/opt/jolokia/jolokia.jar`. 5 | 6 | In order to enable Jolokia for your application you should use this 7 | image as a base image (via `FROM`) and use the output of `jolokia_opts` in 8 | your startup scripts to include it in your startup options. 9 | 10 | For example, the following snippet can be added to a script starting up your 11 | Java application 12 | 13 | # ... 14 | export JAVA_OPTIONS="$JAVA_OPTIONS $(jolokia_opts)" 15 | # .... us JAVA_OPTIONS when starting your app, e.g. as Tomcat does 16 | 17 | You can influence the behaviour `jolokia_opts` by setting various environment 18 | variables: 19 | 20 | * **JOLOKIA_OFF** : If set disables activation of Jolokia (i.e. echos an empty value). By default, Jolokia is enabled. 21 | * **JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 22 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 23 | By default this is `/opt/jolokia/jolokia.properties`. If this file exists, it be will taken 24 | as configuration and **any other config options are ignored**. 25 | * **JOLOKIA_HOST** : Host address to bind to (Default: 0.0.0.0) 26 | * **JOLOKIA_PORT** : Port to use (Default: 8778) 27 | * **JOLOKIA_USER** : User for authentication. By default authentication is switched off. 28 | * **JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 29 | * **JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 30 | * **JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 31 | "key=value,key=value,..." 32 | 33 | Some options for integration in various environments 34 | 35 | * **JOLOKIA_AUTH_OPENSHIFT** : Switch on OAuth2 authentication for OpenShift. The value of this parameter must be the OpenShift API's 36 | base URL (e.g. `https://localhost:8443/osapi/v1beta3/`) 37 | 38 | So, if you start the container with `docker run -e JOLOKIA_OFF ...` no agent will be launched. 39 | 40 | The following versions are used: 41 | 42 | * Java Version: **OpenJDK 1.7.0_79 (7u79-2.5.5-1~deb8u)** (base image: *java:7u79*) 43 | * Jolokia Version: **1.3.1** 44 | * Jolokia Port: **8778** 45 | -------------------------------------------------------------------------------- /openjdk-7/jolokia: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | JOLOKIA_DIR=${JOLOKIA_DIR:-/opt/jolokia} 3 | if [ -n "${JOLOKIA_OFF}" ]; then 4 | JOLOKIA_OPTS="" 5 | else 6 | JOLOKIA_OPTS="-javaagent:${JOLOKIA_DIR}/jolokia.jar" 7 | JOLOKIA_CONFIG=${JOLOKIA_CONFIG:-$JOLOKIA_DIR/jolokia.properties} 8 | JOLOKIA_HOST=${JOLOKIA_HOST:-*} 9 | if [ -f "$JOLOKIA_CONFIG" ]; then 10 | JOLOKIA_ARGS="${JOLOKIA_ARGS},config=${JOLOKIA_CONFIG}" 11 | fi 12 | if [ -n "$JOLOKIA_PORT" ]; then 13 | JOLOKIA_ARGS="${JOLOKIA_ARGS},port=${JOLOKIA_PORT}" 14 | fi 15 | JOLOKIA_ARGS="${JOLOKIA_ARGS},host=${JOLOKIA_HOST}" 16 | if [ -n "$JOLOKIA_USER" ]; then 17 | JOLOKIA_ARGS="${JOLOKIA_ARGS},user=${JOLOKIA_USER}" 18 | fi 19 | if [ -n "$JOLOKIA_PASSWORD" ]; then 20 | JOLOKIA_ARGS="${JOLOKIA_ARGS},password=${JOLOKIA_PASSWORD}" 21 | fi 22 | if [ -n "$JOLOKIA_ARGS" ]; then 23 | JOLOKIA_OPTS="${JOLOKIA_OPTS}=${JOLOKIA_ARGS#?}" 24 | fi 25 | fi 26 | echo $JOLOKIA_OPTS 27 | -------------------------------------------------------------------------------- /openjdk-7/jolokia_opts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dir=${JOLOKIA_DIR:-/opt/jolokia} 3 | if [ -z ${JOLOKIA_OFF+x} ]; then 4 | opts="-javaagent:$dir/jolokia.jar" 5 | config=${JOLOKIA_CONFIG:-$dir/jolokia.properties} 6 | if [ -f "$JOLOKIA_CONFIG" ]; then 7 | # Configuration takes precedence 8 | opts="${opts}=config=${JOLOKIA_CONFIG}" 9 | else 10 | # Direct options only if no configuration is found 11 | opts="${opts}=host=${JOLOKIA_HOST:-*},agentId=${JOLOKIA_ID:-$HOSTNAME}" 12 | if [ -n "$JOLOKIA_PORT" ]; then 13 | opts="${opts},port=${JOLOKIA_PORT}" 14 | fi 15 | if [ -n "$JOLOKIA_USER" ]; then 16 | opts="${opts},user=${JOLOKIA_USER}" 17 | fi 18 | if [ -n "$JOLOKIA_PASSWORD" ]; then 19 | opts="${opts},password=${JOLOKIA_PASSWORD}" 20 | fi 21 | 22 | # Integration of 3rd party environments 23 | if [ -n "$JOLOKIA_AUTH_OPENSHIFT" ]; then 24 | opts="${opts},authMode=delegate,authUrl=${JOLOKIA_AUTH_OPENSHIFT%/}/users/~,authPrincipalSpec=json:metadata/user,authIgnoreCerts=true" 25 | fi 26 | 27 | # Add extra opts to the end 28 | if [ -n "$JOLOKIA_OPTS" ]; then 29 | opts="${opts},${JOLOKIA_OPTS}" 30 | fi 31 | fi 32 | echo $opts 33 | fi 34 | -------------------------------------------------------------------------------- /openjdk-8/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8u45 2 | 3 | MAINTAINER roland@jolokia.org 4 | 5 | ENV JOLOKIA_VERSION 1.3.1 6 | 7 | # Add environment setup script 8 | ADD jolokia_opts /bin/ 9 | 10 | RUN chmod 755 /bin/jolokia_opts && mkdir /opt/jolokia && wget http://central.maven.org/maven2/org/jolokia/jolokia-jvm/1.3.1/jolokia-jvm-1.3.1-agent.jar -O /opt/jolokia/jolokia.jar 11 | 12 | # Print out the version 13 | CMD java -jar /opt/jolokia/jolokia.jar --version 14 | -------------------------------------------------------------------------------- /openjdk-8/README.md: -------------------------------------------------------------------------------- 1 | ## Java Image with Jolokia 2 | 3 | This image is based on the official [java](https://registry.hub.docker.com/_/java) image and 4 | includes a Jolokia JVM agent. The agent is installed as `/opt/jolokia/jolokia.jar`. 5 | 6 | In order to enable Jolokia for your application you should use this 7 | image as a base image (via `FROM`) and use the output of `jolokia_opts` in 8 | your startup scripts to include it in your startup options. 9 | 10 | For example, the following snippet can be added to a script starting up your 11 | Java application 12 | 13 | # ... 14 | export JAVA_OPTIONS="$JAVA_OPTIONS $(jolokia_opts)" 15 | # .... us JAVA_OPTIONS when starting your app, e.g. as Tomcat does 16 | 17 | You can influence the behaviour `jolokia_opts` by setting various environment 18 | variables: 19 | 20 | * **JOLOKIA_OFF** : If set disables activation of Jolokia (i.e. echos an empty value). By default, Jolokia is enabled. 21 | * **JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 22 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 23 | By default this is `/opt/jolokia/jolokia.properties`. If this file exists, it be will taken 24 | as configuration and **any other config options are ignored**. 25 | * **JOLOKIA_HOST** : Host address to bind to (Default: 0.0.0.0) 26 | * **JOLOKIA_PORT** : Port to use (Default: 8778) 27 | * **JOLOKIA_USER** : User for authentication. By default authentication is switched off. 28 | * **JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 29 | * **JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 30 | * **JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 31 | "key=value,key=value,..." 32 | 33 | Some options for integration in various environments 34 | 35 | * **JOLOKIA_AUTH_OPENSHIFT** : Switch on OAuth2 authentication for OpenShift. The value of this parameter must be the OpenShift API's 36 | base URL (e.g. `https://localhost:8443/osapi/v1beta3/`) 37 | 38 | So, if you start the container with `docker run -e JOLOKIA_OFF ...` no agent will be launched. 39 | 40 | The following versions are used: 41 | 42 | * Java Version: **OpenJDK 1.8.0_45 (1.8.0_45-internal-b14)** (base image: *java:8u45*) 43 | * Jolokia Version: **1.3.1** 44 | * Jolokia Port: **8778** 45 | -------------------------------------------------------------------------------- /openjdk-8/jolokia: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | JOLOKIA_DIR=${JOLOKIA_DIR:-/opt/jolokia} 3 | if [ -n "${JOLOKIA_OFF}" ]; then 4 | JOLOKIA_OPTS="" 5 | else 6 | JOLOKIA_OPTS="-javaagent:${JOLOKIA_DIR}/jolokia.jar" 7 | JOLOKIA_CONFIG=${JOLOKIA_CONFIG:-$JOLOKIA_DIR/jolokia.properties} 8 | JOLOKIA_HOST=${JOLOKIA_HOST:-*} 9 | if [ -f "$JOLOKIA_CONFIG" ]; then 10 | JOLOKIA_ARGS="${JOLOKIA_ARGS},config=${JOLOKIA_CONFIG}" 11 | fi 12 | if [ -n "$JOLOKIA_PORT" ]; then 13 | JOLOKIA_ARGS="${JOLOKIA_ARGS},port=${JOLOKIA_PORT}" 14 | fi 15 | JOLOKIA_ARGS="${JOLOKIA_ARGS},host=${JOLOKIA_HOST}" 16 | if [ -n "$JOLOKIA_USER" ]; then 17 | JOLOKIA_ARGS="${JOLOKIA_ARGS},user=${JOLOKIA_USER}" 18 | fi 19 | if [ -n "$JOLOKIA_PASSWORD" ]; then 20 | JOLOKIA_ARGS="${JOLOKIA_ARGS},password=${JOLOKIA_PASSWORD}" 21 | fi 22 | if [ -n "$JOLOKIA_ARGS" ]; then 23 | JOLOKIA_OPTS="${JOLOKIA_OPTS}=${JOLOKIA_ARGS#?}" 24 | fi 25 | fi 26 | echo $JOLOKIA_OPTS 27 | -------------------------------------------------------------------------------- /openjdk-8/jolokia_opts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dir=${JOLOKIA_DIR:-/opt/jolokia} 3 | if [ -z ${JOLOKIA_OFF+x} ]; then 4 | opts="-javaagent:$dir/jolokia.jar" 5 | config=${JOLOKIA_CONFIG:-$dir/jolokia.properties} 6 | if [ -f "$JOLOKIA_CONFIG" ]; then 7 | # Configuration takes precedence 8 | opts="${opts}=config=${JOLOKIA_CONFIG}" 9 | else 10 | # Direct options only if no configuration is found 11 | opts="${opts}=host=${JOLOKIA_HOST:-*},agentId=${JOLOKIA_ID:-$HOSTNAME}" 12 | if [ -n "$JOLOKIA_PORT" ]; then 13 | opts="${opts},port=${JOLOKIA_PORT}" 14 | fi 15 | if [ -n "$JOLOKIA_USER" ]; then 16 | opts="${opts},user=${JOLOKIA_USER}" 17 | fi 18 | if [ -n "$JOLOKIA_PASSWORD" ]; then 19 | opts="${opts},password=${JOLOKIA_PASSWORD}" 20 | fi 21 | 22 | # Integration of 3rd party environments 23 | if [ -n "$JOLOKIA_AUTH_OPENSHIFT" ]; then 24 | opts="${opts},authMode=delegate,authUrl=${JOLOKIA_AUTH_OPENSHIFT%/}/users/~,authPrincipalSpec=json:metadata/user,authIgnoreCerts=true" 25 | fi 26 | 27 | # Add extra opts to the end 28 | if [ -n "$JOLOKIA_OPTS" ]; then 29 | opts="${opts},${JOLOKIA_OPTS}" 30 | fi 31 | fi 32 | echo $opts 33 | fi 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docker-java-jolokia", 3 | "description": "Creating a suite of Docker images containing various application server", 4 | "version": "1.3.1", 5 | "private": true, 6 | "dependencies": { 7 | "dot": "*", 8 | "colors": "*", 9 | "underscore": "*", 10 | "node-json-minify": "*", 11 | "node-getopt" : "*", 12 | "dockerode" : "*" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /templates/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM {{= it.config.java }} 2 | 3 | MAINTAINER {{= it.maintainer }} 4 | 5 | ENV JOLOKIA_VERSION {{= it.jolokiaVersion }} 6 | 7 | # Add environment setup script 8 | ADD jolokia_opts /bin/ 9 | 10 | RUN chmod 755 /bin/jolokia_opts && mkdir /opt/jolokia && wget {{= it.jolokiaBaseUrl}}/{{= it.jolokiaVersion}}/jolokia-jvm-{{= it.jolokiaVersion}}-agent.jar -O /opt/jolokia/jolokia.jar 11 | 12 | # Print out the version 13 | CMD java -jar /opt/jolokia/jolokia.jar --version 14 | -------------------------------------------------------------------------------- /templates/README.md: -------------------------------------------------------------------------------- 1 | ## Java Image with Jolokia 2 | 3 | This image is based on the official [java](https://registry.hub.docker.com/_/java) image and 4 | includes a Jolokia JVM agent. The agent is installed as `/opt/jolokia/jolokia.jar`. 5 | 6 | In order to enable Jolokia for your application you should use this 7 | image as a base image (via `FROM`) and use the output of `jolokia_opts` in 8 | your startup scripts to include it in your startup options. 9 | 10 | For example, the following snippet can be added to a script starting up your 11 | Java application 12 | 13 | # ... 14 | export JAVA_OPTIONS="$JAVA_OPTIONS $(jolokia_opts)" 15 | # .... us JAVA_OPTIONS when starting your app, e.g. as Tomcat does 16 | 17 | You can influence the behaviour `jolokia_opts` by setting various environment 18 | variables: 19 | 20 | * **JOLOKIA_OFF** : If set disables activation of Jolokia (i.e. echos an empty value). By default, Jolokia is enabled. 21 | * **JOLOKIA_CONFIG** : If set uses this file (including path) as Jolokia JVM agent properties (as described 22 | in Jolokia's [reference manual](http://www.jolokia.org/reference/html/agents.html#agents-jvm)). 23 | By default this is `/opt/jolokia/jolokia.properties`. If this file exists, it be will taken 24 | as configuration and **any other config options are ignored**. 25 | * **JOLOKIA_HOST** : Host address to bind to (Default: 0.0.0.0) 26 | * **JOLOKIA_PORT** : Port to use (Default: 8778) 27 | * **JOLOKIA_USER** : User for authentication. By default authentication is switched off. 28 | * **JOLOKIA_PASSWORD** : Password for authentication. By default authentication is switched off. 29 | * **JOLOKIA_ID** : Agent ID to use (`$HOSTNAME` by default, which is the container id) 30 | * **JOLOKIA_OPTS** : Additional options to be appended to the agent opts. They should be given in the format 31 | "key=value,key=value,..." 32 | 33 | Some options for integration in various environments 34 | 35 | * **JOLOKIA_AUTH_OPENSHIFT** : Switch on OAuth2 authentication for OpenShift. The value of this parameter must be the OpenShift API's 36 | base URL (e.g. `https://localhost:8443/osapi/v1beta3/`) 37 | 38 | So, if you start the container with `docker run -e JOLOKIA_OFF ...` no agent will be launched. 39 | 40 | The following versions are used: 41 | 42 | * Java Version: **{{= it.config.fullVersion}}** (base image: *{{= it.config.java}}*) 43 | * Jolokia Version: **{{= it.jolokiaVersion}}** 44 | * Jolokia Port: **8778** -------------------------------------------------------------------------------- /templates/jolokia_opts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dir=${JOLOKIA_DIR:-/opt/jolokia} 3 | if [ -z ${JOLOKIA_OFF+x} ]; then 4 | opts="-javaagent:$dir/jolokia.jar" 5 | config=${JOLOKIA_CONFIG:-$dir/jolokia.properties} 6 | if [ -f "$JOLOKIA_CONFIG" ]; then 7 | # Configuration takes precedence 8 | opts="${opts}=config=${JOLOKIA_CONFIG}" 9 | else 10 | # Direct options only if no configuration is found 11 | opts="${opts}=host=${JOLOKIA_HOST:-*},agentId=${JOLOKIA_ID:-$HOSTNAME}" 12 | if [ -n "$JOLOKIA_PORT" ]; then 13 | opts="${opts},port=${JOLOKIA_PORT}" 14 | fi 15 | if [ -n "$JOLOKIA_USER" ]; then 16 | opts="${opts},user=${JOLOKIA_USER}" 17 | fi 18 | if [ -n "$JOLOKIA_PASSWORD" ]; then 19 | opts="${opts},password=${JOLOKIA_PASSWORD}" 20 | fi 21 | 22 | # Integration of 3rd party environments 23 | if [ -n "$JOLOKIA_AUTH_OPENSHIFT" ]; then 24 | opts="${opts},authMode=delegate,authUrl=${JOLOKIA_AUTH_OPENSHIFT%/}/users/~,authPrincipalSpec=json:metadata/user,authIgnoreCerts=true" 25 | fi 26 | 27 | # Add extra opts to the end 28 | if [ -n "$JOLOKIA_OPTS" ]; then 29 | opts="${opts},${JOLOKIA_OPTS}" 30 | fi 31 | fi 32 | echo $opts 33 | fi --------------------------------------------------------------------------------