<commit_before>= Node.js
{product-author}
{product-version}
:data-uri:
:icons:
:experimental:
:toc: macro
:toc-title:

toc::[]

== Overview
OpenShift provides
link:../../architecture/core_concepts/builds_and_image_streams.html#source-build[S2I]
enabled Node.js images for building and running Node.js applications.
ifdef::openshift-origin[]
The https://github.com/openshift/sti-nodejs[Node.js S2I builder image]
endif::openshift-origin[]
ifdef::openshift-enterprise[]
The Node.js S2I builder image
endif::openshift-enterprise[]
assembles your application source with any required dependencies to create a
new image containing your Node.js application. This resulting image can be run
either by OpenShift or by Docker.

== Versions
Currently, OpenShift provides version
https://github.com/openshift/sti-nodejs/tree/master/0.10[0.10] of Node.js.

== Images

This image comes in two flavors, depending on your needs:

* RHEL 7
* CentOS 7

*RHEL 7 Based Image*

The RHEL 7 image is available through Red Hat's subscription registry using:

----
$ docker pull registry.access.redhat.com/openshift3/nodejs-010-rhel7
----

*CentOS 7 Based Image*

This image is available on DockerHub. To download it:

----
$ docker pull openshift/nodejs-010-centos7
----

To use these images, you can either access them directly from these
link:../../architecture/infrastructure_components/image_registry.html[image
registries], or push them into your
link:../../architecture/infrastructure_components/image_registry.html#integrated-openshift-registry[OpenShift Docker
registry]. Additionally, you can create an
link:../../architecture/core_concepts/builds_and_image_streams.html#image-streams[image
stream] that points to the image, either in your Docker registry or at the
external location. Your OpenShift resources can then reference the ImageStream.
You can find
https://github.com/openshift/origin/tree/master/examples/image-streams[example
image stream definitions] for all the provided OpenShift images.

== Configuration
The Node.js image offers environment variables that facilitate developing your application.

To set these environment variables, you can place them into
link:../../dev_guide/builds.html#environment-files[a *_.s2i/environment_* file]
inside your source code repository, or define them in
link:../../dev_guide/builds.html#buildconfig-environment[the environment
section] of the build configuration's `*sourceStrategy*` definition.

.Development Mode Environment Variables
[cols="3a,6a",options="header"]
|===

| Variable name | Description

|`*DEV_MODE*`
|When set to `true`, enables hot deploy and opens the debug port. Additionally, indicates to tooling that the image is in development mode.  Default is `false`.

|`*DEBUG_PORT*`
|The debug port. Only valid if DEV_MODE is set to true. Default is 5858.

|===

== Hot Deploying

Hot deployment allows you to quickly make and deploy changes to your application
without having to generate a new S2I build. In order to immediately pick up
changes made in your application source code, you must run your built image with
the `*DEV_MODE=true*` environment variable.

For example, see the
link:../../dev_guide/new_app.html#specifying-environment-variables[`oc new-app`]
command. You can use the
link:../../dev_guide/environment_variables.html#set-environment-variables[`oc
env`] command to update environment variables of existing objects.

[WARNING]
====
You should only use this option while developing or debugging; it is not
recommended to turn this on in your production environment.
====

To change your source code in a running pod, use the
link:../../cli_reference/basic_cli_operations.html#troubleshooting-and-debugging-cli-operations[`oc
rsh`] command to enter the container:

----
$ oc rsh <pod_id>
----

After you enter into the running container, your current directory is set to
*_/opt/app-root/src_*, where the source code is located.
<commit_msg>followup edits to nodejs image file<commit_after>= Node.js
{product-author}
{product-version}
:data-uri:
:icons:
:experimental:
:toc: macro
:toc-title:

toc::[]

== Overview
OpenShift provides
link:../../architecture/core_concepts/builds_and_image_streams.html#source-build[S2I]
enabled Node.js images for building and running Node.js applications.
ifdef::openshift-origin[]
The https://github.com/openshift/sti-nodejs[Node.js S2I builder image]
endif::openshift-origin[]
ifdef::openshift-enterprise[]
The Node.js S2I builder image
endif::openshift-enterprise[]
assembles your application source with any required dependencies to create a
new image containing your Node.js application. This resulting image can be run
either by OpenShift or by Docker.

== Versions
Currently, OpenShift provides version
https://github.com/openshift/sti-nodejs/tree/master/0.10[0.10] of Node.js.

== Images

This image comes in two flavors, depending on your needs:

* RHEL 7
* CentOS 7

*RHEL 7 Based Image*

The RHEL 7 image is available through Red Hat's subscription registry using:

----
$ docker pull registry.access.redhat.com/openshift3/nodejs-010-rhel7
----

*CentOS 7 Based Image*

This image is available on DockerHub. To download it:

----
$ docker pull openshift/nodejs-010-centos7
----

To use these images, you can either access them directly from these
link:../../architecture/infrastructure_components/image_registry.html[image
registries], or push them into your
link:../../architecture/infrastructure_components/image_registry.html#integrated-openshift-registry[OpenShift Docker
registry]. Additionally, you can create an
link:../../architecture/core_concepts/builds_and_image_streams.html#image-streams[image
stream] that points to the image, either in your Docker registry or at the
external location. Your OpenShift resources can then reference the ImageStream.
You can find
https://github.com/openshift/origin/tree/master/examples/image-streams[example
image stream definitions] for all the provided OpenShift images.

[[nodejs-configuration]]
== Configuration
The Node.js image supports a number of environment variables, which can be set
to control the configuration and behavior of the Node.js runtime.

To set these environment variables, you can place them into
link:../../dev_guide/builds.html#environment-files[a *_.s2i/environment_* file]
inside your source code repository, or define them in
link:../../dev_guide/builds.html#buildconfig-environment[the environment
section] of the build configuration's `*sourceStrategy*` definition.

.Development Mode Environment Variables
[cols="3a,6a",options="header"]
|===

| Variable name | Description

|`*DEV_MODE*`
|When set to `true`, enables hot deploy and opens the debug port. Additionally, indicates to tooling that the image is in development mode.  Default is `false`.

|`*DEBUG_PORT*`
|The debug port. Only valid if `*DEV_MODE*` is set to true. Default is 5858.

|===

[[nodejs-hot-deploying]]
== Hot Deploying

Hot deployment allows you to quickly make and deploy changes to your application
without having to generate a new S2I build. In order to immediately pick up
changes made in your application source code, you must run your built image with
the `*DEV_MODE=true*` environment variable.

You can set new environment variables when
link:../../dev_guide/new_app.html#specifying-environment-variables[creating new
applications], or
link:../../dev_guide/environment_variables.html#set-environment-variables[updating
environment variables for existing objects].

[WARNING]
====
Only use the `*DEV_MODE=true*` environment variable while developing or
debugging. Using this in your production environment is not recommended.
====

To change the source code of a running pod,
link:../../cli_reference/basic_cli_operations.html#troubleshooting-and-debugging-cli-operations[open
a remote shell into the container]:

----
$ oc rsh <pod_id>
----

Entering into a running container changes your current directory to
*_/opt/app-root/src_*, where the source code is located.
{'fraction_non_alphanumeric': 0.0993202416918429, 'fraction_numerical': 0.007804632426988922, 'mean_word_length': 4.94685628742515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6327126', 'n_tokens_mistral': 2333, 'n_tokens_neox': 2200, 'n_words': 837}