All Projects → icflorescu → Openshift Cartridge Nodejs

icflorescu / Openshift Cartridge Nodejs

Licence: isc
Custom cartridge for OpenShift providing the lastest version of Node.js.

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Openshift Cartridge Nodejs

Fabric8
fabric8 is an open source microservices platform based on Docker, Kubernetes and Jenkins
Stars: ✭ 1,783 (+685.46%)
Mutual labels:  openshift
Forecastle
Forecastle is a control panel which dynamically discovers and provides a launchpad to access applications deployed on Kubernetes – [✩Star] if you're using it!
Stars: ✭ 186 (-18.06%)
Mutual labels:  openshift
Kiali
Kiali project, observability for the Istio service mesh
Stars: ✭ 2,687 (+1083.7%)
Mutual labels:  openshift
Openshift Ansible
Install and config an OpenShift 3.x cluster
Stars: ✭ 2,032 (+795.15%)
Mutual labels:  openshift
Enmasse
EnMasse - Self-service messaging on Kubernetes and OpenShift
Stars: ✭ 185 (-18.5%)
Mutual labels:  openshift
K8s Bigip Ctlr
Repository for F5 Container Ingress Services for Kubernetes & OpenShift.
Stars: ✭ 204 (-10.13%)
Mutual labels:  openshift
Gist Reveal
Gist-powered Revealjs slides
Stars: ✭ 138 (-39.21%)
Mutual labels:  openshift
Ansible Service Broker
Ansible Service Broker
Stars: ✭ 224 (-1.32%)
Mutual labels:  openshift
Minishift
Run OpenShift 3.x locally
Stars: ✭ 2,246 (+889.43%)
Mutual labels:  openshift
Containers Quickstarts
Images & templates for deploying software to OpenShift
Stars: ✭ 215 (-5.29%)
Mutual labels:  openshift
Reloader
Reloader is maintained by Stakater. Like it? Please let us know at [email protected]
Stars: ✭ 2,930 (+1190.75%)
Mutual labels:  openshift
S2i Python Container
Python container images based on Red Hat Software Collections and intended for OpenShift and general usage, that provide a platform for building and running Python applications. Users can choose between Red Hat Enterprise Linux, Fedora, and CentOS based images.
Stars: ✭ 178 (-21.59%)
Mutual labels:  openshift
Console
OpenShift Cluster Console UI
Stars: ✭ 203 (-10.57%)
Mutual labels:  openshift
Argocd Operator
A Kubernetes operator for managing Argo CD clusters.
Stars: ✭ 151 (-33.48%)
Mutual labels:  openshift
Helloworld Msa
Main repository with documentation and support files
Stars: ✭ 218 (-3.96%)
Mutual labels:  openshift
Kubernetes Client
Java client for Kubernetes & OpenShift
Stars: ✭ 2,188 (+863.88%)
Mutual labels:  openshift
Strimzi Kafka Operator
Apache Kafka running on Kubernetes
Stars: ✭ 2,833 (+1148.02%)
Mutual labels:  openshift
Azure arc
Automated Azure Arc environments
Stars: ✭ 224 (-1.32%)
Mutual labels:  openshift
Kcli
Management tool for libvirt/aws/gcp/kubevirt/openstack/ovirt/vsphere/packet
Stars: ✭ 219 (-3.52%)
Mutual labels:  openshift
Jkube
Successor of the deprecated Fabric8 Maven Plugin
Stars: ✭ 213 (-6.17%)
Mutual labels:  openshift

Custom Node.js cartridge for OpenShift

nodejs-openshift

This is a custom Node.js cartridge that takes care of auto-updating the Node.js and NPM versions on each build.

Why

Because the standard OpenShift cartridge never gets updated to the latest Node.js version.

When to use

When you need a quick and unsophisticated solution to run your application on the latest Node.js version.

Note: Looking for (co-)maintainers

A lot of people have been using this cartridge since the beginning of 2015. Thank you all for your PRs and moral support.

However, since I'm not using OpenShift in my projects anymore, there's now little reason for me to maintain this repository as well as it probably deserves.

So, if anyone is willing and ready to step up and become a maintainer, please don't hesitate to drop me a line!

How to

The lazy way

Just click here:

Create Node.js app on OpenShift

…or deploy from the OpenShift Hub Quickstart.

Using web console

Go to Choose a type of application in your OpenShift Online account, paste the URL below into "Code Anything" textbox at the bottom of the page, click "Next", then set your public URL and click "Create Application".

https://raw.githubusercontent.com/icflorescu/openshift-cartridge-nodejs/master/metadata/manifest.yml

Using command line

Assuming you have rhc installed (see here), run:

rhc app create appname https://raw.githubusercontent.com/icflorescu/openshift-cartridge-nodejs/master/metadata/manifest.yml

…where appname is the name of your application.

If you want to create the app with your own source code instead of the provided application template, run:

rhc app create appname \
  https://raw.githubusercontent.com/icflorescu/openshift-cartridge-nodejs/master/metadata/manifest.yml \
  --from-code=https://github.com/you/your-repo.git

…where https://github.com/you/your-repo.git is your application repository URL.

Make sure your app has the appropriate start entry in package.json (see note below).

You can also create an app based on multiple cartridges. For instance, assuming you'd want to include this custom MongoDB cartridge as well, run:

rhc app create appname \
  https://raw.githubusercontent.com/icflorescu/openshift-cartridge-nodejs/master/metadata/manifest.yml \
  https://raw.githubusercontent.com/icflorescu/openshift-cartridge-mongodb/master/metadata/manifest.yml

