{"componentChunkName":"component---node-modules-gatsby-theme-blog-core-src-templates-post-query-js","path":"/package-java-buildpack-with-docker/","result":{"data":{"site":{"siteMetadata":{"title":"one melo a day","social":[{"name":"twitter","url":"https://twitter.com/melo0187"},{"name":"github","url":"https://github.com/melo0187"}]}},"blogPost":{"__typename":"MdxBlogPost","id":"9b9ecf8f-33f4-589d-b078-ed291093181a","excerpt":"How I used Docker to package the CF java-buildpack in minutes","body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"layout\": \"post\",\n  \"title\": \"Package Cloud Foundry java-buildpack with Docker\",\n  \"author\": \"melo\",\n  \"date\": \"2017-11-26T21:55:42.000Z\",\n  \"categories\": [\"Cloud Foundry\", \"Docker\", \"Technical\"],\n  \"slug\": \"package-java-buildpack-with-docker\",\n  \"excerpt\": \"How I used Docker to package the CF java-buildpack in minutes\",\n  \"draft\": false,\n  \"meta_title\": \"Package Cloud Foundry java-buildpack with Docker\"\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"Just last week I found myself in the situation were I needed to package the \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/cloudfoundry/java-buildpack\"\n  }), \"Cloud Foundry Java Buildpack\"), \". Here is why I chose Docker to package the buildpack and what was necessary to get it done both on Linux and on Windows 7 using Docker Toolbox.\"), mdx(\"h2\", {\n    \"id\": \"why-package-your-own-buildpack\"\n  }, \"Why package your own buildpack?\"), mdx(\"p\", null, \"So \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"why package your own buildpack\"), \" you might ask yourself? I mainly had two reasons. As you might know a Cloud Foundry buildpack is a package \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"that is as minimal as possible and is configured to connect to the network for all dependencies\"), mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"#fn-543-1\"\n  }), \"1\"), \". In my target Cloud Foundry environment there is no unrestricted internet access, so I need an offline package anyway that platform ops will then make available through the  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"cf create-buildpack\"), \"  command. Furthermore I need to customize my buildpack, more specifically a configuration for the \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://www.appdynamics.com/\"\n  }), \"AppDynamics\"), \" agent that needs to go inside my app\\u2019s containers.\"), mdx(\"h2\", {\n    \"id\": \"why-build-with-docker\"\n  }, \"Why build with Docker?\"), mdx(\"p\", null, \"I don\\u2019t use ruby, thus I don\\u2019t have it installed. So I can\\u2019t simply run the commands the maintainers of the Cloud Foundry Java Buildpack specify \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/cloudfoundry/java-buildpack#offline-package\"\n  }), \"here\"), \". Since I won\\u2019t use ruby in the foreseeable future, I don\\u2019t want to invest the time to properly install it on my host system. One of my favorite usecases for Docker is to run disposable containers to build sources with the build-environment they require without the need to manage several build-environments on the host machine directly. So choosing Docker for this occasion seems natural to me.\"), mdx(\"h2\", {\n    \"id\": \"package-java-buildpack-with-docker\"\n  }, \"Package java-buildpack with Docker\"), mdx(\"p\", null, \"So first things first. Let us grab the java-buildpack and checkout a version tag. \", \"[\", \"code language=\\u201Cbash\\u201D\", \"]\", \" git clone \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/cloudfoundry/java-buildpack.git\"\n  }), \"https://github.com/cloudfoundry/java-buildpack.git\"), \" git checkout v4.6 \", \"[\", \"/code\", \"]\", \" The next step for me was to customize the buildpack. So I added my custom-interceptors.xml in  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"resources/app_dynamics_agent\"), \" .\"), mdx(\"h3\", {\n    \"id\": \"build-with-a-single-command-on-linux\"\n  }, \"Build with a single command on Linux\"), mdx(\"p\", null, \"When on Linux (running Docker directly rather then inside a VM you connect to with Docker Machine, like when using Docker Toolbox) just do this: \", \"[\", \"code language=\\u201Cbash\\u201D\", \"]\", \" docker run \\u2014rm -v \\u201C$PWD\\u201D:/usr/src/java-buildpack -w /usr/src/java-buildpack ruby:2.2.8 /bin/bash -c \\u201Cbundle install; bundle exec rake clean package OFFLINE=true PINNED=true\\u201D \", \"[\", \"/code\", \"]\", \" The  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"/bin/bash -c ...\"), \"  part is to run multiple commands, as described \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://stackoverflow.com/questions/28490874/docker-run-image-multiple-commands\"\n  }), \"here\"), \". If you use Linux: Congratulations, you\\u2019re done!\"), mdx(\"h3\", {\n    \"id\": \"avoid-the-pitfalls-on-windows\"\n  }, \"Avoid the pitfalls on Windows\"), mdx(\"p\", null, \"When using Windows 7 you are forced to use Docker through Docker Machine, which is installed for you with \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://www.docker.com/products/docker-toolbox\"\n  }), \"Docker Toolbox\"), \". However the above mentioned command won\\u2019t run successfully on Windows using Docker Toolbox. The reason is that \", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"if you are using Docker Machine on Mac or Windows, your Docker daemon has only limited access to your OS X or Windows filesystem\"), mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"#fn-543-2\"\n  }), \"2\"), \". But we can work around that. First, before performing any Docker commands connect the Docker cli on your host with the Docker-Machine, which looks something like this: \", \"[\", \"code language=\\u201Cbash\\u201D\", \"]\", \" docker-machine start docker-machine env eval $(\\u201CC:/Program Files/Docker Toolbox/docker-machine.exe\\u201D env) \", \"[\", \"/code\", \"]\", \" Your path to docker-machine.exe might be different. Make sure to use the path the  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"docker-machine env\"), \"  output is telling you. Now make sure you have git cloned java-buildpack somewhere in  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"C:\\\\Users\\\\<Your_Username>\"), \" . So as an example let\\u2019s say you cloned to  \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"C:\\\\Users\\\\USER\\\\java-buildpack\"), \" . In that case the following command will work on Windows and package the Java Buildpack for you: \", \"[\", \"code language=\\u201Cbash\\u201D\", \"]\", \" docker run \\u2014rm -v /c/Users/USER/java-buildpack:/usr/src/java-buildpack -w /usr/src/java-buildpack ruby:2.2.8 /bin/bash -c \\u201Cbundle install; bundle exec rake clean package OFFLINE=true PINNED=true\\u201D \", \"[\", \"/code\", \"]\"), mdx(\"h2\", {\n    \"id\": \"docker-saves-the-day\"\n  }, \"Docker saves the day\"), mdx(\"p\", null, \"So once again Docker is really useful in helping me build source code written in languages I actually don\\u2019t use and thus don\\u2019t have the proper tools for. Instead of spending time to find out if and how I can install Ruby or \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/rbenv/rbenv\"\n  }), \"rbenv\"), \" I can quickly jump into building the package I need and move on with working on our own application\\u2019s source code.\"), mdx(\"hr\", null), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"a\", _extends({\n    parentName: \"li\"\n  }, {\n    \"href\": \"https://github.com/cloudfoundry/java-buildpack#online-package\"\n  }), \"https://github.com/cloudfoundry/java-buildpack#online-package\"), \"\\xA0\", mdx(\"a\", _extends({\n    parentName: \"li\"\n  }, {\n    \"href\": \"#fnref-543-1\"\n  }), \"\\u21A9\")), mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"a\", _extends({\n    parentName: \"li\"\n  }, {\n    \"href\": \"https://stackoverflow.com/a/34255036\"\n  }), \"https://stackoverflow.com/a/34255036\"), \"\\xA0\", mdx(\"a\", _extends({\n    parentName: \"li\"\n  }, {\n    \"href\": \"#fnref-543-2\"\n  }), \"\\u21A9\"))));\n}\n;\nMDXContent.isMDXComponent = true;","slug":"/package-java-buildpack-with-docker/","title":"Package Cloud Foundry java-buildpack with Docker","tags":[],"keywords":[],"date":"November 26, 2017"},"previous":{"__typename":"MdxBlogPost","id":"32736f66-7def-5241-999b-137d1e17a8b6","excerpt":"When a bug in your Android app is hard to reproduce, it can make sense to install a debuggable version of your app on more than one device…","slug":"/send-adb-command-to-all-devices/","title":"Quicktip: Send ADB command to all connected devices","date":"August 08, 2017"},"next":{"__typename":"MdxBlogPost","id":"a4bbc0e9-2bd1-5bd9-aca8-729924f9df05","excerpt":"I finally managed to update my system to Ubuntu 17.10. After doing that I wanted to install  TeamSpeak 3 , which does not come in a .deb…","slug":"/quicktip-create-app-launchers-in-ubuntu-17-10/","title":"Quicktip: Create app launchers in Ubuntu 17.10","date":"December 31, 2017"}},"pageContext":{"isCreatedByStatefulCreatePages":false,"id":"9b9ecf8f-33f4-589d-b078-ed291093181a","previousId":"32736f66-7def-5241-999b-137d1e17a8b6","nextId":"a4bbc0e9-2bd1-5bd9-aca8-729924f9df05"}}}