├── 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.7.3 5.12.0 6.9.5 7.5.0 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 | [![image layers](https://imagelayers.io/badge/ryanj/centos7-s2i-nodejs.svg)](https://imagelayers.io/?images=ryanj%2Fcentos7-s2i-nodejs:current,ryanj%2Fcentos7-s2i-nodejs:lts,ryanj%2Fcentos7-s2i-nodejs:0.12,ryanj%2Fcentos7-s2i-nodejs:0.10) 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.5.0` `current` 20 | * `6.9.5` `lts` 21 | * `5.12.0` 22 | * `4.7.3` 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` relase 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=6.9.5 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.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.7.3", 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.7.3" 83 | } 84 | }, 85 | { 86 | "name": "4.4", 87 | "annotations": { 88 | "description": "Build and run NodeJS applications", 89 | "iconClass": "icon-nodejs", 90 | "tags": "builder,nodejs,nodejs-4.7.3", 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.7.3" 97 | } 98 | }, 99 | { 100 | "name": "4.7.3", 101 | "annotations": { 102 | "description": "Build and run NodeJS applications", 103 | "iconClass": "icon-nodejs", 104 | "tags": "builder,nodejs,nodejs-4.7.3", 105 | "supports":"nodejs:4,nodejs:4.4,nodejs", 106 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 107 | }, 108 | "from": { 109 | "kind": "DockerImage", 110 | "name": "ryanj/centos7-s2i-nodejs:4.7.3" 111 | } 112 | }, 113 | { 114 | "name": "5", 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.12.0", 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 | "version": "5.12.0", 135 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 136 | }, 137 | "from": { 138 | "kind": "DockerImage", 139 | "name": "ryanj/centos7-s2i-nodejs:5.12.0" 140 | } 141 | }, 142 | { 143 | "name": "6", 144 | "annotations": { 145 | "description": "Build and run NodeJS applications", 146 | "iconClass": "icon-nodejs", 147 | "tags": "builder,nodejs,nodejs-6.9.5", 148 | "supports":"nodejs:6,nodejs:6.9,nodejs", 149 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 150 | }, 151 | "from": { 152 | "kind": "ImageStreamTag", 153 | "name": "6.9.5" 154 | } 155 | }, 156 | { 157 | "name": "6.9", 158 | "annotations": { 159 | "description": "Build and run NodeJS applications", 160 | "iconClass": "icon-nodejs", 161 | "tags": "builder,nodejs,nodejs-6.9.5", 162 | "supports":"nodejs:6,nodejs:6.9,nodejs", 163 | "version": "6.9.5", 164 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 165 | }, 166 | "from": { 167 | "kind": "ImageStreamTag", 168 | "name": "6.9.5" 169 | } 170 | }, 171 | { 172 | "name": "6.9.5", 173 | "annotations": { 174 | "description": "Build and run NodeJS applications", 175 | "iconClass": "icon-nodejs", 176 | "tags": "builder,nodejs,nodejs-6.9.5", 177 | "supports":"nodejs:6,nodejs:6.9,nodejs", 178 | "version": "6.9.5", 179 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 180 | }, 181 | "from": { 182 | "kind": "DockerImage", 183 | "name": "ryanj/centos7-s2i-nodejs:6.9.5" 184 | } 185 | }, 186 | { 187 | "name": "7", 188 | "annotations": { 189 | "description": "Build and run NodeJS applications", 190 | "iconClass": "icon-nodejs", 191 | "tags": "builder,nodejs,nodejs-7.5.0", 192 | "supports":"nodejs:7,nodejs:7.5,nodejs", 193 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 194 | }, 195 | "from": { 196 | "kind": "ImageStreamTag", 197 | "name": "7.5.0" 198 | } 199 | }, 200 | { 201 | "name": "7.5", 202 | "annotations": { 203 | "description": "Build and run NodeJS applications", 204 | "iconClass": "icon-nodejs", 205 | "tags": "builder,nodejs,nodejs-7.5.0,nodejs-latest", 206 | "supports":"nodejs:7,nodejs:7.5,nodejs", 207 | "version": "7.5.0", 208 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 209 | }, 210 | "from": { 211 | "kind": "ImageStreamTag", 212 | "name": "7.5.0" 213 | } 214 | }, 215 | { 216 | "name": "7.5.0", 217 | "annotations": { 218 | "description": "Build and run NodeJS applications", 219 | "iconClass": "icon-nodejs", 220 | "tags": "builder,nodejs,nodejs-7.5.0,nodejs-latest", 221 | "supports":"nodejs:7,nodejs:7.5,nodejs", 222 | "version": "7.5.0", 223 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 224 | }, 225 | "from": { 226 | "kind": "DockerImage", 227 | "name": "ryanj/centos7-s2i-nodejs:7.5.0" 228 | } 229 | }, 230 | { 231 | "name": "lts", 232 | "annotations": { 233 | "description": "Build and run NodeJS applications", 234 | "iconClass": "icon-nodejs", 235 | "tags": "builder,nodejs,nodejs-6.9.5,nodejs-lts", 236 | "supports":"nodejs:6,nodejs:6.9,nodejs", 237 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 238 | }, 239 | "from": { 240 | "kind": "ImageStreamTag", 241 | "name": "6.9.5" 242 | } 243 | }, 244 | { 245 | "name": "latest", 246 | "annotations": { 247 | "openshift.io/display-name": "NodeJS (Latest)", 248 | "description": "Build and run NodeJS applications on CentOS 7", 249 | "iconClass": "icon-nodejs", 250 | "tags": "builder,nodejs", 251 | "supports": "nodejs", 252 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 253 | }, 254 | "from": { 255 | "kind": "ImageStreamTag", 256 | "name": "7.5.0" 257 | } 258 | }, 259 | { 260 | "name": "current", 261 | "annotations": { 262 | "openshift.io/display-name": "NodeJS (Latest)", 263 | "description": "Build and run NodeJS applications on CentOS 7", 264 | "iconClass": "icon-nodejs", 265 | "tags": "builder,nodejs", 266 | "supports": "nodejs", 267 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 268 | }, 269 | "from": { 270 | "kind": "ImageStreamTag", 271 | "name": "7.5.0" 272 | } 273 | } 274 | ] 275 | } 276 | } 277 | ] 278 | } 279 | -------------------------------------------------------------------------------- /hack/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # This script is used to build and test 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 [[ ! -z "$ONBUILD" ]]; 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 -i.bak -e "s/NODE_VERSION *= *.*/NODE_VERSION=${version} \\\/" "${DOCKERFILE}.${version}" 29 | echo "LABEL io.origin.builder-version=\"${git_version}\"" >> "${DOCKERFILE}.${version}" 30 | docker build -t ${IMAGE_NAME}:${version} -f "${DOCKERFILE}.${version}" . 31 | rm -f "${DOCKERFILE}.${version}" "${DOCKERFILE}.${version}.bak" 32 | } 33 | 34 | # Specify a VERSION variable to build a specific nodejs.org release 35 | # or specify a list of VERSIONS 36 | versions=${VERSION:-$VERSIONS} 37 | 38 | for version in ${versions}; do 39 | IMAGE_NAME="${NAMESPACE}/${OS}-${BASE_IMAGE_NAME}" 40 | 41 | if [[ ! -z "$TEST_MODE" ]]; then 42 | IMAGE_NAME+="-candidate" 43 | fi 44 | 45 | echo "-> Building ${IMAGE_NAME}:${version} ..." 46 | 47 | pushd "nodejs.org" > /dev/null 48 | if [ "$OS" == "fedora" -o "$OS" == "fedora-candidate" ]; then 49 | docker_build_with_version Dockerfile.fedora 50 | else 51 | docker_build_with_version Dockerfile 52 | fi 53 | 54 | if [[ ! -z "$TEST_MODE" ]]; then 55 | IMAGE_NAME=${IMAGE_NAME} NODE_VERSION=${version} test/run 56 | 57 | if [[ $? -eq 0 ]] && [[ "${TAG_ON_SUCCESS}" == "true" ]]; then 58 | echo "-> Re-tagging ${IMAGE_NAME}:${version} image to ${IMAGE_NAME%"-candidate"}:${version}" 59 | docker tag -f $IMAGE_NAME:$version ${IMAGE_NAME%"-candidate"}:${version} 60 | fi 61 | 62 | if [[ ! -z "${REGISTRY}" ]]; then 63 | echo "-> Tagging image as" ${REGISTRY}/${IMAGE_NAME%"-candidate"} 64 | docker tag -f $IMAGE_NAME ${REGISTRY}/${IMAGE_NAME%"-candidate"} 65 | fi 66 | fi 67 | 68 | popd > /dev/null 69 | done 70 | -------------------------------------------------------------------------------- /hack/common.mk: -------------------------------------------------------------------------------- 1 | build = hack/build.sh 2 | 3 | ifeq ($(TARGET),fedora) 4 | OS := fedora 5 | else 6 | OS := centos7 7 | endif 8 | 9 | script_env = \ 10 | VERSIONS="$(VERSIONS)" \ 11 | OS="$(OS)" \ 12 | NAMESPACE="$(NAMESPACE)" \ 13 | BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" \ 14 | ONBUILD_IMAGE_NAME="$(ONBUILD_IMAGE_NAME)" \ 15 | VERSION="$(VERSION)" 16 | 17 | .PHONY: build 18 | build: 19 | $(script_env) $(build) 20 | 21 | .PHONY: all 22 | all: 23 | make rebuild && make test && make build && make onbuild && make tags && make publish 24 | 25 | .PHONY: onbuild 26 | onbuild: 27 | $(script_env) ONBUILD=true $(build) 28 | 29 | .PHONY: tags 30 | tags: 31 | $(script_env) npm run tag 32 | 33 | .PHONY: publish 34 | publish: 35 | $(script_env) npm run pub 36 | 37 | .PHONY: rebuild 38 | rebuild: 39 | $(script_env) npm run rebuild 40 | 41 | .PHONY: test 42 | test: 43 | $(script_env) TAG_ON_SUCCESS=$(TAG_ON_SUCCESS) TEST_MODE=true $(build) 44 | 45 | .PHONY: clean 46 | clean: 47 | npm run clean 48 | -------------------------------------------------------------------------------- /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 | LATEST_RELEASE="$(./hack/latest.js | cut -f5 -d' ')" 6 | LATEST_RELEASES="$(node ./hack/latest.js)" 7 | NUMS="$(seq 1 `echo $LAST_RELEASES | wc -w`)" 8 | #Files with hard-coded version strings: 9 | LAST_UPDATES_NEEDED="centos7-s2i-nodejs.json \ 10 | image-streams-candidate.json \ 11 | image-streams.json \ 12 | README.md" 13 | LATEST_UPDATES_NEEDED="hack/build.sh \ 14 | nodejs.org/Dockerfile \ 15 | nodejs.org/Dockerfile.onbuild" 16 | 17 | if [ "${LAST_RELEASES}" != "${LATEST_RELEASES}" ] ; then 18 | echo "New NodeJS releases available!: ${LATEST_RELEASES}" 19 | sed -i Makefile -e "s/VERSIONS.*/VERSIONS = $LATEST_RELEASES/" 20 | 21 | for release in $NUMS ; do 22 | last="$( echo ${LAST_RELEASES} | cut -d' ' -f$release )" 23 | latest="$( echo ${LATEST_RELEASES} | cut -d' ' -f$release )" 24 | if [ $last != $latest ] ; then 25 | echo "Updating v$last to v$latest" 26 | for file in $LAST_UPDATES_NEEDED ; do 27 | sed -i $file -e "s/${last}/${latest}/g" 28 | done 29 | fi 30 | done 31 | 32 | if [ "${LAST_RELEASE}" != "${LATEST_RELEASE}" ] ; then 33 | for file in $LATEST_UPDATES_NEEDED ; do 34 | sed -i $file -e "s/${LAST_RELEASE}/${LATEST_RELEASE}/g" 35 | done 36 | fi 37 | 38 | docker pull openshift/base-centos7 39 | 40 | else 41 | echo "No new NodeJS releases found" 42 | fi 43 | -------------------------------------------------------------------------------- /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 | elif [[ $RELEASE == 5.* ]] ; then 19 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:5" 20 | docker tag -f $img $BASE:5 21 | elif [[ $RELEASE == 6.* ]] ; then 22 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:6" 23 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:lts" 24 | docker tag -f $img $BASE:6 25 | docker tag -f $img $BASE:lts 26 | elif [[ $RELEASE == 7.* ]] ; then 27 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:7" 28 | echo "tagging ${BASE}:${RELEASE} for release as: ${BASE}:current" 29 | docker tag -f $img $BASE:7 30 | docker tag -f $img $BASE:current 31 | fi 32 | done 33 | fi 34 | done 35 | -------------------------------------------------------------------------------- /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.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.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.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-candidate: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.7.3", 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.7.3" 83 | } 84 | }, 85 | { 86 | "name": "4.4", 87 | "annotations": { 88 | "description": "Build and run NodeJS applications", 89 | "iconClass": "icon-nodejs", 90 | "tags": "builder,nodejs,nodejs-4.7.3", 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.7.3" 97 | } 98 | }, 99 | { 100 | "name": "4.7.3", 101 | "annotations": { 102 | "description": "Build and run NodeJS applications", 103 | "iconClass": "icon-nodejs", 104 | "tags": "builder,nodejs,nodejs-4.7.3", 105 | "supports":"nodejs:4,nodejs:4.4,nodejs", 106 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 107 | }, 108 | "from": { 109 | "kind": "DockerImage", 110 | "name": "ryanj/centos7-s2i-nodejs-candidate:4.7.3" 111 | } 112 | }, 113 | { 114 | "name": "5", 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.11,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.12.0", 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 | "version": "5.12.0", 135 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 136 | }, 137 | "from": { 138 | "kind": "DockerImage", 139 | "name": "ryanj/centos7-s2i-nodejs-candidate:5.12.0" 140 | } 141 | }, 142 | { 143 | "name": "6", 144 | "annotations": { 145 | "description": "Build and run NodeJS applications", 146 | "iconClass": "icon-nodejs", 147 | "tags": "builder,nodejs,nodejs-6.9.5", 148 | "supports":"nodejs:6,nodejs:6.9,nodejs", 149 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 150 | }, 151 | "from": { 152 | "kind": "ImageStreamTag", 153 | "name": "6.9.5" 154 | } 155 | }, 156 | { 157 | "name": "6.9", 158 | "annotations": { 159 | "description": "Build and run NodeJS applications", 160 | "iconClass": "icon-nodejs", 161 | "tags": "builder,nodejs,nodejs-6.9.5", 162 | "supports":"nodejs:6,nodejs:6.9,nodejs", 163 | "version": "6.9.5", 164 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 165 | }, 166 | "from": { 167 | "kind": "ImageStreamTag", 168 | "name": "6.9.5" 169 | } 170 | }, 171 | { 172 | "name": "6.9.5", 173 | "annotations": { 174 | "description": "Build and run NodeJS applications", 175 | "iconClass": "icon-nodejs", 176 | "tags": "builder,nodejs,nodejs-6.9.5", 177 | "supports":"nodejs:6,nodejs:6.9,nodejs", 178 | "version": "6.9.5", 179 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 180 | }, 181 | "from": { 182 | "kind": "DockerImage", 183 | "name": "ryanj/centos7-s2i-nodejs:6.9.5" 184 | } 185 | }, 186 | { 187 | "name": "7", 188 | "annotations": { 189 | "description": "Build and run NodeJS applications", 190 | "iconClass": "icon-nodejs", 191 | "tags": "builder,nodejs,nodejs-7.5.0", 192 | "supports":"nodejs:7,nodejs:7.5,nodejs", 193 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 194 | }, 195 | "from": { 196 | "kind": "ImageStreamTag", 197 | "name": "7.5.0" 198 | } 199 | }, 200 | { 201 | "name": "7.5", 202 | "annotations": { 203 | "description": "Build and run NodeJS applications", 204 | "iconClass": "icon-nodejs", 205 | "tags": "builder,nodejs,nodejs-7.5.0,nodejs-latest", 206 | "supports":"nodejs:7,nodejs:7.5,nodejs", 207 | "version": "7.5.0", 208 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 209 | }, 210 | "from": { 211 | "kind": "ImageStreamTag", 212 | "name": "7.5.0" 213 | } 214 | }, 215 | { 216 | "name": "7.5.0", 217 | "annotations": { 218 | "description": "Build and run NodeJS applications", 219 | "iconClass": "icon-nodejs", 220 | "tags": "builder,nodejs,nodejs-7.5.0,nodejs-latest", 221 | "supports":"nodejs:7,nodejs:7.5,nodejs", 222 | "version": "7.5.0", 223 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 224 | }, 225 | "from": { 226 | "kind": "DockerImage", 227 | "name": "ryanj/centos7-s2i-nodejs:7.5.0" 228 | } 229 | }, 230 | { 231 | "name": "lts", 232 | "annotations": { 233 | "description": "Build and run NodeJS applications", 234 | "iconClass": "icon-nodejs", 235 | "tags": "builder,nodejs,nodejs-6.9.5,nodejs-lts", 236 | "supports":"nodejs:6,nodejs:6.9,nodejs", 237 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 238 | }, 239 | "from": { 240 | "kind": "ImageStreamTag", 241 | "name": "6.9.5" 242 | } 243 | }, 244 | { 245 | "name": "latest", 246 | "annotations": { 247 | "openshift.io/display-name": "NodeJS (Latest)", 248 | "description": "Build and run NodeJS applications on CentOS 7", 249 | "iconClass": "icon-nodejs", 250 | "tags": "builder,nodejs", 251 | "supports": "nodejs", 252 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 253 | }, 254 | "from": { 255 | "kind": "ImageStreamTag", 256 | "name": "7.5.0" 257 | } 258 | }, 259 | { 260 | "name": "current", 261 | "annotations": { 262 | "openshift.io/display-name": "NodeJS (Latest)", 263 | "description": "Build and run NodeJS applications on CentOS 7", 264 | "iconClass": "icon-nodejs", 265 | "tags": "builder,nodejs", 266 | "supports": "nodejs", 267 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 268 | }, 269 | "from": { 270 | "kind": "ImageStreamTag", 271 | "name": "7.5.0" 272 | } 273 | } 274 | ] 275 | } 276 | } 277 | ] 278 | } 279 | -------------------------------------------------------------------------------- /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.7.3", 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.7.3" 83 | } 84 | }, 85 | { 86 | "name": "4.4", 87 | "annotations": { 88 | "description": "Build and run NodeJS applications", 89 | "iconClass": "icon-nodejs", 90 | "tags": "builder,nodejs,nodejs-4.7.3", 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.7.3" 97 | } 98 | }, 99 | { 100 | "name": "4.7.3", 101 | "annotations": { 102 | "description": "Build and run NodeJS applications", 103 | "iconClass": "icon-nodejs", 104 | "tags": "builder,nodejs,nodejs-4.7.3", 105 | "supports":"nodejs:4,nodejs:4.4,nodejs", 106 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 107 | }, 108 | "from": { 109 | "kind": "DockerImage", 110 | "name": "ryanj/centos7-s2i-nodejs:4.7.3" 111 | } 112 | }, 113 | { 114 | "name": "5", 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.12.0", 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 | "version": "5.12.0", 135 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 136 | }, 137 | "from": { 138 | "kind": "DockerImage", 139 | "name": "ryanj/centos7-s2i-nodejs:5.12.0" 140 | } 141 | }, 142 | { 143 | "name": "6", 144 | "annotations": { 145 | "description": "Build and run NodeJS applications", 146 | "iconClass": "icon-nodejs", 147 | "tags": "builder,nodejs,nodejs-6.9.5", 148 | "supports":"nodejs:6,nodejs:6.9,nodejs", 149 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 150 | }, 151 | "from": { 152 | "kind": "ImageStreamTag", 153 | "name": "6.9.5" 154 | } 155 | }, 156 | { 157 | "name": "6.9", 158 | "annotations": { 159 | "description": "Build and run NodeJS applications", 160 | "iconClass": "icon-nodejs", 161 | "tags": "builder,nodejs,nodejs-6.9.5", 162 | "supports":"nodejs:6,nodejs:6.9,nodejs", 163 | "version": "6.9.5", 164 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 165 | }, 166 | "from": { 167 | "kind": "ImageStreamTag", 168 | "name": "6.9.5" 169 | } 170 | }, 171 | { 172 | "name": "6.9.5", 173 | "annotations": { 174 | "description": "Build and run NodeJS applications", 175 | "iconClass": "icon-nodejs", 176 | "tags": "builder,nodejs,nodejs-6.9.5", 177 | "supports":"nodejs:6,nodejs:6.9,nodejs", 178 | "version": "6.9.5", 179 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 180 | }, 181 | "from": { 182 | "kind": "DockerImage", 183 | "name": "ryanj/centos7-s2i-nodejs:6.9.5" 184 | } 185 | }, 186 | { 187 | "name": "7", 188 | "annotations": { 189 | "description": "Build and run NodeJS applications", 190 | "iconClass": "icon-nodejs", 191 | "tags": "builder,nodejs,nodejs-7.5.0", 192 | "supports":"nodejs:7,nodejs:7.5,nodejs", 193 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 194 | }, 195 | "from": { 196 | "kind": "ImageStreamTag", 197 | "name": "7.5.0" 198 | } 199 | }, 200 | { 201 | "name": "7.5", 202 | "annotations": { 203 | "description": "Build and run NodeJS applications", 204 | "iconClass": "icon-nodejs", 205 | "tags": "builder,nodejs,nodejs-7.5.0,nodejs-latest", 206 | "supports":"nodejs:7,nodejs:7.5,nodejs", 207 | "version": "7.5.0", 208 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 209 | }, 210 | "from": { 211 | "kind": "ImageStreamTag", 212 | "name": "7.5.0" 213 | } 214 | }, 215 | { 216 | "name": "7.5.0", 217 | "annotations": { 218 | "description": "Build and run NodeJS applications", 219 | "iconClass": "icon-nodejs", 220 | "tags": "builder,nodejs,nodejs-7.5.0,nodejs-latest", 221 | "supports":"nodejs:7,nodejs:7.5,nodejs", 222 | "version": "7.5.0", 223 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 224 | }, 225 | "from": { 226 | "kind": "DockerImage", 227 | "name": "ryanj/centos7-s2i-nodejs:7.5.0" 228 | } 229 | }, 230 | { 231 | "name": "lts", 232 | "annotations": { 233 | "description": "Build and run NodeJS applications", 234 | "iconClass": "icon-nodejs", 235 | "tags": "builder,nodejs,nodejs-6.9.5,nodejs-lts", 236 | "supports":"nodejs:6,nodejs:6.9,nodejs", 237 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 238 | }, 239 | "from": { 240 | "kind": "ImageStreamTag", 241 | "name": "6.9.5" 242 | } 243 | }, 244 | { 245 | "name": "latest", 246 | "annotations": { 247 | "openshift.io/display-name": "NodeJS (Latest)", 248 | "description": "Build and run NodeJS applications on CentOS 7", 249 | "iconClass": "icon-nodejs", 250 | "tags": "builder,nodejs", 251 | "supports": "nodejs", 252 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 253 | }, 254 | "from": { 255 | "kind": "ImageStreamTag", 256 | "name": "7.5.0" 257 | } 258 | }, 259 | { 260 | "name": "current", 261 | "annotations": { 262 | "openshift.io/display-name": "NodeJS (Latest)", 263 | "description": "Build and run NodeJS applications on CentOS 7", 264 | "iconClass": "icon-nodejs", 265 | "tags": "builder,nodejs", 266 | "supports": "nodejs", 267 | "sampleRepo": "https://github.com/ryanj/pillar-base.git" 268 | }, 269 | "from": { 270 | "kind": "ImageStreamTag", 271 | "name": "7.5.0" 272 | } 273 | } 274 | ] 275 | } 276 | } 277 | ] 278 | } 279 | -------------------------------------------------------------------------------- /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= \ 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 | 9554F04D7259F04124DE6B476D5A82AC7E37093B \ 34 | 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ 35 | 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \ 36 | FD3A5288F042B6850C66B31F09FE44734EB7990E \ 37 | 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ 38 | DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ 39 | B9AE9905FFD7803F25714661B63B535A4C206CA9 \ 40 | C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ 41 | ; do \ 42 | gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ 43 | done && \ 44 | yum install -y epel-release && \ 45 | INSTALL_PKGS="bzip2 nss_wrapper" && \ 46 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 47 | rpm -V $INSTALL_PKGS && \ 48 | yum clean all -y && \ 49 | 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 && \ 50 | curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt.asc && \ 51 | gpg --batch -d SHASUMS256.txt.asc | grep " node-v${NODE_VERSION}-linux-x64.tar.gz\$" | sha256sum -c - && \ 52 | tar -zxf node-v${NODE_VERSION}-linux-x64.tar.gz -C /usr/local --strip-components=1 && \ 53 | npm install -g npm@${NPM_VERSION} && \ 54 | find /usr/local/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf; \ 55 | rm -rf ~/node-v${NODE_VERSION}-linux-x64.tar.gz ~/SHASUMS256.txt.asc /tmp/node-v${NODE_VERSION} ~/.npm ~/.node-gyp ~/.gnupg \ 56 | /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 57 | 58 | # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH 59 | COPY ./s2i/bin/ $STI_SCRIPTS_PATH 60 | 61 | # Each language image can have 'contrib' a directory with extra files needed to 62 | # run and build the applications. 63 | COPY ./contrib/ /opt/app-root 64 | 65 | # Drop the root user and make the content of /opt/app-root owned by user 1001 66 | RUN chown -R 1001:0 /opt/app-root 67 | USER 1001 68 | 69 | # Set the default CMD to print the usage of the language image 70 | CMD $STI_SCRIPTS_PATH/usage 71 | -------------------------------------------------------------------------------- /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= \ 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 | 9554F04D7259F04124DE6B476D5A82AC7E37093B \ 34 | 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ 35 | 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \ 36 | FD3A5288F042B6850C66B31F09FE44734EB7990E \ 37 | 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ 38 | DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ 39 | B9AE9905FFD7803F25714661B63B535A4C206CA9 \ 40 | C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ 41 | ; do \ 42 | gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ 43 | done && \ 44 | yum install -y epel-release && \ 45 | INSTALL_PKGS="bzip2 nss_wrapper" && \ 46 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 47 | rpm -V $INSTALL_PKGS && \ 48 | yum clean all -y && \ 49 | 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 && \ 50 | curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt.asc && \ 51 | gpg --batch -d SHASUMS256.txt.asc | grep " node-v${NODE_VERSION}-linux-x64.tar.gz\$" | sha256sum -c - && \ 52 | tar -zxf node-v${NODE_VERSION}-linux-x64.tar.gz -C /usr/local --strip-components=1 && \ 53 | npm install -g npm@${NPM_VERSION} && \ 54 | find /usr/local/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf; \ 55 | rm -rf ~/node-v${NODE_VERSION}-linux-x64.tar.gz ~/SHASUMS256.txt.asc /tmp/node-v${NODE_VERSION} ~/.npm ~/.node-gyp ~/.gnupg \ 56 | /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 57 | 58 | # Each language image can have 'contrib' a directory with extra files needed to 59 | # run and build the applications. 60 | COPY ./contrib/ /opt/app-root 61 | 62 | # Drop the root user and make the content of /opt/app-root owned by user 1001 63 | RUN chown -R 1001:0 /opt/app-root 64 | USER 1001 65 | 66 | ONBUILD COPY package.json /opt/app-root/src 67 | ONBUILD RUN npm install 68 | ONBUILD COPY . /opt/app-root/src 69 | 70 | CMD ["/bin/bash", "-c", "npm run -d $NPM_RUN" ] 71 | -------------------------------------------------------------------------------- /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= \ 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 | 9554F04D7259F04124DE6B476D5A82AC7E37093B \ 35 | 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ 36 | 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \ 37 | FD3A5288F042B6850C66B31F09FE44734EB7990E \ 38 | 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ 39 | DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ 40 | B9AE9905FFD7803F25714661B63B535A4C206CA9 \ 41 | C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ 42 | ; do \ 43 | gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ 44 | done && \ 45 | yum install -y epel-release && \ 46 | INSTALL_PKGS="bzip2 nss_wrapper" && \ 47 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 48 | rpm -V $INSTALL_PKGS && \ 49 | yum clean all -y && \ 50 | curl -o node-v${NODE_VERSION}.tar.gz -sSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.tar.gz && \ 51 | curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt.asc && \ 52 | gpg --batch -d SHASUMS256.txt.asc | grep " node-v${NODE_VERSION}.tar.gz\$" | sha256sum -c - && \ 53 | tar -zxf node-v${NODE_VERSION}.tar.gz -C /tmp && \ 54 | cd /tmp/node-v${NODE_VERSION} && \ 55 | ./configure --prefix=/usr/local && \ 56 | make -j$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ 57 | make install && \ 58 | npm install -g npm@${NPM_VERSION} nodemon && \ 59 | find /usr/local/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf; \ 60 | rm -rf ~/node-v${NODE_VERSION}.tar.gz ~/SHASUMS256.txt.asc /tmp/node-v${NODE_VERSION} ~/.npm ~/.node-gyp ~/.gnupg \ 61 | /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 62 | 63 | # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH 64 | COPY ./s2i/bin/ $STI_SCRIPTS_PATH 65 | 66 | # Each language image can have 'contrib' a directory with extra files needed to 67 | # run and build the applications. 68 | COPY ./contrib/ /opt/app-root 69 | 70 | # Drop the root user and make the content of /opt/app-root owned by user 1001 71 | RUN chown -R 1001:0 /opt/app-root 72 | USER 1001 73 | 74 | # Set the default CMD to print the usage of the language image 75 | CMD $STI_SCRIPTS_PATH/usage 76 | -------------------------------------------------------------------------------- /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=/tmp/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 | echo "---> Installing application source" 22 | cp -Rf /tmp/src/. ./ 23 | 24 | if [ ! -z $HTTP_PROXY ]; then 25 | echo "---> Setting npm http proxy to $HTTP_PROXY" 26 | npm config set proxy $HTTP_PROXY 27 | fi 28 | 29 | if [ ! -z $http_proxy ]; then 30 | echo "---> Setting npm http proxy to $http_proxy" 31 | npm config set proxy $http_proxy 32 | fi 33 | 34 | if [ ! -z $HTTPS_PROXY ]; then 35 | echo "---> Setting npm https proxy to $HTTPS_PROXY" 36 | npm config set https-proxy $HTTPS_PROXY 37 | fi 38 | 39 | if [ ! -z $https_proxy ]; then 40 | echo "---> Setting npm https proxy to $https_proxy" 41 | npm config set https-proxy $https_proxy 42 | fi 43 | 44 | # Change the npm registry mirror if provided 45 | if [ ! -z "$NPM_MIRROR" ]; then 46 | echo "---> Setting the npm package mirror to $NPM_MIRROR" 47 | npm config set registry $NPM_MIRROR 48 | fi 49 | 50 | echo "---> Building your Node application from source" 51 | npm install -d 52 | 53 | # Fix source directory permissions 54 | fix-permissions ./ 55 | -------------------------------------------------------------------------------- /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" || READLINK_EXEC="greadlink" 22 | ! type -a "gmktemp" &>"/dev/null" || MKTEMP_EXEC="gmktemp" 23 | fi 24 | 25 | test_project=${1:-test-app} 26 | test_dir="$($READLINK_EXEC -zf $(dirname "${0}"))" 27 | image_dir=$($READLINK_EXEC -zf ${test_dir}/..) 28 | cid_file=$($MKTEMP_EXEC -u --suffix=.cid) 29 | 30 | # Since we built the candidate image locally, we don't want S2I to attempt to pull 31 | # it from Docker hub 32 | s2i_args="--pull-policy=never " 33 | 34 | # Port the image exposes service to be tested 35 | test_port="$(docker inspect --format='{{range $key, $value := .ContainerConfig.ExposedPorts }}{{$key}}{{end}}' ${IMAGE_TAG} | sed 's/\/.*//')" 36 | 37 | image_exists() { 38 | docker inspect $1 &>/dev/null 39 | } 40 | 41 | container_exists() { 42 | image_exists $(cat $cid_file) 43 | } 44 | 45 | container_ip() { 46 | if [ ! -z "$DOCKER_HOST" ] && (echo "$OSTYPE" | grep -qs 'darwin'); then 47 | docker-machine ip 48 | else 49 | echo "localhost" 50 | fi 51 | } 52 | 53 | container_port() { 54 | docker inspect --format='{{(index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort}}' $(cat $cid_file) 55 | } 56 | 57 | run_s2i_build() { 58 | s2i build ${s2i_args} file://${test_dir}/${test_project} ${IMAGE_TAG} ${IMAGE_NAME}-${test_project} 59 | } 60 | 61 | prepare() { 62 | if ! image_exists ${IMAGE_TAG}; then 63 | echo "ERROR: The image ${IMAGE_TAG} must exist before this script is executed." 64 | exit 1 65 | fi 66 | # s2i build requires the application is a valid 'Git' repository 67 | pushd ${test_dir}/${test_project} >/dev/null 68 | git init 69 | git config user.email "build@localhost" && git config user.name "builder" 70 | git add -A && git commit --no-gpg-sign -m "Sample commit" 71 | popd >/dev/null 72 | } 73 | 74 | run_test_application() { 75 | echo "Starting test application" 76 | docker run --rm --user=100001 --cidfile=${cid_file} -p ${test_port} ${IMAGE_NAME}-${test_project} 77 | } 78 | 79 | cleanup() { 80 | if [ -f $cid_file ]; then 81 | if container_exists; then 82 | docker stop $(cat $cid_file) 83 | fi 84 | rm -rf $cid_file 85 | fi 86 | if image_exists ${IMAGE_NAME}-${test_project}; then 87 | echo "Removing image ${IMAGE_NAME}-${test_project}" 88 | docker rmi -f ${IMAGE_NAME}-${test_project} 89 | fi 90 | rm -rf ${test_dir}/${test_project}/.git 91 | } 92 | 93 | check_result() { 94 | local result="$1" 95 | if [[ "$result" != "0" ]]; then 96 | echo "S2I image '${IMAGE_TAG}' test FAILED (exit code: ${result})" 97 | cleanup 98 | exit $result 99 | fi 100 | } 101 | 102 | wait_for_cid() { 103 | local max_attempts=10 104 | local sleep_time=1 105 | local attempt=1 106 | local result=1 107 | while [ $attempt -le $max_attempts ]; do 108 | [ -f $cid_file ] && container_exists && break 109 | echo "Waiting for container to start..." 110 | attempt=$(( $attempt + 1 )) 111 | sleep $sleep_time 112 | done 113 | echo "Waiting for test application start, sleep 5 seconds" 114 | sleep 5 115 | } 116 | 117 | test_s2i_usage() { 118 | echo "Testing 's2i usage'..." 119 | s2i usage ${s2i_args} ${IMAGE_TAG} &>/dev/null 120 | } 121 | 122 | test_docker_run_usage() { 123 | echo "Testing 'docker run' usage..." 124 | docker run --rm ${IMAGE_TAG} &>/dev/null 125 | } 126 | 127 | test_connection() { 128 | echo "Testing HTTP connection..." 129 | local max_attempts=10 130 | local sleep_time=1 131 | local attempt=1 132 | local result=1 133 | 134 | while [ $attempt -le $max_attempts ]; do 135 | echo "Sending GET request($attempt) to http://$(container_ip):$(container_port)/" 136 | response_code=$(curl -s -w %{http_code} -o /dev/null http://$(container_ip):$(container_port)/) 137 | status=$? 138 | if [ $status -eq 0 ]; then 139 | if [ $response_code -eq 200 ]; then 140 | result=0 141 | fi 142 | break 143 | fi 144 | echo "Validating response_code($response_code) == 200" 145 | attempt=$(( $attempt + 1 )) 146 | sleep $sleep_time 147 | done 148 | return $result 149 | } 150 | 151 | test_scl_usage() { 152 | local run_cmd="$1" 153 | local expected="$2" 154 | 155 | echo "Checking nodejs runtime version ..." 156 | out=$(docker run --rm ${IMAGE_TAG} /bin/bash -c "${run_cmd}") 157 | if ! echo "${out}" | grep -q "${expected}"; then 158 | echo "ERROR[/bin/bash -c "${run_cmd}"] Expected '${expected}', got '${out}'" 159 | return 1 160 | fi 161 | out=$(docker exec $(cat ${cid_file}) /bin/bash -c "${run_cmd}" 2>&1) 162 | if ! echo "${out}" | grep -q "${expected}"; then 163 | echo "ERROR[exec /bin/bash -c "${run_cmd}"] Expected '${expected}', got '${out}'" 164 | return 1 165 | fi 166 | out=$(docker exec $(cat ${cid_file}) /bin/sh -ic "${run_cmd}" 2>&1) 167 | if ! echo "${out}" | grep -q "${expected}"; then 168 | echo "ERROR[exec /bin/sh -ic "${run_cmd}"] Expected '${expected}', got '${out}'" 169 | return 1 170 | fi 171 | } 172 | 173 | # Sets and Gets the NODE_ENV environment variable from the container. 174 | get_set_node_env_from_container() { 175 | local node_env="$1" 176 | 177 | echo $(docker run --rm --env NODE_ENV=$node_env $IMAGE_TAG /bin/bash -c 'echo "$NODE_ENV"') 178 | } 179 | 180 | # Gets the NODE_ENV environment variable from the container. 181 | get_default_node_env_from_container() { 182 | echo $(docker run --rm $IMAGE_TAG /bin/bash -c 'echo "$NODE_ENV"') 183 | } 184 | 185 | test_node_env_and_environment_variables() { 186 | local default_node_env="production" 187 | local node_env_prod="production" 188 | local node_env_dev="development" 189 | echo 'Validating default NODE_ENV, verifying ability to configure using Env Vars...' 190 | 191 | result=0 192 | 193 | if [ "$default_node_env" != $(get_default_node_env_from_container) ]; then 194 | echo "ERROR default NODE_ENV should be '$default_node_env'" 195 | result=1 196 | fi 197 | 198 | if [ "$node_env_prod" != $(get_set_node_env_from_container "$node_env_prod") ]; then 199 | echo "ERROR: NODE_ENV was unsuccessfully set to '$node_env_prod' mode" 200 | result=1 201 | fi 202 | 203 | if [ "$node_env_dev" != $(get_set_node_env_from_container "$node_env_dev") ]; then 204 | echo "ERROR: NODE_ENV unsuccessfully set to '$node_env_dev' mode" 205 | result=1 206 | fi 207 | 208 | return $result 209 | } 210 | 211 | # Build the application image twice to ensure the 'save-artifacts' and 212 | # 'restore-artifacts' scripts are working properly 213 | prepare 214 | run_s2i_build 215 | check_result $? 216 | 217 | # Verify the 'usage' script is working properly when running the base image with 's2i usage ...' 218 | test_s2i_usage 219 | check_result $? 220 | 221 | # Verify the 'usage' script is working properly when running the base image with 'docker run ...' 222 | test_docker_run_usage 223 | check_result $? 224 | 225 | # Verify that the HTTP connection can be established to test application container 226 | run_test_application & 227 | 228 | # Wait for the container to write it's CID file 229 | wait_for_cid 230 | 231 | test_scl_usage "node --version" "v${NODE_VERSION}" 232 | check_result $? 233 | 234 | test_connection 235 | check_result $? 236 | 237 | test_node_env_and_environment_variables 238 | check_result $? 239 | 240 | echo "Success!" 241 | cleanup 242 | 243 | check_result $? 244 | echo "All tests finished successfully." 245 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------