Documentation

Documentation

    ›Tutorials

    General

    • Getting Started
    • Use Cases
    • Setup Guide

    Tutorials

    • Java Container
    • Node.JS Container
    • Python Container
    • .NET Container
    • Ruby Container

    SDK Setup

    • Introduction
    • JVM
    • .NET
    • Python
    • Ruby
    • Node.js
    • Go
    • Deployment Examples

    Session Configuration

    • Instances Selection
    • Source Code
    • Labels

    Breakpoints

    • Introduction
    • Breakpoint Status
    • Conditional Breakpoints
    • Breakpoint Limits
    • Built-in Variables

    Organizations

    • Organizations

    ETL Controller

    • Introduction
    • Installation
    • Configuration

    Data On-Premise

    • Introduction
    • Installation
    • Configuration

    Advanced

    • Live Logger
    • Collaboration
    • Tracing Timeline
    • Keyboard Shortcuts
    • Data Redaction

    More

    • Software Versions
    • Controller and Datastore License
    Edit

    Deploy Rookout on a Node.JS container

    This short tutorial will walk you through the perfect Rookout deployment for containerized NodeJS applications in four quick steps.

    Get Your Application

    First things first, choose an application. If you don't have one readily available, use our sample application.

    Start by:

    git clone https://github.com/Rookout/node-tutorial-2022
    cd node-tutorial-2022
    

    1. Add the npm Package

    Rookout for NodeJS is a simple npm Package.
    Go ahead and add it as a dependency:

    npm install --save rookout
    

    2. Start Rookout

    Load and start the package to connect to your Rookout account (if you haven't signed up, do that here).

    The start function returns a promise - wait for it to debug the application initialization code.

    Edit your main file - in our case index.js:

    const rookout = require('rookout')
    rookout.start({ 
        token: '[Your Rookout Token]',
        labels: {
            env: 'dev'
        }
    }).then(/*Start your application here*/)
    

    Configuration is where you can get fancy. You have got additional options up your sleeve:

    1. Move options to secret or configuration managers.
    2. If you are using a Rookout Controller, set up the remote host and port configuration.
    3. Dig deeper into other options available right here.

    3. Include Source Maps

    Configure transpiling tools to generate source maps and include them in your container image.

    For babel, open the babel.config.json file and change the sourceMaps configuration to inline:

    {
        "sourceMaps": "inline"
    }
    

    Instructions to configure Webpack, TypeScript, and CoffeeScript may be found here.

    4. Embed Source Information

    Rookout offers the smoothest debugging experience by displaying up-to-date source code for each server.

    Set this up for containerized applications by adding a handful of files from your .git folder to the container image.

    Edit (or add) your .Dockerignore file and adapt the traditional .git exclude:

    # Keep ignoring .git
    .git
    # Allow specific files with !
    !.git/HEAD
    !.git/config
    !.git/refs
    

    Add a COPY command to the end of the Dockerfile, just above the ENTRYPOINT.

    COPY .git /.git
    

    Note: in multi-stage builds (like ours), make all your changes on the final stage.

    Test

    One second! if you are not using our demo app, please commit and push your changes to a new branch.

    Build and run your Docker image:

    docker build . -t rookout-nodejs-todo
    docker run -it -p 8080:8080 rookout-nodejs-todo
    

    As your Node.JS application spins up, search for this output at the top:

    Interact with your application at http://localhost:8080 and use Rookout to debug it on the fly!

    Questions?

    1. Check out this reference implementation.
    2. Dig into our Node.JS docs.
    3. Reach out to us via chat or email.
    ← Java ContainerPython Container →
    General

    WelcomeUse CasesSetup Guide
    Tutorials

    Java Container TutorialNode Container TutorialPython Container TutorialDotnet Container TutorialRuby Container Tutorial
    SDK Setup

    Setup IntroJvm SetupDotnet SetupPython SetupRuby SetupNode SetupGo SetupDeployment Examples
    Session Configuration

    Debug Session SetupSource ReposProjects Labels
    Breakpoints

    BreakpointsBreakpoints StatusBreakpoints ConditionalBreakpoint LimitsBuilt In Variables
    Organizations

    Organizations
    ETL Controller

    Etl Controller IntroEtl Controller InstallEtl Controller Config
    Data On-Premise

    Dop IntroDop InstallDop Config
    Advanced

    Live LoggerCollaborationsTracing TimelineKeyboard ShortcutsData Redaction
    More

    Sdk DigestsLicense
    Other

    Status
    GitHub - RookoutFacebook - RookoutTwitter - RookoutLinkedIn - Rookout