• Stars
    star
    221
  • Rank 174,177 (Top 4 %)
  • Language
    Shell
  • License
    ISC License
  • Created over 9 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

More Repositories

1

mantine-datatable

The table component for your Mantine data-rich applications, supporting asynchronous data loading, column sorting, custom cell data rendering, context menus, nesting, Gmail-style batch row selection, dark theme, and more.
TypeScript
839
star
2

iisexpress-proxy

A simple local proxy for accessing IIS Express from remote machines.
JavaScript
737
star
3

trpc-sveltekit

End-to-end typesafe APIs with tRPC.io for your SvelteKit applications.
TypeScript
727
star
4

trpc-sveltekit-example

A sample SvelteKit application built to illustrate the usage of ✨ trpc-sveltekit.
Svelte
130
star
5

mantine-contextmenu

Craft your applications for productivity and meet your users’ expectations by enhancing your Mantine-based UIs with a desktop-grade, lightweight yet fully-featured, dark-theme aware context-menu component, built by the creator of Mantine DataTable.
TypeScript
114
star
6

expose-wsl

The simplest way to expose apps running on WSL to local network devices.
JavaScript
97
star
7

openshift-cartridge-mongodb

Custom cartridge for OpenShift providing MongoDB > 3.2.
Shell
70
star
8

textdiff-create

Create lean text diff deltas.
JavaScript
37
star
9

aspax

The simple Node.js asset packager.
CoffeeScript
17
star
10

textdiff-patch

Apply lean text diff delta patches created by textdiff-create.
JavaScript
17
star
11

quickstart-express-react

Combined live/hot-reloading quickstart for Express.js/React
JavaScript
16
star
12

trpc-transformer

A simple tRPC transformer based on superjson with decimal.js support
JavaScript
14
star
13

openshift-cartridge-mysql

Custom cartridge for OpenShift providing MySQL 5.7.17
Shell
13
star
14

vlc-3-appimage

A repository for building a VLC 3.0.3 AppImage on Travis CI
Shell
11
star
15

postgresql-tsearch-utils

A collection of files and patterns to improve PostgreSQL text search
11
star
16

aspa

End of Life Notice - January 2014: Please use ASPAX instead.
CoffeeScript
9
star
17

aspa-express

ASPA-Express is an Express/Connect module to use web assets packaged by ASPA
JavaScript
9
star
18

interiordelight.ro.v1

interiordelight.ro
JavaScript
7
star
19

quick-romanian-freelance-tax-calculator

A quick & dirty tax calculator for Romanian freelancers.
Svelte
6
star
20

openshift-cartridge-postgresql

Custom OpenShift cartridge aiming to provide the most recent stable PostgreSQL version packaged by bigsql.org.
Shell
6
star
21

gulp-js-with-nancy-fx

A Node.js-based front-end development workflow for ASP.NET
CSS
5
star
22

icflorescu

Ionut-Cristian Florescu
2
star
23

mantine-contextmenu-v6

The lightweight yet customisable context-menu for your Mantine applications, with a succinct API and dark-theme support. Compatible with Mantine V6.
TypeScript
2
star
24

qilive-q8912-kbd-driver-win-ro

Driver Windows pentru tastatură Bluetooth cu layout românesc Q.8912 de la Qilive
2
star
25

aspax-styl-handler

Plugin enabling ASPAX to handle Stylus files.
CoffeeScript
2
star
26

aspax-ls-handler

Plugin enabling ASPAX to handle LiveScript files.
LiveScript
2
star
27

aspax-jade-handler

Plugin enabling ASPAX to handle Jade files.
CoffeeScript
2
star
28

aspax-iced-handler

Plugin enabling ASPAX to handle IcedCoffeeScript files.
CoffeeScript
2
star
29

aspax-coffee-handler

Plugin enabling ASPAX to handle CoffeeScript files.
CoffeeScript
2
star
30

basic-stylus-grid

A very simple CSS grid system in less than 35 lines of code using Stylus
2
star
31

aspax-less-handler

Plugin enabling ASPAX to handle LESS files.
CoffeeScript
2
star
32

aspax-demo

A simple Node.js application to demonstrate the usage of ASPAX package manager.
JavaScript
1
star
33

aspax-express

Module enabling Express.js to handle assets built and packaged by ASPAX.
JavaScript
1
star
34

flutter_course

Code for Maximilian's Flutter course
Dart
1
star
35

next-netlify-blog-starter

JavaScript
1
star
36

galanta

A minimal UI library to make your Svelte apps look stylish
Svelte
1
star
37

flutterux

A Dart / Flutter / Redux project sample.
Dart
1
star
38

next8-babel-issue

A repo demonstrating issue #6273 in Next.js
JavaScript
1
star
39

mantine-datatable-v6

The table component for your Mantine data-rich applications, supporting asynchronous data loading, column sorting, custom cell data rendering, context menus, nesting, Gmail-style batch row selection, dark theme, and more.
TypeScript
1
star
40

awesome-mantine

A collection of awesome Mantine projects & showcase 👀🚀
1
star