See output of rhc app create --help for information on additional options.

Customizing the Node.js and npm versions

Node.js

By default, the Node.js version is determined by querying semver.io/node/unstable.

A different URL can be specified either via NODE_VERSION_URL environment variable or by setting .openshift/NODE_VERSION_URL marker in your application repository. For instance, you'd get the latest 0.10.x (0.10.41 as of Jan 24, 2015) by putting this in NODE_VERSION_URL variable or .openshift/NODE_VERSION_URL marker:

https://semver.io/node/resolve/0.10

If you're using a non-default Node.js version and you're planning to scale the application across multiple gears, you must use the environment variable (learn here why).

npm

By default, the npm version is determined by running npm view npm version.

A different npm version can be specified either via NPM_VERSION_URL environment variable or by setting .openshift/NPM_VERSION_URL marker in your application repository. For instance, you'd get the latest 2.x (2.14.16 as of Jan 24, 2016) by putting this in NPM_VERSION_URL variable or .openshift/NPM_VERSION_URL marker:

https://semver.io/npm/resolve/2

Features

  • The cartridge build script is using this function to check for the latest Node.js and npm versions and installs them if necessary;
  • This cartridge can be scaled;
  • This cartridge does not (yet?) have a hot-deploy strategy.

Notes

  • Can't guarantee this cartridge is production-ready. Some people use it though (on their own responsibility).
  • This is a lean cartridge. No unnecessary modules are installed. Which means that unlike the standard Node.js cartridge – it won't install supervisor for you. You'll have to implement your own logic to auto-restart on errors. The provided application template is using cluster for that.
  • The cartridge emulates the execution of npm start to start your application, so make sure your application entrypoint is defined in your start script of your package.json file. See package.json in the provided template or read the npm docs for more information. See a discussion here to learn why the cartridge is emulating npm start instead of actually running it.
  • The cartridge also emulates the execution of npm stop if the script is found in your package.json file. Otherwise, a SIGTERM is sent to the running process using kill.
  • Due to OpenShift's outdated gcc (4.4.7 as of Jan 4 2016), native modules (such as pg-native) won't compile on recent Node.js versions. They'll only work on Node.js 0.10 and 0.12. See this issue for more info.
  • Upon cartridge initialization, the Node.js binary package is downloaded and installed, which may take a while, depending on OpenShift server and network load. 2 - 3 minutes is quite often, but 5 - 10 minutes is not uncommon, especially for scalable multi-gear setups (if you specified "Scale with web traffic").
  • The cartridge automatically installs the npm dependencies as needed on each build/deploy event; devDependencies are not installed (see an in-depth discussion here).

FAQ

Q: I'm getting the error Cannot download, must be smaller than 20480 bytes while trying to deploy the cartridge to OpenShift. What am I doing wrong?

A: You're probably trying to use the URL https://github.com/icflorescu/openshift-cartridge-nodejs instead of https://raw.githubusercontent.com/icflorescu/openshift-cartridge-nodejs/master/metadata/manifest.yml. A common mistake for people not paying sufficient attention while trying to use a custom cartridge for the first time.


Q: The latest Node.js version is 5.3.0, but the cartridge installs 5.1.1. Isn't it supposed to install the latest?

A: By default, the Node.js version is determined by querying semver.io/node/unstable (see the top of this README). For reasons which escape me, semver.io is not updating instantly the latest version, but you can force the cartridge to install it by putting, for instance, https://semver.io/node/resolve/5.3.x in NODE_VERSION_URL environment variable or .openshift/NODE_VERSION_URL file.


Q: How do I disable the auto-update feature? I want to lock my application to specific Node.js and npm versions.

A: Just set the necessary environment variables or markers to the versions you need. For instance, you can lock your application to Node.js 4.3.2 and npm 3.6.0 by setting:

NODE_VERSION_URL=https://semver.io/node/resolve/4.3.2
NPM_VERSION_URL=https://semver.io/npm/resolve/3.6.0

Q: Sometimes, git push fails with:

remote: CLIENT_MESSAGE: Stopping Node.js application...
remote: CLIENT_RESULT: Warning! Could not stop Node.js application!
remote: An error occurred executing 'gear prereceive' (exit code: 1)
remote: Error message: CLIENT_ERROR: Failed to execute: 'control stop' for /var/lib/openshift/[...]/nodejs
remote:
remote: For more details about the problem, try running the command again with the '--trace' option.
To ssh://[...].git/
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://[...].git/'

What's wrong?

A: Your application may take longer than 60 seconds to shutdown. Try to git push again until it works.


Q: I'm trying to use engines in package.json to specify node and npm versions, but it doesn't work. What do I have to do?

A: See @Spown's comment here.

Related

Since you're here, chances are you might also be interested in this custom MongoDB cartridge.

Before raising issues

I'm getting lots of questions from people just learning to do web development or simply looking to solve a very specific problem they're dealing with. While I will answer some of them for the benefit of the community, please understand that open-source is a shared effort and it's definitely not about piggybacking on other people's work. On places like GitHub, that means raising issues is encouraged, but coming up with useful PRs is a lot better. If I'm willing to share some of my code for free, I'm doing it for a number of reasons: my own intellectual challenges, pride, arrogance, stubbornness to believe I'm bringing a contribution to common progress and freedom, etc. Your particular well-being is probably not one of those reasons. I'm not in the business of providing free consultancy, so if you need my help to solve your specific problem, there's a fee for that.

Credits

See contributors here.

If you find this repo useful, don't hesitate to give it a star and spread the word.

License

The ISC License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].