Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Building an Application for Containerization | CI/CD & Automation
Introduction to DevOps

bookBuilding an Application for Containerization

Now you need to create a simple application that you'll later run inside a container.

But before you can start writing any code, you need a tool that allows us to run JavaScript on our computer, install the necessary libraries, and spin up a server for testing.

That tool is Node.js β€” it will serve as the foundation of our application and provide everything you need to move forward.

Installation and Configuration of Node.js

Go to the official Node.js website and download the LTS (Long-Term Support) version β€” it's the most stable and widely supported option.

The installer includes:

  • Node.js β€” the JavaScript runtime environment;

  • npm (Node Package Manager) β€” the tool for installing and managing project dependencies.

Once the installation is complete, verify it by running these commands in your terminal or command prompt:

This will print the installed Node.js version.

This will print the installed npm version. If both commands return versions, the installation was successful.

Creating a Project

Next, let's create a new project folder and move into it:

Now initialize the project with default settings. This will generate a package.json file that keeps track of your project details and dependencies:

Install Express, a popular framework that makes building servers simple and fast:

Creating Server File

The main entry point of the app will be server.js. This file creates and configures the Express server and defines how it responds to requests.

Create a file called server.js inside your project folder and add the following code:

server.js

server.js

copy

This code imports Express, creates a server, and defines the / route that sends a message to the user. The server starts on the port specified by the environment variable PORT, or defaults to 3000 if the variable is not set.

1. Which command is used to check the installed version of Node.js?

2. What does npm stand for?

question mark

Which command is used to check the installed version of Node.js?

Select the correct answer

question mark

What does npm stand for?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 6

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Awesome!

Completion rate improved to 3.7

bookBuilding an Application for Containerization

Swipe to show menu

Now you need to create a simple application that you'll later run inside a container.

But before you can start writing any code, you need a tool that allows us to run JavaScript on our computer, install the necessary libraries, and spin up a server for testing.

That tool is Node.js β€” it will serve as the foundation of our application and provide everything you need to move forward.

Installation and Configuration of Node.js

Go to the official Node.js website and download the LTS (Long-Term Support) version β€” it's the most stable and widely supported option.

The installer includes:

  • Node.js β€” the JavaScript runtime environment;

  • npm (Node Package Manager) β€” the tool for installing and managing project dependencies.

Once the installation is complete, verify it by running these commands in your terminal or command prompt:

This will print the installed Node.js version.

This will print the installed npm version. If both commands return versions, the installation was successful.

Creating a Project

Next, let's create a new project folder and move into it:

Now initialize the project with default settings. This will generate a package.json file that keeps track of your project details and dependencies:

Install Express, a popular framework that makes building servers simple and fast:

Creating Server File

The main entry point of the app will be server.js. This file creates and configures the Express server and defines how it responds to requests.

Create a file called server.js inside your project folder and add the following code:

server.js

server.js

copy

This code imports Express, creates a server, and defines the / route that sends a message to the user. The server starts on the port specified by the environment variable PORT, or defaults to 3000 if the variable is not set.

1. Which command is used to check the installed version of Node.js?

2. What does npm stand for?

question mark

Which command is used to check the installed version of Node.js?

Select the correct answer

question mark

What does npm stand for?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 6
some-alt