├── LICENSE ├── Makefile ├── README.md ├── centos7-s2i-nodejs.json ├── hack ├── build.sh ├── common.mk ├── latest.js ├── publish.sh ├── rebuild.sh └── tag.sh ├── image-streams-candidate.json ├── image-streams.json ├── nodejs.org ├── Dockerfile ├── Dockerfile.onbuild ├── Dockerfile.sourcebuild ├── README.md ├── contrib │ └── etc │ │ ├── generate_container_user │ │ └── npm_global_module_list ├── s2i │ └── bin │ │ ├── assemble │ │ ├── run │ │ └── usage └── test │ ├── run │ └── test-app │ ├── README.md │ ├── iisnode.yml │ ├── package.json │ ├── server.js │ └── web.config └── package.json /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 [yyyy] [name of copyright owner] 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. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Include common Makefile code. 2 | BASE_IMAGE_NAME=s2i-nodejs 3 | ONBUILD_IMAGE_NAME=nodejs 4 | NAMESPACE=ryanj 5 | VERSIONS = 0.10.48 0.12.18 4.8.1 5.12.0 6.10.1 7.7.4 6 | 7 | # Include common Makefile code. 8 | include hack/common.mk 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Origin S2I NodeJS 2 | ================= 3 | 4 | This repository contains sources for an [s2i](https://github.com/openshift/source-to-image) builder image, based on CentOS7 and nodejs releases from nodejs.org. 5 | 6 | If you are interested in developing against SCL-based nodejs releases, try [sti-nodejs](https://github.com/openshift/sti-nodejs). 7 | 8 | [![docker hub stats](http://dockeri.co/image/ryanj/centos7-s2i-nodejs)](https://hub.docker.com/r/ryanj/centos7-s2i-nodejs/) 9 | 10 | [![](https://images.microbadger.com/badges/image/ryanj/centos7-s2i-nodejs.svg)](https://microbadger.com/images/ryanj/centos7-s2i-nodejs "Get your own image badge on microbadger.com") 11 | 12 | For more information about using these images with OpenShift, please see the 13 | official [OpenShift Documentation](https://docs.openshift.org/latest/using_images/s2i_images/nodejs.html). 14 | 15 | Versions 16 | --------------- 17 | [Node.JS versions currently provided are](https://hub.docker.com/r/ryanj/centos7-s2i-nodejs/tags/): 18 | 19 | * `7.7.4` `current` 20 | * `6.10.1` `lts` 21 | * `5.12.0` 22 | * `4.8.1` 23 | * `0.12.18` 24 | * `0.10.48` 25 | 26 | Usage 27 | --------------------------------- 28 | 29 | OpenShift allows you to quickly start a build using the web console, or the CLI. 30 | 31 | The [`oc` command-line tool](https://github.com/openshift/origin/releases) can be used to start a build, layering your desired nodejs `REPO_URL` sources into a centos7 image with your selected `RELEASE` of nodejs via the following command format: 32 | 33 | oc new-app ryanj/centos7-s2i-nodejs:RELEASE~REPO_URL 34 | 35 | For example, you can run a build (including `npm install` steps), using my [`http-base`](http://github.com/ryanj/http-base) example repo, and the `current` release of nodejs with: 36 | 37 | oc new-app ryanj/centos7-s2i-nodejs:current~http://github.com/ryanj/http-base 38 | 39 | Or, to run the latest `lts` release with my [`pillar-base`](http://github.com/ryanj/pillar-base) example: 40 | 41 | oc new-app ryanj/centos7-s2i-nodejs:lts~http://github.com/ryanj/pillar-base 42 | 43 | You can try using any of the available tagged nodejs releases, and your own repo sources - as long as your application source will init correctly with `npm start`, and listen on port 8080. 44 | 45 | Builds 46 | ------ 47 | 48 | The [Source2Image cli tools](https://github.com/openshift/source-to-image/releases) are available as a standalone project, allowing you to [run builds outside of OpenShift](https://github.com/ryanj/origin-s2i-nodejs/blob/master/nodejs.org/README.md#usage). 49 | 50 | This example will produce a new docker image named `pillarjs`: 51 | 52 | s2i build https://github.com/ryanj/pillar-base ryanj/centos7-s2i-nodejs:current pillarjs 53 | 54 | Installation 55 | --------------- 56 | 57 | There are several ways to make this base image and the full list of tagged nodejs releases available to users during OpenShift's web-based "Add to Project" workflow. 58 | 59 | #### For OpenShift Online Next Gen Developer Preview 60 | Those without admin privileges can install the latest nodejs releases within their project context with: 61 | 62 | oc create -f https://raw.githubusercontent.com/ryanj/origin-s2i-nodejs/master/image-streams.json 63 | 64 | To ensure that each of the latest NodeJS release tags are available and displayed correctly in the web UI, try upgrading / reinstalling the imageStream: 65 | 66 | oc delete is/centos7-s2i-nodejs ; oc create -f https://raw.githubusercontent.com/ryanj/origin-s2i-nodejs/master/image-streams.json 67 | 68 | If you've (automatically) imported this image using the [`oc new-app` example command](#usage), then you may need to clear the auto-imported image stream reference and re-install it. 69 | 70 | #### For Administrators 71 | 72 | Administrators can make these NodeJS releases available globally (visible in all projects, by all users) by adding them to the `openshift` namespace: 73 | 74 | oc create -n openshift -f https://raw.githubusercontent.com/ryanj/origin-s2i-nodejs/master/image-streams.json 75 | 76 | To replace [the default SCL-packaged `openshift/nodejs` image](https://hub.docker.com/r/openshift/nodejs-010-centos7/) (admin access required), run: 77 | 78 | oc delete is/nodejs -n openshift ; oc create -n openshift -f https://raw.githubusercontent.com/ryanj/origin-s2i-nodejs/master/centos7-s2i-nodejs.json 79 | 80 | Building your own Builder images 81 | -------------------------------- 82 | Clone a copy of this repo to fetch the build sources: 83 | 84 | $ git clone https://github.com/ryanj/origin-s2i-nodejs.git 85 | $ cd origin-s2i-nodejs 86 | 87 | To build your own S2I Node.JS builder images from scratch, run: 88 | 89 | $ docker pull openshift/base-centos7 90 | $ make build 91 | 92 | You can also build a specific release, or try building the alternate `ONBUILD` version of this base: 93 | 94 | $ ONBUILD=true make VERSION=7.7.4 95 | 96 | The `ONBUILD` base images are available at https://hub.docker.com/r/ryanj/centos7-nodejs 97 | 98 | Test 99 | --------------------- 100 | This repository also provides a [S2I](https://github.com/openshift/source-to-image) test framework, 101 | which launches tests to check functionality of a simple Node.JS application built on top of the sti-nodejs image. 102 | 103 | Users can choose between testing a Node.JS test application based on a RHEL or CentOS image. 104 | 105 | * **CentOS based image** 106 | 107 | ``` 108 | $ cd sti-nodejs 109 | $ make test 110 | ``` 111 | 112 | Repository organization 113 | ------------------------ 114 | * **`nodejs.org/`** 115 | 116 | Dockerfile and scripts to build container images. 117 | 118 | * **`hack/`** 119 | 120 | Folder containing scripts which are responsible for the build and test actions performed by the `Makefile`. 121 | 122 | * ** `image-streams.json` ** 123 | 124 | Use this file to add these runtimes to OpenShift's web-based **"Add to Project"** workflow. 125 | 126 | * ** `Makefile` ** 127 | 128 | See the [build your own builder images](#build_your_own_builder_images) section of the `README` for `build` and `test` usage details. 129 | -------------------------------------------------------------------------------- /centos7-s2i-nodejs.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "ImageStreamList", 3 | "apiVersion": "v1", 4 | "metadata": {}, 5 | "items": [ 6 | { 7 | "kind": "ImageStream", 8 | "apiVersion": "v1", 9 | "metadata": { 10 | "name": "nodejs", 11 | "creationTimestamp": null 12 | }, 13 | "spec": { 14 | "tags": [ 15 | { 16 | "name": "0.10", 17 | "annotations": { 18 | "description": "Build and run NodeJS applications", 19 | "iconClass": "icon-nodejs", 20 | "tags": "builder,nodejs,nodejs-0.10.46", 21 | "supports":"nodejs:0.10,nodejs", 22 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 23 | }, 24 | "from": { 25 | "kind": "ImageStreamTag", 26 | "name": "0.10.46" 27 | } 28 | }, 29 | { 30 | "name": "0.10.46", 31 | "annotations": { 32 | "description": "Build and run NodeJS applications", 33 | "iconClass": "icon-nodejs", 34 | "tags": "builder,nodejs,nodejs-0.10.46", 35 | "supports":"nodejs:0.10,nodejs", 36 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 37 | }, 38 | "from": { 39 | "kind": "DockerImage", 40 | "name": "ryanj/centos7-s2i-nodejs:0.10.46" 41 | } 42 | }, 43 | { 44 | "name": "0.12", 45 | "annotations": { 46 | "description": "Build and run NodeJS applications", 47 | "iconClass": "icon-nodejs", 48 | "tags": "builder,nodejs,nodejs-0.12.15", 49 | "supports":"nodejs:0.12,nodejs", 50 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 51 | }, 52 | "from": { 53 | "kind": "ImageStreamTag", 54 | "name": "0.12.15" 55 | } 56 | }, 57 | { 58 | "name": "0.12.15", 59 | "annotations": { 60 | "description": "Build and run NodeJS applications", 61 | "iconClass": "icon-nodejs", 62 | "tags": "builder,nodejs,nodejs-0.12.15", 63 | "supports":"nodejs:0.12,nodejs", 64 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 65 | }, 66 | "from": { 67 | "kind": "DockerImage", 68 | "name": "ryanj/centos7-s2i-nodejs:0.12.15" 69 | } 70 | }, 71 | { 72 | "name": "lts", 73 | "annotations": { 74 | "description": "Build and run NodeJS applications", 75 | "iconClass": "icon-nodejs", 76 | "tags": "builder,nodejs,nodejs-4.4.7,nodejs-lts", 77 | "supports":"nodejs:4,nodejs:4.4,nodejs", 78 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 79 | }, 80 | "from": { 81 | "kind": "ImageStreamTag", 82 | "name": "4.4.7" 83 | } 84 | }, 85 | { 86 | "name": "4", 87 | "annotations": { 88 | "description": "Build and run NodeJS applications", 89 | "iconClass": "icon-nodejs", 90 | "tags": "builder,nodejs,nodejs-4.4.7", 91 | "supports":"nodejs:4,nodejs:4.4,nodejs", 92 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 93 | }, 94 | "from": { 95 | "kind": "ImageStreamTag", 96 | "name": "4.4.7" 97 | } 98 | }, 99 | { 100 | "name": "4.4", 101 | "annotations": { 102 | "description": "Build and run NodeJS applications", 103 | "iconClass": "icon-nodejs", 104 | "tags": "builder,nodejs,nodejs-4.4.7", 105 | "supports":"nodejs:4,nodejs:4.4,nodejs", 106 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 107 | }, 108 | "from": { 109 | "kind": "ImageStreamTag", 110 | "name": "4.4.7" 111 | } 112 | }, 113 | { 114 | "name": "4.4.7", 115 | "annotations": { 116 | "description": "Build and run NodeJS applications", 117 | "iconClass": "icon-nodejs", 118 | "tags": "builder,nodejs,nodejs-4.4.7,nodejs-lts", 119 | "supports":"nodejs:4,nodejs:4.4,nodejs", 120 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 121 | }, 122 | "from": { 123 | "kind": "DockerImage", 124 | "name": "ryanj/centos7-s2i-nodejs:4.4.7" 125 | } 126 | }, 127 | { 128 | "name": "5.11", 129 | "annotations": { 130 | "description": "Build and run NodeJS applications", 131 | "iconClass": "icon-nodejs", 132 | "tags": "builder,nodejs,nodejs-5.12.0", 133 | "supports":"nodejs:5,nodejs:5.11,nodejs", 134 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 135 | }, 136 | "from": { 137 | "kind": "ImageStreamTag", 138 | "name": "5.12.0" 139 | } 140 | }, 141 | { 142 | "name": "5", 143 | "annotations": { 144 | "description": "Build and run NodeJS applications", 145 | "iconClass": "icon-nodejs", 146 | "tags": "builder,nodejs,nodejs-5.12.0", 147 | "supports":"nodejs:5,nodejs:5.11,nodejs", 148 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 149 | }, 150 | "from": { 151 | "kind": "ImageStreamTag", 152 | "name": "5.12.0" 153 | } 154 | }, 155 | { 156 | "name": "5.12.0", 157 | "annotations": { 158 | "description": "Build and run NodeJS applications", 159 | "iconClass": "icon-nodejs", 160 | "tags": "builder,nodejs,nodejs-5.12.0,nodejs-latest", 161 | "supports":"nodejs:5,nodejs:5.11,nodejs", 162 | "version": "5.12.0", 163 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 164 | }, 165 | "from": { 166 | "kind": "DockerImage", 167 | "name": "ryanj/centos7-s2i-nodejs:5.12.0" 168 | } 169 | }, 170 | { 171 | "name": "latest", 172 | "annotations": { 173 | "description": "Build and run NodeJS applications", 174 | "iconClass": "icon-nodejs", 175 | "tags": "builder,nodejs,nodejs-6.3.1", 176 | "supports":"nodejs:6,nodejs:6.2,nodejs", 177 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 178 | }, 179 | "from": { 180 | "kind": "ImageStreamTag", 181 | "name": "6.3.1" 182 | } 183 | }, 184 | { 185 | "name": "6.2", 186 | "annotations": { 187 | "description": "Build and run NodeJS applications", 188 | "iconClass": "icon-nodejs", 189 | "tags": "builder,nodejs,nodejs-6.3.1", 190 | "supports":"nodejs:6,nodejs:6.2,nodejs", 191 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 192 | }, 193 | "from": { 194 | "kind": "ImageStreamTag", 195 | "name": "6.3.1" 196 | } 197 | }, 198 | { 199 | "name": "6", 200 | "annotations": { 201 | "description": "Build and run NodeJS applications", 202 | "iconClass": "icon-nodejs", 203 | "tags": "builder,nodejs,nodejs-6.3.1", 204 | "supports":"nodejs:6,nodejs:6.2,nodejs", 205 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 206 | }, 207 | "from": { 208 | "kind": "ImageStreamTag", 209 | "name": "6.3.1" 210 | } 211 | }, 212 | { 213 | "name": "current", 214 | "annotations": { 215 | "description": "Build and run NodeJS applications", 216 | "iconClass": "icon-nodejs", 217 | "tags": "builder,nodejs,nodejs-6.3.1,nodejs-current", 218 | "supports":"nodejs:6,nodejs:6.2,nodejs", 219 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 220 | }, 221 | "from": { 222 | "kind": "ImageStreamTag", 223 | "name": "6.3.1" 224 | } 225 | }, 226 | { 227 | "name": "6.3.1", 228 | "annotations": { 229 | "description": "Build and run NodeJS applications", 230 | "iconClass": "icon-nodejs", 231 | "tags": "builder,nodejs,nodejs-6.3.1,nodejs-latest", 232 | "supports":"nodejs:6,nodejs:6.2,nodejs", 233 | "version": "6.3.1", 234 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 235 | }, 236 | "from": { 237 | "kind": "DockerImage", 238 | "name": "ryanj/centos7-s2i-nodejs:6.3.1" 239 | } 240 | } 241 | ] 242 | } 243 | } 244 | ] 245 | } 246 | -------------------------------------------------------------------------------- /hack/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # This script is used to build, test and squash the OpenShift Docker images. 3 | # 4 | # Name of resulting image will be: 'NAMESPACE/OS-BASE_IMAGE_NAME:NODE_VERSION'. 5 | # 6 | # VERSION - Specifies the image version 7 | # TEST_MODE - If set, build a candidate image and test it 8 | # TAG_ON_SUCCESS - If set, tested image will be re-tagged as a non-candidate 9 | # image, if the tests pass. 10 | # VERSIONS - a list of possible versions, can be provided instead of VERSION 11 | 12 | OS=${1-$OS} 13 | VERSION=${2-$VERSION} 14 | 15 | DOCKERFILE="Dockerfile" 16 | if [ "${ONBUILD}+enabled" ]; then 17 | BASE_IMAGE_NAME="${ONBUILD_IMAGE_NAME}" 18 | DOCKERFILE+=".onbuild" 19 | fi 20 | 21 | # Cleanup the temporary Dockerfile created by docker build with version 22 | trap "rm -f ${DOCKERFILE}.${version}" SIGINT SIGQUIT EXIT 23 | 24 | # Perform docker build but append the LABEL with GIT commit id at the end 25 | function docker_build_with_version { 26 | cp ${DOCKERFILE} "${DOCKERFILE}.${version}" 27 | git_version=$(git rev-parse HEAD) 28 | sed -e "s/NODE_VERSION *= *.*/NODE_VERSION=${version} \\\/" -i "${DOCKERFILE}.${version}" 29 | echo "LABEL io.origin.builder-version=\"${git_version}\"" >> "${DOCKERFILE}.${version}" 30 | docker build -t ${IMAGE_NAME}:${version} -f "${DOCKERFILE}.${version}" . 31 | if [[ "${SKIP_SQUASH}" != "1" ]]; then 32 | squash "${DOCKERFILE}.${version}" 33 | fi 34 | rm -f "${DOCKERFILE}.${version}" 35 | } 36 | 37 | # Install the docker squashing tool[1] and squash the result image 38 | # [1] https://github.com/goldmann/docker-squash 39 | function squash { 40 | # FIXME: We have to use the exact versions here to avoid Docker client 41 | # compatibility issues 42 | easy_install -q --user docker_py==1.7.2 docker-squash==1.0.1 43 | base=$(awk '/^FROM/{print $2}' $1) 44 | docker-squash -f $base ${IMAGE_NAME}:${version} 45 | } 46 | 47 | # Specify a VERSION variable to build a specific nodejs.org release 48 | # or specify a list of VERSIONS 49 | versions=${VERSION:-$VERSIONS} 50 | 51 | for version in ${versions}; do 52 | IMAGE_NAME="${NAMESPACE}/${OS}-${BASE_IMAGE_NAME}" 53 | 54 | if [ "${TEST_MODE}+enabled" ]; then 55 | IMAGE_NAME+="-candidate" 56 | fi 57 | 58 | echo "-> Building ${IMAGE_NAME}:${version} ..." 59 | 60 | pushd "nodejs.org" > /dev/null 61 | if [ "$OS" == "fedora" -o "$OS" == "fedora-candidate" ]; then 62 | docker_build_with_version Dockerfile.fedora 63 | else 64 | docker_build_with_version Dockerfile 65 | fi 66 | 67 | if [ "${TEST_MODE}+enabled" ]; then 68 | IMAGE_NAME=${IMAGE_NAME} NODE_VERSION=${version} test/run 69 | 70 | if [[ $? -eq 0 ]] && [[ "${TAG_ON_SUCCESS}" == "true" ]]; then 71 | echo "-> Re-tagging ${IMAGE_NAME}:${version} image to ${IMAGE_NAME%"-candidate"}:${version}" 72 | docker tag -f $IMAGE_NAME:$version ${IMAGE_NAME%"-candidate"}:${version} 73 | fi 74 | 75 | if [[ ! -z "${REGISTRY}" ]]; then 76 | echo "-> Tagging image as" ${REGISTRY}/${IMAGE_NAME%"-candidate"} 77 | docker tag -f $IMAGE_NAME ${REGISTRY}/${IMAGE_NAME%"-candidate"} 78 | fi 79 | fi 80 | 81 | popd > /dev/null 82 | done 83 | -------------------------------------------------------------------------------- /hack/common.mk: -------------------------------------------------------------------------------- 1 | SKIP_SQUASH?=0 2 | 3 | build = hack/build.sh 4 | 5 | ifeq ($(TARGET),fedora) 6 | OS := fedora 7 | else 8 | OS := centos7 9 | endif 10 | 11 | script_env = \ 12 | SKIP_SQUASH="$(SKIP_SQUASH)" \ 13 | VERSIONS="$(VERSIONS)" \ 14 | OS="$(OS)" \ 15 | NAMESPACE="$(NAMESPACE)" \ 16 | BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" \ 17 | ONBUILD_IMAGE_NAME="$(ONBUILD_IMAGE_NAME)" \ 18 | VERSION="$(VERSION)" 19 | 20 | .PHONY: build 21 | build: 22 | $(script_env) $(build) 23 | 24 | .PHONY: all 25 | all: 26 | make rebuild && make test && make build && make onbuild && make tags && make publish 27 | 28 | .PHONY: onbuild 29 | onbuild: 30 | $(script_env) ONBUILD=true $(build) 31 | 32 | .PHONY: tags 33 | tags: 34 | $(script_env) npm run tag 35 | 36 | .PHONY: publish 37 | publish: 38 | $(script_env) npm run pub 39 | 40 | .PHONY: rebuild 41 | rebuild: 42 | $(script_env) npm run rebuild 43 | 44 | .PHONY: test 45 | test: 46 | $(script_env) TAG_ON_SUCCESS=$(TAG_ON_SUCCESS) TEST_MODE=true $(build) 47 | 48 | .PHONY: clean 49 | clean: 50 | npm run clean 51 | -------------------------------------------------------------------------------- /hack/latest.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var request = require('request'), 3 | semver = require('semver'), 4 | latest_releases = { 5 | '0.10': undefined, 6 | '0.12': undefined, 7 | '4': undefined, 8 | '5': undefined, 9 | '6': undefined, 10 | '7': undefined}; 11 | 12 | function parse_releases(json_releases){ 13 | var releases = JSON.parse(json_releases); 14 | var versions = []; 15 | // group by major release version 16 | for(var release in releases){ 17 | var release_ver = releases[release]['version']; 18 | for(var major_version in latest_releases){ 19 | if(semver.satisfies(release_ver, major_version)){ 20 | if( typeof(latest_releases[major_version]) == 'undefined' || 21 | semver.gt(release_ver, latest_releases[major_version])){ 22 | latest_releases[major_version] = semver.clean(release_ver); 23 | } 24 | } 25 | } 26 | } 27 | 28 | for(var version in latest_releases){ 29 | versions.push(latest_releases[version]); 30 | } 31 | console.log(versions.sort().join(' ')); 32 | }; 33 | 34 | request('https://nodejs.org/dist/index.json', function (error, response, body) { 35 | if (!error && response.statusCode == 200) { 36 | parse_releases(body) 37 | }else{ 38 | console.error("Error fetching latest release info from: \nhttps://nodejs.org/dist/index.json") 39 | } 40 | }) 41 | -------------------------------------------------------------------------------- /hack/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | BASE_IMAGES="${NAMESPACE}/${OS}-${ONBUILD_IMAGE_NAME} ${NAMESPACE}/${OS}-${BASE_IMAGE_NAME} ${NAMESPACE}/${OS}-${BASE_IMAGE_NAME}-candidate" 4 | 5 | if [ ! -z $DOCKER_USER ] && [ ! -z $DOCKER_PASS ]; then 6 | echo "---> Authenticating to DockerHub..." 7 | docker login --username $DOCKER_USER --password $DOCKER_PASS 8 | fi 9 | 10 | for BASE in $BASE_IMAGES ; do 11 | echo "publishing: ${BASE}..." 12 | docker push $BASE 13 | done 14 | -------------------------------------------------------------------------------- /hack/rebuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | LAST_RELEASE="$(grep 'NODE_VERSION=' nodejs.org/Dockerfile | sed -e "s/ *NODE_VERSION=\([^ ]*\) \\\/\1/")" 4 | LAST_RELEASES="$VERSIONS" 5 | MAJOR_RELEASES=6 6 | LATEST_RELEASES="$(node ./hack/latest.js)" 7 | LATEST_RELEASE="$(echo $LATEST_RELEASES | cut -f$MAJOR_RELEASES -d' ')" 8 | NUMS="$(seq 1 `echo $LAST_RELEASES | wc -w`)" 9 | #Files with hard-coded version strings: 10 | LAST_UPDATES_NEEDED="centos7-s2i-nodejs.json \ 11 | image-streams-candidate.json \ 12 | image-streams.json \ 13 | README.md" 14 | LATEST_UPDATES_NEEDED="hack/build.sh \ 15 | nodejs.org/Dockerfile \ 16 | nodejs.org/Dockerfile.onbuild" 17 | 18 | if [ "${LAST_RELEASES}" != "${LATEST_RELEASES}" ] ; then 19 | echo "New NodeJS releases available!: ${LATEST_RELEASES}" 20 | sed -e "s/VERSIONS.*/VERSIONS = $LATEST_RELEASES/" -i Makefile 21 | 22 | for release in $NUMS ; do 23 | last="$( echo ${LAST_RELEASES} | cut -d' ' -f$release )" 24 | latest="$( echo ${LATEST_RELEASES} | cut -d' ' -f$release )" 25 | if [ $last != $latest ] ; then 26 | echo "Updating v$last to v$latest" 27 | for file in $LAST_UPDATES_NEEDED ; do 28 | sed -e "s/${last}/${latest}/g" -i $file 29 | done 30 | fi 31 | done 32 | 33 | if [ "${LAST_RELEASE}" != "${LATEST_RELEASE}" ] ; then 34 | for file in $LATEST_UPDATES_NEEDED ; do 35 | sed -e "s/${LAST_RELEASE}/${LATEST_RELEASE}/g" -i $file 36 | done 37 | fi 38 | 39 | docker pull openshift/base-centos7 40 | 41 | else 42 | echo "No new NodeJS releases found" 43 | fi 44 | -------------------------------------------------------------------------------- /hack/tag.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | BASE_IMAGES="${NAMESPACE}/${OS}-${ONBUILD_IMAGE_NAME} ${NAMESPACE}/${OS}-${BASE_IMAGE_NAME} ${NAMESPACE}/${OS}-${BASE_IMAGE_NAME}-candidate" 4 | 5 | for BASE in $BASE_IMAGES ; do 6 | if [ $(echo "${VERSIONS}" | wc -w) -gt 0 ] ; then 7 | for RELEASE in $VERSIONS ; do 8 | img=$(docker images | grep $BASE | grep $RELEASE | head -n 1 | tr -s ' ' | cut -f3 -d' ') 9 | if [[ $RELEASE == 0.10.* ]] ; then 10 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:0.10" 11 | docker tag -f $img $BASE:0.10 12 | elif [[ $RELEASE == 0.12.* ]] ; then 13 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:0.12" 14 | docker tag -f $img $BASE:0.12 15 | elif [[ $RELEASE == 4.* ]] ; then 16 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:4" 17 | docker tag -f $img $BASE:4 18 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:lts" 19 | docker tag -f $img $BASE:lts 20 | elif [[ $RELEASE == 5.* ]] ; then 21 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:5" 22 | docker tag -f $img $BASE:5 23 | elif [[ $RELEASE == 6.* ]] ; then 24 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:6" 25 | docker tag -f $img $BASE:6 26 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:current" 27 | docker tag -f $img $BASE:current 28 | fi 29 | done 30 | fi 31 | done 32 | -------------------------------------------------------------------------------- /image-streams-candidate.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "ImageStreamList", 3 | "apiVersion": "v1", 4 | "metadata": {}, 5 | "items": [ 6 | { 7 | "kind": "ImageStream", 8 | "apiVersion": "v1", 9 | "metadata": { 10 | "name": "centos7-s2i-nodejs-candidate", 11 | "creationTimestamp": null 12 | }, 13 | "spec": { 14 | "tags": [ 15 | { 16 | "name": "0.10", 17 | "annotations": { 18 | "description": "Build and run NodeJS applications", 19 | "iconClass": "icon-nodejs", 20 | "tags": "builder,nodejs,nodejs-0.10.46", 21 | "supports":"nodejs:0.10,nodejs", 22 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 23 | }, 24 | "from": { 25 | "kind": "ImageStreamTag", 26 | "name": "0.10.46" 27 | } 28 | }, 29 | { 30 | "name": "0.10.46", 31 | "annotations": { 32 | "description": "Build and run NodeJS applications", 33 | "iconClass": "icon-nodejs", 34 | "tags": "builder,nodejs,nodejs-0.10.46", 35 | "supports":"nodejs:0.10,nodejs", 36 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 37 | }, 38 | "from": { 39 | "kind": "DockerImage", 40 | "name": "ryanj/centos7-s2i-nodejs-candidate:0.10.46" 41 | } 42 | }, 43 | { 44 | "name": "0.12", 45 | "annotations": { 46 | "description": "Build and run NodeJS applications", 47 | "iconClass": "icon-nodejs", 48 | "tags": "builder,nodejs,nodejs-0.12.15", 49 | "supports":"nodejs:0.12,nodejs", 50 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 51 | }, 52 | "from": { 53 | "kind": "ImageStreamTag", 54 | "name": "0.12.15" 55 | } 56 | }, 57 | { 58 | "name": "0.12.15", 59 | "annotations": { 60 | "description": "Build and run NodeJS applications", 61 | "iconClass": "icon-nodejs", 62 | "tags": "builder,nodejs,nodejs-0.12.15", 63 | "supports":"nodejs:0.12,nodejs", 64 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 65 | }, 66 | "from": { 67 | "kind": "DockerImage", 68 | "name": "ryanj/centos7-s2i-nodejs-candidate:0.12.15" 69 | } 70 | }, 71 | { 72 | "name": "lts", 73 | "annotations": { 74 | "description": "Build and run NodeJS applications", 75 | "iconClass": "icon-nodejs", 76 | "tags": "builder,nodejs,nodejs-4.4.7,nodejs-lts", 77 | "supports":"nodejs:4,nodejs:4.4,nodejs", 78 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 79 | }, 80 | "from": { 81 | "kind": "ImageStreamTag", 82 | "name": "4.4.7" 83 | } 84 | }, 85 | { 86 | "name": "4", 87 | "annotations": { 88 | "description": "Build and run NodeJS applications", 89 | "iconClass": "icon-nodejs", 90 | "tags": "builder,nodejs,nodejs-4.4.7", 91 | "supports":"nodejs:4,nodejs:4.4,nodejs", 92 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 93 | }, 94 | "from": { 95 | "kind": "ImageStreamTag", 96 | "name": "4.4.7" 97 | } 98 | }, 99 | { 100 | "name": "4.4", 101 | "annotations": { 102 | "description": "Build and run NodeJS applications", 103 | "iconClass": "icon-nodejs", 104 | "tags": "builder,nodejs,nodejs-4.4.7", 105 | "supports":"nodejs:4,nodejs:4.4,nodejs", 106 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 107 | }, 108 | "from": { 109 | "kind": "ImageStreamTag", 110 | "name": "4.4.7" 111 | } 112 | }, 113 | { 114 | "name": "4.4.7", 115 | "annotations": { 116 | "description": "Build and run NodeJS applications", 117 | "iconClass": "icon-nodejs", 118 | "tags": "builder,nodejs,nodejs-4.4.7,nodejs-lts", 119 | "supports":"nodejs:4,nodejs:4.4,nodejs", 120 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 121 | }, 122 | "from": { 123 | "kind": "DockerImage", 124 | "name": "ryanj/centos7-s2i-nodejs-candidate:4.4.7" 125 | } 126 | }, 127 | { 128 | "name": "5.11", 129 | "annotations": { 130 | "description": "Build and run NodeJS applications", 131 | "iconClass": "icon-nodejs", 132 | "tags": "builder,nodejs,nodejs-5.12.0", 133 | "supports":"nodejs:5,nodejs:5.11,nodejs", 134 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 135 | }, 136 | "from": { 137 | "kind": "ImageStreamTag", 138 | "name": "5.12.0" 139 | } 140 | }, 141 | { 142 | "name": "5", 143 | "annotations": { 144 | "description": "Build and run NodeJS applications", 145 | "iconClass": "icon-nodejs", 146 | "tags": "builder,nodejs,nodejs-5.12.0", 147 | "supports":"nodejs:5,nodejs:5.11,nodejs", 148 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 149 | }, 150 | "from": { 151 | "kind": "ImageStreamTag", 152 | "name": "5.12.0" 153 | } 154 | }, 155 | { 156 | "name": "5.12.0", 157 | "annotations": { 158 | "description": "Build and run NodeJS applications", 159 | "iconClass": "icon-nodejs", 160 | "tags": "builder,nodejs,nodejs-5.12.0,nodejs-latest", 161 | "supports":"nodejs:5,nodejs:5.11,nodejs", 162 | "version": "5.12.0", 163 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 164 | }, 165 | "from": { 166 | "kind": "DockerImage", 167 | "name": "ryanj/centos7-s2i-nodejs-candidate:5.12.0" 168 | } 169 | }, 170 | { 171 | "name": "latest", 172 | "annotations": { 173 | "description": "Build and run NodeJS applications", 174 | "iconClass": "icon-nodejs", 175 | "tags": "builder,nodejs,nodejs-6.3.1", 176 | "supports":"nodejs:6,nodejs:6.2,nodejs", 177 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 178 | }, 179 | "from": { 180 | "kind": "ImageStreamTag", 181 | "name": "6.3.1" 182 | } 183 | }, 184 | { 185 | "name": "6.2", 186 | "annotations": { 187 | "description": "Build and run NodeJS applications", 188 | "iconClass": "icon-nodejs", 189 | "tags": "builder,nodejs,nodejs-6.3.1", 190 | "supports":"nodejs:6,nodejs:6.2,nodejs", 191 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 192 | }, 193 | "from": { 194 | "kind": "ImageStreamTag", 195 | "name": "6.3.1" 196 | } 197 | }, 198 | { 199 | "name": "6", 200 | "annotations": { 201 | "description": "Build and run NodeJS applications", 202 | "iconClass": "icon-nodejs", 203 | "tags": "builder,nodejs,nodejs-6.3.1", 204 | "supports":"nodejs:6,nodejs:6.2,nodejs", 205 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 206 | }, 207 | "from": { 208 | "kind": "ImageStreamTag", 209 | "name": "6.3.1" 210 | } 211 | }, 212 | { 213 | "name": "current", 214 | "annotations": { 215 | "description": "Build and run NodeJS applications", 216 | "iconClass": "icon-nodejs", 217 | "tags": "builder,nodejs,nodejs-6.3.1,nodejs-current", 218 | "supports":"nodejs:6,nodejs:6.2,nodejs", 219 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 220 | }, 221 | "from": { 222 | "kind": "ImageStreamTag", 223 | "name": "6.3.1" 224 | } 225 | }, 226 | { 227 | "name": "6.3.1", 228 | "annotations": { 229 | "description": "Build and run NodeJS applications", 230 | "iconClass": "icon-nodejs", 231 | "tags": "builder,nodejs,nodejs-6.3.1,nodejs-latest", 232 | "supports":"nodejs:6,nodejs:6.2,nodejs", 233 | "version": "6.3.1", 234 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 235 | }, 236 | "from": { 237 | "kind": "DockerImage", 238 | "name": "ryanj/centos7-s2i-nodejs-candidate:6.3.1" 239 | } 240 | } 241 | ] 242 | } 243 | } 244 | ] 245 | } 246 | -------------------------------------------------------------------------------- /image-streams.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "ImageStreamList", 3 | "apiVersion": "v1", 4 | "metadata": {}, 5 | "items": [ 6 | { 7 | "kind": "ImageStream", 8 | "apiVersion": "v1", 9 | "metadata": { 10 | "name": "centos7-s2i-nodejs", 11 | "creationTimestamp": null 12 | }, 13 | "spec": { 14 | "tags": [ 15 | { 16 | "name": "0.10", 17 | "annotations": { 18 | "description": "Build and run NodeJS applications", 19 | "iconClass": "icon-nodejs", 20 | "tags": "builder,nodejs,nodejs-0.10.48", 21 | "supports":"nodejs:0.10,nodejs", 22 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 23 | }, 24 | "from": { 25 | "kind": "ImageStreamTag", 26 | "name": "0.10.48" 27 | } 28 | }, 29 | { 30 | "name": "0.10.48", 31 | "annotations": { 32 | "description": "Build and run NodeJS applications", 33 | "iconClass": "icon-nodejs", 34 | "tags": "builder,nodejs,nodejs-0.10.48", 35 | "supports":"nodejs:0.10,nodejs", 36 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 37 | }, 38 | "from": { 39 | "kind": "DockerImage", 40 | "name": "ryanj/centos7-s2i-nodejs:0.10.48" 41 | } 42 | }, 43 | { 44 | "name": "0.12", 45 | "annotations": { 46 | "description": "Build and run NodeJS applications", 47 | "iconClass": "icon-nodejs", 48 | "tags": "builder,nodejs,nodejs-0.12.18", 49 | "supports":"nodejs:0.12,nodejs", 50 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 51 | }, 52 | "from": { 53 | "kind": "ImageStreamTag", 54 | "name": "0.12.18" 55 | } 56 | }, 57 | { 58 | "name": "0.12.18", 59 | "annotations": { 60 | "description": "Build and run NodeJS applications", 61 | "iconClass": "icon-nodejs", 62 | "tags": "builder,nodejs,nodejs-0.12.18", 63 | "supports":"nodejs:0.12,nodejs", 64 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 65 | }, 66 | "from": { 67 | "kind": "DockerImage", 68 | "name": "ryanj/centos7-s2i-nodejs:0.12.18" 69 | } 70 | }, 71 | { 72 | "name": "4", 73 | "annotations": { 74 | "description": "Build and run NodeJS applications", 75 | "iconClass": "icon-nodejs", 76 | "tags": "builder,nodejs,nodejs-4.8.1", 77 | "supports":"nodejs:4,nodejs:4.8,nodejs", 78 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 79 | }, 80 | "from": { 81 | "kind": "ImageStreamTag", 82 | "name": "4.8.1" 83 | } 84 | }, 85 | { 86 | "name": "4.8", 87 | "annotations": { 88 | "description": "Build and run NodeJS applications", 89 | "iconClass": "icon-nodejs", 90 | "tags": "builder,nodejs,nodejs-4.8.1", 91 | "supports":"nodejs:4,nodejs:4.8,nodejs", 92 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 93 | }, 94 | "from": { 95 | "kind": "ImageStreamTag", 96 | "name": "4.8.1" 97 | } 98 | }, 99 | { 100 | "name": "4.8.1", 101 | "annotations": { 102 | "description": "Build and run NodeJS applications", 103 | "iconClass": "icon-nodejs", 104 | "tags": "builder,nodejs,nodejs-4.8.1", 105 | "supports":"nodejs:4,nodejs:4.8,nodejs", 106 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 107 | }, 108 | "from": { 109 | "kind": "DockerImage", 110 | "name": "ryanj/centos7-s2i-nodejs:4.8.1" 111 | } 112 | }, 113 | { 114 | "name": "5.12", 115 | "annotations": { 116 | "description": "Build and run NodeJS applications", 117 | "iconClass": "icon-nodejs", 118 | "tags": "builder,nodejs,nodejs-5.12.0", 119 | "supports":"nodejs:5,nodejs:5.12,nodejs", 120 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 121 | }, 122 | "from": { 123 | "kind": "ImageStreamTag", 124 | "name": "5.12.0" 125 | } 126 | }, 127 | { 128 | "name": "5", 129 | "annotations": { 130 | "description": "Build and run NodeJS applications", 131 | "iconClass": "icon-nodejs", 132 | "tags": "builder,nodejs,nodejs-5.12.0", 133 | "supports":"nodejs:5,nodejs:5.12,nodejs", 134 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 135 | }, 136 | "from": { 137 | "kind": "ImageStreamTag", 138 | "name": "5.12.0" 139 | } 140 | }, 141 | { 142 | "name": "5.12.0", 143 | "annotations": { 144 | "description": "Build and run NodeJS applications", 145 | "iconClass": "icon-nodejs", 146 | "tags": "builder,nodejs,nodejs-5.12.0,nodejs-latest", 147 | "supports":"nodejs:5,nodejs:5.12,nodejs", 148 | "version": "5.12.0", 149 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 150 | }, 151 | "from": { 152 | "kind": "DockerImage", 153 | "name": "ryanj/centos7-s2i-nodejs:5.12.0" 154 | } 155 | }, 156 | { 157 | "name": "6.10", 158 | "annotations": { 159 | "description": "Build and run NodeJS applications", 160 | "iconClass": "icon-nodejs", 161 | "tags": "builder,nodejs,nodejs-6.10.1", 162 | "supports":"nodejs:6,nodejs:6.10,nodejs", 163 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 164 | }, 165 | "from": { 166 | "kind": "ImageStreamTag", 167 | "name": "6.10.1" 168 | } 169 | }, 170 | { 171 | "name": "6", 172 | "annotations": { 173 | "description": "Build and run NodeJS applications", 174 | "iconClass": "icon-nodejs", 175 | "tags": "builder,nodejs,nodejs-6.10.1", 176 | "supports":"nodejs:6,nodejs:6.10,nodejs", 177 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 178 | }, 179 | "from": { 180 | "kind": "ImageStreamTag", 181 | "name": "6.10.1" 182 | } 183 | }, 184 | { 185 | "name": "6.10.1", 186 | "annotations": { 187 | "description": "Build and run NodeJS applications", 188 | "iconClass": "icon-nodejs", 189 | "tags": "builder,nodejs,nodejs-6.10.1,nodejs-latest", 190 | "supports":"nodejs:6,nodejs:6.10,nodejs", 191 | "version": "6.10.1", 192 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 193 | }, 194 | "from": { 195 | "kind": "DockerImage", 196 | "name": "ryanj/centos7-s2i-nodejs:6.10.1" 197 | } 198 | }, 199 | { 200 | "name": "lts", 201 | "annotations": { 202 | "description": "Build and run NodeJS applications", 203 | "iconClass": "icon-nodejs", 204 | "tags": "builder,nodejs,nodejs-6.10.1,nodejs-lts", 205 | "supports":"nodejs:6,nodejs:6.10,nodejs", 206 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 207 | }, 208 | "from": { 209 | "kind": "ImageStreamTag", 210 | "name": "6.10.1" 211 | } 212 | }, 213 | { 214 | "name": "latest", 215 | "annotations": { 216 | "description": "Build and run NodeJS applications", 217 | "iconClass": "icon-nodejs", 218 | "tags": "builder,nodejs,nodejs-7.7.4", 219 | "supports":"nodejs:7,nodejs:7.7,nodejs", 220 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 221 | }, 222 | "from": { 223 | "kind": "ImageStreamTag", 224 | "name": "7.7.4" 225 | } 226 | }, 227 | { 228 | "name": "current", 229 | "annotations": { 230 | "description": "Build and run NodeJS applications", 231 | "iconClass": "icon-nodejs", 232 | "tags": "builder,nodejs,nodejs-7.7.4,nodejs-current", 233 | "supports":"nodejs:7,nodejs:7.7,nodejs", 234 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 235 | }, 236 | "from": { 237 | "kind": "ImageStreamTag", 238 | "name": "7.7.4" 239 | } 240 | }, 241 | { 242 | "name": "7.7", 243 | "annotations": { 244 | "description": "Build and run NodeJS applications", 245 | "iconClass": "icon-nodejs", 246 | "tags": "builder,nodejs,nodejs-7.7.4", 247 | "supports":"nodejs:7,nodejs:7.7,nodejs", 248 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 249 | }, 250 | "from": { 251 | "kind": "ImageStreamTag", 252 | "name": "7.7.4" 253 | } 254 | }, 255 | { 256 | "name": "7", 257 | "annotations": { 258 | "description": "Build and run NodeJS applications", 259 | "iconClass": "icon-nodejs", 260 | "tags": "builder,nodejs,nodejs-7.7.4", 261 | "supports":"nodejs:7,nodejs:7.7,nodejs", 262 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 263 | }, 264 | "from": { 265 | "kind": "ImageStreamTag", 266 | "name": "7.7.4" 267 | } 268 | }, 269 | { 270 | "name": "current", 271 | "annotations": { 272 | "description": "Build and run NodeJS applications", 273 | "iconClass": "icon-nodejs", 274 | "tags": "builder,nodejs,nodejs-7.7.4,nodejs-current", 275 | "supports":"nodejs:7,nodejs:7.7,nodejs", 276 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 277 | }, 278 | "from": { 279 | "kind": "ImageStreamTag", 280 | "name": "7.7.4" 281 | } 282 | }, 283 | { 284 | "name": "7.7.4", 285 | "annotations": { 286 | "description": "Build and run NodeJS applications", 287 | "iconClass": "icon-nodejs", 288 | "tags": "builder,nodejs,nodejs-7.7.4,nodejs-latest", 289 | "supports":"nodejs:7,nodejs:7.7,nodejs", 290 | "version": "7.7.4", 291 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 292 | }, 293 | "from": { 294 | "kind": "DockerImage", 295 | "name": "ryanj/centos7-s2i-nodejs:7.7.4" 296 | } 297 | } 298 | ] 299 | } 300 | } 301 | ] 302 | } 303 | -------------------------------------------------------------------------------- /nodejs.org/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openshift/base-centos7 2 | 3 | # This image provides a Node.JS environment you can use to run your Node.JS 4 | # applications. 5 | 6 | MAINTAINER RyanJ 7 | 8 | EXPOSE 8080 9 | 10 | # This image will be initialized with "npm run $NPM_RUN" 11 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 12 | # file for possible values of NPM_RUN 13 | ENV NPM_RUN=start \ 14 | NODE_VERSION=7.7.4 \ 15 | NPM_CONFIG_LOGLEVEL=info \ 16 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 17 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ 18 | NPM_VERSION=3 \ 19 | DEBUG_PORT=5858 \ 20 | NODE_ENV=production \ 21 | DEV_MODE=false 22 | 23 | LABEL io.k8s.description="Platform for building and running Node.js applications" \ 24 | io.k8s.display-name="Node.js v$NODE_VERSION" \ 25 | io.openshift.expose-services="8080:http" \ 26 | io.openshift.tags="builder,nodejs,nodejs$NODE_VERSION" \ 27 | com.redhat.deployments-dir="/opt/app-root/src" 28 | 29 | # Download and install a binary from nodejs.org 30 | # Add the gpg keys listed at https://github.com/nodejs/node 31 | RUN set -ex && \ 32 | for key in \ 33 | 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ 34 | FD3A5288F042B6850C66B31F09FE44734EB7990E \ 35 | 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ 36 | DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ 37 | C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ 38 | B9AE9905FFD7803F25714661B63B535A4C206CA9 \ 39 | 56730D5401028683275BD23C23EFEFE93C4CFFFE \ 40 | ; do \ 41 | gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ 42 | done && \ 43 | INSTALL_PKGS="bzip2 nss_wrapper" && \ 44 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 45 | rpm -V $INSTALL_PKGS && \ 46 | yum clean all -y && \ 47 | curl -o node-v${NODE_VERSION}-linux-x64.tar.gz -sSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz && \ 48 | curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt.asc && \ 49 | gpg --batch -d SHASUMS256.txt.asc | grep " node-v${NODE_VERSION}-linux-x64.tar.gz\$" | sha256sum -c - && \ 50 | tar -zxf node-v${NODE_VERSION}-linux-x64.tar.gz -C /usr/local --strip-components=1 && \ 51 | npm install -g npm@${NPM_VERSION} && \ 52 | find /usr/local/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf; \ 53 | rm -rf ~/node-v${NODE_VERSION}-linux-x64.tar.gz ~/SHASUMS256.txt.asc /tmp/node-v${NODE_VERSION} ~/.npm ~/.node-gyp ~/.gnupg \ 54 | /usr/share/man /tmp/* /usr/local/lib/node_modules/npm/man /usr/local/lib/node_modules/npm/doc /usr/local/lib/node_modules/npm/html 55 | 56 | # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH 57 | COPY ./s2i/bin/ $STI_SCRIPTS_PATH 58 | 59 | # Each language image can have 'contrib' a directory with extra files needed to 60 | # run and build the applications. 61 | COPY ./contrib/ /opt/app-root 62 | 63 | # Drop the root user and make the content of /opt/app-root owned by user 1001 64 | RUN chown -R 1001:0 /opt/app-root 65 | USER 1001 66 | 67 | # Set the default CMD to print the usage of the language image 68 | CMD $STI_SCRIPTS_PATH/usage 69 | -------------------------------------------------------------------------------- /nodejs.org/Dockerfile.onbuild: -------------------------------------------------------------------------------- 1 | FROM openshift/base-centos7 2 | 3 | # This image provides a Node.JS environment you can use to run your Node.JS 4 | # applications. 5 | 6 | MAINTAINER RyanJ 7 | 8 | EXPOSE 8080 9 | 10 | # This image will be initialized with "npm run $NPM_RUN" 11 | # See https://docs.npmjs.com/misc/scripts, and your repo's package.json 12 | # file for possible values of NPM_RUN 13 | ENV NPM_RUN=start \ 14 | NODE_VERSION=7.7.4 \ 15 | NPM_CONFIG_LOGLEVEL=info \ 16 | NPM_CONFIG_PREFIX=$HOME/.npm-global \ 17 | PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ 18 | NPM_VERSION=3 \ 19 | DEBUG_PORT=5858 \ 20 | NODE_ENV=production \ 21 | DEV_MODE=false 22 | 23 | LABEL io.k8s.description="Platform for building and running Node.js applications" \ 24 | io.k8s.display-name="Node.js v$NODE_VERSION" \ 25 | io.openshift.expose-services="8080:http" \ 26 | io.openshift.tags="builder,nodejs,nodejs$NODE_VERSION" \ 27 | com.redhat.deployments-dir="/opt/app-root/src" 28 | 29 | # Download and install a binary from nodejs.org 30 | # Add the gpg keys listed at https://github.com/nodejs/node 31 | RUN set -ex && \ 32 | for key in \ 33 | 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ 34 | FD3A5288F042B6850C66B31F09FE44734EB7990E \ 35 | 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ 36 | DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ 37 | C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ 38 | B9AE9905FFD7803F25714661B63B535A4C206CA9 \ 39 | 56730D5401028683275BD23C23EFEFE93C4CFFFE \ 40 | ; do \ 41 | gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ 42 | done && \ 43 | INSTALL_PKGS="bzip2 nss_wrapper" && \ 44 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 45 | rpm -V $INSTALL_PKGS && \ 46 | yum clean all -y && \ 47 | curl -o node-v${NODE_VERSION}-linux-x64.tar.gz -sSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz && \ 48 | curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt.asc && \ 49 | gpg --batch -d SHASUMS256.txt.asc | grep " node-v${NODE_VERSION}-linux-x64.tar.gz\$" | sha256sum -c - && \ 50 | tar -zxf node-v${NODE_VERSION}-linux-x64.tar.gz -C /usr/local --strip-components=1 && \ 51 | npm install -g npm@${NPM_VERSION} && \ 52 | find /usr/local/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf; \ 53 | rm -rf ~/node-v${NODE_VERSION}-linux-x64.tar.gz ~/SHASUMS256.txt.asc /tmp/node-v${NODE_VERSION} ~/.npm ~/.node-gyp ~/.gnupg \ 54 | /usr/share/man /tmp/* /usr/local/lib/node_modules/npm/man /usr/local/lib/node_modules/npm/doc /usr/local/lib/node_modules/npm/html 55 | 56 | # Each language image can have 'contrib' a directory with extra files needed to 57 | # run and build the applications. 58 | COPY ./contrib/ /opt/app-root 59 | 60 | # Drop the root user and make the content of /opt/app-root owned by user 1001 61 | RUN chown -R 1001:0 /opt/app-root 62 | USER 1001 63 | 64 | ONBUILD COPY package.json /opt/app-root/src 65 | ONBUILD RUN npm install 66 | ONBUILD COPY . /opt/app-root/src 67 | 68 | CMD ["/bin/bash", "-c", "npm run -d $NPM_RUN" ] 69 | -------------------------------------------------------------------------------- /nodejs.org/Dockerfile.sourcebuild: -------------------------------------------------------------------------------- 1 | FROM openshift/base-centos7 2 | 3 | # This image provides a Node.JS environment you can use to run your Node.JS 4 | # applications. 5 | 6 | MAINTAINER RyanJ 7 | 8 | EXPOSE 8080 9 | 10 | # Release version configuration: 11 | # Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts 12 | # available on the CLI without using npm's --global installation mode 13 | ENV NODE_VERSION=6.1.0 \ 14 | NPM_CONFIG_LOGLEVEL=info \ 15 | PATH=$HOME/node_modules/.bin/:$PATH \ 16 | NPM_VERSION=3 \ 17 | NPM_RUN=start \ 18 | DEBUG_PORT=5858 \ 19 | NODE_ENV=production \ 20 | DEV_MODE=false 21 | 22 | LABEL io.k8s.description="Platform for building and running Node.js applications" \ 23 | io.k8s.display-name="Node.js v$NODE_VERSION" \ 24 | io.openshift.expose-services="8080:http" \ 25 | io.openshift.tags="builder,nodejs,nodejs$NODE_VERSION" \ 26 | com.redhat.dev-mode="DEV_MODE:false" \ 27 | com.redhat.deployments-dir="/opt/app-root/src" \ 28 | com.redhat.dev-mode.port="DEBUG_PORT:5858" 29 | 30 | # Download and install a binary from nodejs.org 31 | # Add the gpg keys listed at https://github.com/nodejs/node 32 | RUN set -ex && \ 33 | for key in \ 34 | 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ 35 | FD3A5288F042B6850C66B31F09FE44734EB7990E \ 36 | 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ 37 | DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ 38 | C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ 39 | B9AE9905FFD7803F25714661B63B535A4C206CA9 \ 40 | 56730D5401028683275BD23C23EFEFE93C4CFFFE \ 41 | ; do \ 42 | gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ 43 | done && \ 44 | INSTALL_PKGS="bzip2 nss_wrapper" && \ 45 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 46 | rpm -V $INSTALL_PKGS && \ 47 | yum clean all -y && \ 48 | curl -o node-v${NODE_VERSION}.tar.gz -sSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.tar.gz && \ 49 | curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt.asc && \ 50 | gpg --batch -d SHASUMS256.txt.asc | grep " node-v${NODE_VERSION}.tar.gz\$" | sha256sum -c - && \ 51 | tar -zxf node-v${NODE_VERSION}.tar.gz -C /tmp && \ 52 | cd /tmp/node-v${NODE_VERSION} && \ 53 | ./configure --prefix=/usr/local && \ 54 | make -j$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ 55 | make install && \ 56 | npm install -g npm@${NPM_VERSION} nodemon && \ 57 | find /usr/local/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf; \ 58 | rm -rf ~/node-v${NODE_VERSION}.tar.gz ~/SHASUMS256.txt.asc /tmp/node-v${NODE_VERSION} ~/.npm ~/.node-gyp ~/.gnupg \ 59 | /usr/share/man /tmp/* /usr/local/lib/node_modules/npm/man /usr/local/lib/node_modules/npm/doc /usr/local/lib/node_modules/npm/html 60 | 61 | # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH 62 | COPY ./s2i/bin/ $STI_SCRIPTS_PATH 63 | 64 | # Each language image can have 'contrib' a directory with extra files needed to 65 | # run and build the applications. 66 | COPY ./contrib/ /opt/app-root 67 | 68 | # Drop the root user and make the content of /opt/app-root owned by user 1001 69 | RUN chown -R 1001:0 /opt/app-root 70 | USER 1001 71 | 72 | # Set the default CMD to print the usage of the language image 73 | CMD $STI_SCRIPTS_PATH/usage 74 | -------------------------------------------------------------------------------- /nodejs.org/README.md: -------------------------------------------------------------------------------- 1 | NodeJS Builder image 2 | =================== 3 | 4 | This repository contains the source for building various versions of 5 | the Node.JS application as a reproducible Docker image using 6 | [source-to-image](https://github.com/openshift/source-to-image). 7 | 8 | CentOS based builder images with Nodejs binaries from nodejs.org. 9 | The resulting image can be run using [Docker](http://docker.io). 10 | 11 | If you are interested in using SCL-based nodejs binaries, try [sti-nodejs](https://github.com/openshift/sti-nodejs) 12 | 13 | Usage 14 | --------------------- 15 | To build a simple [nodejs example app](https://github.com/ryanj/pillar-base) application using standalone [STI](https://github.com/openshift/source-to-image): 16 | 17 | ``` 18 | $ s2i build https://github.com/ryanj/pillar-base ryanj/centos7-s2i-nodejs:current pillarjs 19 | ``` 20 | 21 | Run the resulting image with [Docker](http://docker.io): 22 | 23 | ``` 24 | $ docker run -p 8080:8080 pillarjs 25 | ``` 26 | 27 | Access the application: 28 | ``` 29 | $ curl 127.0.0.1:8080 30 | ``` 31 | 32 | Repository organization 33 | ------------------------ 34 | * **`nodejs.org`** 35 | 36 | * **Dockerfile** 37 | 38 | CentOS based Dockerfile with 64bit nodejs binaries from nodejs.org. 39 | 40 | * **Dockerfile.sourcebuild** 41 | 42 | CentOS based Dockerfile, nodejs binaries built from source (downloaded from nodejs.org). 43 | 44 | * **`s2i/bin/`** 45 | 46 | This folder contains scripts that are run by [STI](https://github.com/openshift/source-to-image): 47 | 48 | * **assemble** 49 | 50 | Used to install the sources into the location where the application 51 | will be run and prepare the application for deployment (eg. installing 52 | modules using npm, etc.) 53 | 54 | * **run** 55 | 56 | This script is responsible for running the application, by using the 57 | application web server. 58 | 59 | * **usage*** 60 | 61 | This script prints the usage of this image. 62 | 63 | * **`contrib/`** 64 | 65 | This folder contains a file with commonly used modules. 66 | 67 | * **`test/`** 68 | 69 | This folder contains the [S2I](https://github.com/openshift/source-to-image) 70 | test framework with simple Node.JS echo server. 71 | 72 | * **`test-app/`** 73 | 74 | A simple Node.JS echo server used for testing purposes by the [S2I](https://github.com/openshift/source-to-image) test framework. 75 | 76 | * **run** 77 | 78 | This script runs the [S2I](https://github.com/openshift/source-to-image) test framework. 79 | 80 | Environment variables 81 | --------------------- 82 | 83 | Application developers can use the following environment variables to configure the runtime behavior of this image: 84 | 85 | NAME | Description 86 | ------------|------------- 87 | NPM_RUN | Select an alternate / custom runtime mode, defined in your `package.json` file's [`scripts`](https://docs.npmjs.com/misc/scripts) section (default: npm run "start") 88 | NODE_ENV | NodeJS runtime mode (default: "production") 89 | HTTP_PROXY | use an npm proxy during assembly 90 | HTTPS_PROXY | use an npm proxy during assembly 91 | 92 | One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file. 93 | 94 | Example: DATABASE_USER=sampleUser 95 | 96 | #### NOTE: Define your own "`DEV_MODE`": 97 | 98 | The following `package.json` example includes a `scripts.dev` entry. You can define your own custom [`NPM_RUN`](https://docs.npmjs.com/cli/run-script) scripts in your application's `package.json` file. 99 | 100 | ### Using Docker's exec 101 | 102 | To change your source code in a running container, use Docker's [exec](http://docker.io) command: 103 | ``` 104 | $ docker exec -it /bin/bash 105 | ``` 106 | 107 | After you [Docker exec](http://docker.io) into the running container, your current directory is set to `/opt/app-root/src`, where the source code for your application is located. 108 | 109 | ### Using OpenShift's rsync 110 | 111 | If you have deployed the container to OpenShift, you can use [oc rsync](https://docs.openshift.org/latest/dev_guide/copy_files_to_container.html) to copy local files to a remote container running in an OpenShift pod. 112 | -------------------------------------------------------------------------------- /nodejs.org/contrib/etc/generate_container_user: -------------------------------------------------------------------------------- 1 | # Set current user in nss_wrapper 2 | USER_ID=$(id -u) 3 | GROUP_ID=$(id -g) 4 | 5 | if [ x"$USER_ID" != x"0" -a x"$USER_ID" != x"1001" ]; then 6 | 7 | NSS_WRAPPER_PASSWD=/opt/app-root/etc/passwd 8 | NSS_WRAPPER_GROUP=/etc/group 9 | 10 | cat /etc/passwd | sed -e 's/^default:/builder:/' > $NSS_WRAPPER_PASSWD 11 | 12 | echo "default:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/sbin/nologin" >> $NSS_WRAPPER_PASSWD 13 | 14 | export NSS_WRAPPER_PASSWD 15 | export NSS_WRAPPER_GROUP 16 | export LD_PRELOAD=libnss_wrapper.so 17 | fi 18 | -------------------------------------------------------------------------------- /nodejs.org/contrib/etc/npm_global_module_list: -------------------------------------------------------------------------------- 1 | async 2 | mime 3 | mkdirp 4 | qs 5 | minimatch 6 | -------------------------------------------------------------------------------- /nodejs.org/s2i/bin/assemble: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Prevent running assemble in builders different than official STI image. 4 | # The official nodejs:0.10-onbuild already run npm install and use different 5 | # application folder. 6 | [ -d "/usr/src/app" ] && exit 0 7 | 8 | set -e 9 | 10 | # FIXME: Linking of global modules is disabled for now as it causes npm failures 11 | # under RHEL7 12 | # Global modules good to have 13 | # npmgl=$(grep "^\s*[^#\s]" ../etc/npm_global_module_list | sort -u) 14 | # Available global modules; only match top-level npm packages 15 | #global_modules=$(npm ls -g 2> /dev/null | perl -ne 'print "$1\n" if /^\S+\s(\S+)\@[\d\.-]+/' | sort -u) 16 | # List all modules in common 17 | #module_list=$(/usr/bin/comm -12 <(echo "${global_modules}") | tr '\n' ' ') 18 | # Link the modules 19 | #npm link $module_list 20 | 21 | shopt -s dotglob 22 | echo "---> Installing application source" 23 | mv /tmp/src/* ./ 24 | 25 | if [ ! -z $HTTP_PROXY ]; then 26 | echo "---> Setting npm http proxy to $HTTP_PROXY" 27 | npm config set proxy $HTTP_PROXY 28 | fi 29 | 30 | if [ ! -z $http_proxy ]; then 31 | echo "---> Setting npm http proxy to $http_proxy" 32 | npm config set proxy $http_proxy 33 | fi 34 | 35 | if [ ! -z $HTTPS_PROXY ]; then 36 | echo "---> Setting npm https proxy to $HTTPS_PROXY" 37 | npm config set https-proxy $HTTPS_PROXY 38 | fi 39 | 40 | if [ ! -z $https_proxy ]; then 41 | echo "---> Setting npm https proxy to $https_proxy" 42 | npm config set https-proxy $https_proxy 43 | fi 44 | 45 | # Change the npm registry mirror if provided 46 | if [ ! -z "$NPM_MIRROR" ]; then 47 | echo "---> Setting the npm package mirror to $NPM_MIRROR" 48 | npm config set registry $NPM_MIRROR 49 | fi 50 | 51 | echo "---> Building your Node application from source" 52 | npm install -d 53 | 54 | # Fix source directory permissions 55 | fix-permissions ./ 56 | -------------------------------------------------------------------------------- /nodejs.org/s2i/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # nss_wrapper: 6 | if [ -e "/opt/app-root/etc/generate_container_user" ]; then 7 | source /opt/app-root/etc/generate_container_user 8 | fi 9 | 10 | # Runs the nodejs application server. 11 | run_node() { 12 | exec npm run -d $NPM_RUN 13 | } 14 | 15 | # If the official dockerhub node image is used, skip the SCL setup below 16 | # and just run the nodejs server 17 | if [ -d "/usr/src/app" ]; then 18 | run_node 19 | fi 20 | 21 | # Allow users to inspect/debug the builder image itself, by using: 22 | # $ docker run -i -t openshift/centos-nodejs-builder --debug 23 | # 24 | [ "$1" == "--debug" ] && exec /bin/bash 25 | 26 | run_node 27 | -------------------------------------------------------------------------------- /nodejs.org/s2i/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` 4 | 5 | cat </dev/null 26 | } 27 | 28 | container_exists() { 29 | image_exists $(cat $cid_file) 30 | } 31 | 32 | container_ip() { 33 | docker inspect --format="{{ .NetworkSettings.IPAddress }}" $(cat $cid_file) 34 | } 35 | 36 | run_s2i_build() { 37 | s2i build ${s2i_args} file://${test_dir}/test-app ${IMAGE_TAG} ${IMAGE_NAME}-testapp 38 | } 39 | 40 | prepare() { 41 | if ! image_exists ${IMAGE_TAG}; then 42 | echo "ERROR: The image ${IMAGE_TAG} must exist before this script is executed." 43 | exit 1 44 | fi 45 | # TODO: STI build require the application is a valid 'GIT' repository, we 46 | # should remove this restriction in the future when a file:// is used. 47 | pushd ${test_dir}/test-app >/dev/null 48 | git init 49 | git config user.email "build@localhost" && git config user.name "builder" 50 | git add -A && git commit --no-gpg-sign -m "Sample commit" 51 | popd >/dev/null 52 | } 53 | 54 | run_test_application() { 55 | docker run --user=100001 --rm --cidfile=${cid_file} -p ${test_port} ${IMAGE_NAME}-testapp 56 | } 57 | 58 | cleanup() { 59 | if [ -f $cid_file ]; then 60 | if container_exists; then 61 | docker stop $(cat $cid_file) 62 | fi 63 | fi 64 | if image_exists ${IMAGE_NAME}-testapp; then 65 | docker rmi -f ${IMAGE_NAME}-testapp 66 | fi 67 | rm -rf ${test_dir}/test-app/.git 68 | } 69 | 70 | check_result() { 71 | local result="$1" 72 | if [[ "$result" != "0" ]]; then 73 | echo "STI image '${IMAGE_TAG}' test FAILED (exit code: ${result})" 74 | cleanup 75 | exit $result 76 | fi 77 | } 78 | 79 | wait_for_cid() { 80 | local max_attempts=10 81 | local sleep_time=1 82 | local attempt=1 83 | local result=1 84 | while [ $attempt -le $max_attempts ]; do 85 | [ -f $cid_file ] && [ -s $cid_file ] && break 86 | echo "Waiting for container start..." 87 | attempt=$(( $attempt + 1 )) 88 | sleep $sleep_time 89 | done 90 | } 91 | 92 | test_s2i_usage() { 93 | echo "Testing 's2i usage'..." 94 | s2i usage ${s2i_args} ${IMAGE_TAG} &>/dev/null 95 | } 96 | 97 | test_docker_run_usage() { 98 | echo "Testing 'docker run' usage..." 99 | docker run ${IMAGE_TAG} &>/dev/null 100 | } 101 | 102 | test_connection() { 103 | echo "Testing HTTP connection..." 104 | local max_attempts=10 105 | local sleep_time=1 106 | local attempt=1 107 | local result=1 108 | while [ $attempt -le $max_attempts ]; do 109 | echo "Sending GET request to http://$(container_ip):${test_port}/" 110 | response_code=$(curl -s -w %{http_code} -o /dev/null http://$(container_ip):${test_port}/) 111 | status=$? 112 | if [ $status -eq 0 ]; then 113 | if [ $response_code -eq 200 ]; then 114 | result=0 115 | fi 116 | break 117 | fi 118 | attempt=$(( $attempt + 1 )) 119 | sleep $sleep_time 120 | done 121 | return $result 122 | } 123 | 124 | test_scl_usage() { 125 | local run_cmd="$1" 126 | local expected="$2" 127 | 128 | echo "Checking nodejs runtime version ..." 129 | out=$(docker run --rm ${IMAGE_TAG} /bin/bash -c "${run_cmd}") 130 | if ! echo "${out}" | grep -q "${expected}"; then 131 | echo "ERROR[/bin/bash -c "${run_cmd}"] Expected '${expected}', got '${out}'" 132 | return 1 133 | fi 134 | out=$(docker exec $(cat ${cid_file}) /bin/bash -c "${run_cmd}" 2>&1) 135 | if ! echo "${out}" | grep -q "${expected}"; then 136 | echo "ERROR[exec /bin/bash -c "${run_cmd}"] Expected '${expected}', got '${out}'" 137 | return 1 138 | fi 139 | out=$(docker exec $(cat ${cid_file}) /bin/sh -ic "${run_cmd}" 2>&1) 140 | if ! echo "${out}" | grep -q "${expected}"; then 141 | echo "ERROR[exec /bin/sh -ic "${run_cmd}"] Expected '${expected}', got '${out}'" 142 | return 1 143 | fi 144 | } 145 | 146 | # Sets and Gets the NODE_ENV environment variable from the container. 147 | get_set_node_env_from_container() { 148 | local node_env="$1" 149 | 150 | echo $(docker run --rm --env NODE_ENV=$node_env $IMAGE_TAG /bin/bash -c 'echo "$NODE_ENV"') 151 | } 152 | 153 | # Gets the NODE_ENV environment variable from the container. 154 | get_default_node_env_from_container() { 155 | echo $(docker run --rm $IMAGE_TAG /bin/bash -c 'echo "$NODE_ENV"') 156 | } 157 | 158 | test_node_env_and_environment_variables() { 159 | local default_node_env="production" 160 | local node_env_prod="production" 161 | local node_env_dev="development" 162 | echo 'Validating default NODE_ENV, verifying ability to configure using Env Vars...' 163 | 164 | result=0 165 | 166 | if [ "$default_node_env" != $(get_default_node_env_from_container) ]; then 167 | echo "ERROR default NODE_ENV should be '$default_node_env'" 168 | result=1 169 | fi 170 | 171 | if [ "$node_env_prod" != $(get_set_node_env_from_container "$node_env_prod") ]; then 172 | echo "ERROR: NODE_ENV was unsuccessfully set to '$node_env_prod' mode" 173 | result=1 174 | fi 175 | 176 | if [ "$node_env_dev" != $(get_set_node_env_from_container "$node_env_dev") ]; then 177 | echo "ERROR: NODE_ENV unsuccessfully set to '$node_env_dev' mode" 178 | result=1 179 | fi 180 | 181 | return $result 182 | } 183 | 184 | # Build the application image twice to ensure the 'save-artifacts' and 185 | # 'restore-artifacts' scripts are working properly 186 | prepare 187 | run_s2i_build 188 | check_result $? 189 | 190 | # Verify the 'usage' script is working properly when running the base image with 's2i usage ...' 191 | test_s2i_usage 192 | check_result $? 193 | 194 | # Verify the 'usage' script is working properly when running the base image with 'docker run ...' 195 | test_docker_run_usage 196 | check_result $? 197 | 198 | # Verify that the HTTP connection can be established to test application container 199 | run_test_application & 200 | 201 | # Wait for the container to write it's CID file 202 | wait_for_cid 203 | 204 | test_scl_usage "node --version" "v${NODE_VERSION}" 205 | check_result $? 206 | 207 | test_connection 208 | check_result $? 209 | 210 | test_node_env_and_environment_variables 211 | check_result $? 212 | 213 | echo "Success!" 214 | cleanup 215 | -------------------------------------------------------------------------------- /nodejs.org/test/test-app/README.md: -------------------------------------------------------------------------------- 1 | node-echo 2 | ========= 3 | 4 | node.js echo server, returns request data to response 5 | -------------------------------------------------------------------------------- /nodejs.org/test/test-app/iisnode.yml: -------------------------------------------------------------------------------- 1 | # For documentation see https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml 2 | 3 | # loggingEnabled: false 4 | # debuggingEnabled: false 5 | # devErrorsEnabled: false 6 | node_env: production 7 | # nodeProcessCountPerApplication: 1 8 | # maxConcurrentRequestsPerProcess: 1024 9 | # maxNamedPipeConnectionRetry: 24 10 | # namedPipeConnectionRetryDelay: 250 11 | # maxNamedPipeConnectionPoolSize: 512 12 | # maxNamedPipePooledConnectionAge: 30000 13 | # asyncCompletionThreadCount: 0 14 | # initialRequestBufferSize: 4096 15 | # maxRequestBufferSize: 65536 16 | watchedFiles: iisnode.yml;node_modules\*;*.js 17 | # uncFileChangesPollingInterval: 5000 18 | # gracefulShutdownTimeout: 60000 19 | # logDirectoryNameSuffix: logs 20 | # debuggerPortRange: 5058-6058 21 | # debuggerPathSegment: debug 22 | # maxLogFileSizeInKB: 128 23 | # appendToExistingLog: false 24 | # logFileFlushInterval: 5000 25 | # flushResponse: false 26 | # enableXFF: false 27 | # promoteServerVars: -------------------------------------------------------------------------------- /nodejs.org/test/test-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-echo", 3 | "version": "0.0.1", 4 | "description": "node-echo", 5 | "main": "server.js", 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "nodemon": "*" 10 | }, 11 | "engine": { 12 | "node": "*", 13 | "npm": "*" 14 | }, 15 | "scripts": { 16 | "dev": "nodemon --ignore node_modules/ server.js", 17 | "start": "node server.js" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "http://github.com/bettiolo/node-echo.git" 22 | }, 23 | "keywords": [ 24 | "Echo" 25 | ], 26 | "author": "Marco Bettiolo ", 27 | "license": "", 28 | "bugs": { 29 | "url": "http://github.com/bettiolo/node-echo/issues" 30 | }, 31 | "homepage": "http://apilb.com" 32 | } 33 | -------------------------------------------------------------------------------- /nodejs.org/test/test-app/server.js: -------------------------------------------------------------------------------- 1 | var util = require('util'); 2 | var http = require('http'); 3 | var url = require('url'); 4 | var qs = require('querystring'); 5 | var os = require('os') 6 | var port = process.env.PORT || process.env.port || process.env.OPENSHIFT_NODEJS_PORT || 8080; 7 | var ip = process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; 8 | var nodeEnv = process.env.NODE_ENV || 'unknown'; 9 | var server = http.createServer(function (req, res) { 10 | var url_parts = url.parse(req.url, true); 11 | 12 | var body = ''; 13 | req.on('data', function (data) { 14 | body += data; 15 | }); 16 | req.on('end', function () { 17 | var formattedBody = qs.parse(body); 18 | 19 | res.writeHead(200, {'Content-Type': 'text/plain'}); 20 | 21 | res.write('This is a node.js echo service\n'); 22 | res.write('Host: ' + req.headers.host + '\n'); 23 | res.write('\n'); 24 | res.write('node.js Production Mode: ' + (nodeEnv == 'production' ? 'yes' : 'no') + '\n'); 25 | res.write('\n'); 26 | res.write('HTTP/' + req.httpVersion +'\n'); 27 | res.write('Request headers:\n'); 28 | res.write(util.inspect(req.headers, null) + '\n'); 29 | res.write('Request query:\n'); 30 | res.write(util.inspect(url_parts.query, null) + '\n'); 31 | res.write('Request body:\n'); 32 | res.write(util.inspect(formattedBody, null) + '\n'); 33 | res.write('\n'); 34 | res.write('Host: ' + os.hostname() + '\n'); 35 | res.write('OS Type: ' + os.type() + '\n'); 36 | res.write('OS Platform: ' + os.platform() + '\n'); 37 | res.write('OS Arch: ' + os.arch() + '\n'); 38 | res.write('OS Release: ' + os.release() + '\n'); 39 | res.write('OS Uptime: ' + os.uptime() + '\n'); 40 | res.write('OS Free memory: ' + os.freemem() / 1024 / 1024 + 'mb\n'); 41 | res.write('OS Total memory: ' + os.totalmem() / 1024 / 1024 + 'mb\n'); 42 | res.write('OS CPU count: ' + os.cpus().length + '\n'); 43 | res.write('OS CPU model: ' + os.cpus()[0].model + '\n'); 44 | res.write('OS CPU speed: ' + os.cpus()[0].speed + 'mhz\n'); 45 | res.end('\n'); 46 | 47 | }); 48 | }); 49 | server.listen(port); 50 | console.log('Server running on ' + ip + ':' + port); 51 | -------------------------------------------------------------------------------- /nodejs.org/test/test-app/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "centos7-nodejs", 3 | "homepage": "https://github.com/ryanj/origin-s2i-nodejs", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/ryanj/origin-s2i-nodejs.git" 7 | }, 8 | "version": "0.0.2", 9 | "description": "NodeJS images for OpenShift / Kubernetes, based on CentOS", 10 | "dependencies": { 11 | "request": "^2.72.0", 12 | "semver": "^5.1.0" 13 | }, 14 | "devDependencies": { 15 | "tap": "^5.7.0" 16 | }, 17 | "keywords": [ 18 | "openshift", 19 | "aws", 20 | "docker", 21 | "ansible" 22 | ], 23 | "author": "ryanj", 24 | "scripts": { 25 | "start": "make all", 26 | "rebuild": "hack/rebuild.sh", 27 | "tag": "hack/tag.sh", 28 | "pub": "hack/publish.sh", 29 | "build": "make", 30 | "test": "make test", 31 | "clean": "docker rmi -f $(docker images |tr -s ' ' | grep -e 'centos7-s2i-nodejs\\|centos7-s2i-nodejs-candidate\\|centos7-nodejs' | cut -d' ' -s -f3)" 32 | }, 33 | "license": "MIT", 34 | "bugs": { 35 | "url": "https://github.com/2015-Middleware-Keynote/demo-ansible/issues" 36 | } 37 | } 38 | --------------------------------------------------------------------------------