Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Building an Application for Containerization | Section
CI/CD Fundamentals

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

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 6

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

bookBuilding an Application for Containerization

Desliza para mostrar el menú

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

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 6
some-alt