Help Center

JavaScript - Node.js + Next.js

Node.js is a framework for the JavaScript language that allows you to create a web application using only this language, running JavaScript on the server side instead of in the browser. It is compatible with all other JavaScript frameworks, as well as its own plugins and extensions.

Next.js is a framework for Node.js that allows designing front-end by facilitating the connection of the graphical interface with JavaScript code. It is the most recommended framework for building user interfaces in a Node.js application, highly optimized and SEO-friendly.

Project structure

text
.
β”œβ”€β”€ app
β”‚Β Β  β”œβ”€β”€ dev.Dockerfile
β”‚Β Β  β”œβ”€β”€ next.config.js 
β”‚Β Β  β”œβ”€β”€ package.json
β”‚Β Β  β”œβ”€β”€ prod.Dockerfile
β”‚Β Β  β”œβ”€β”€ prod-without-multistage.Dockerfile
β”‚Β Β  β”œβ”€β”€ public
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ favicon.ico
β”‚Β Β  β”‚Β Β  └── vercel.svg
β”‚Β Β  β”œβ”€β”€ src
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ pages
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ _app.tsx
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── index.tsx
β”‚Β Β  β”‚Β Β  └── styles
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ globals.css
β”‚Β Β  β”‚Β Β      └── Home.module.css
β”‚Β Β  └── tsconfig.json
β”œβ”€β”€ app.Dockerfile
β”œβ”€β”€ compose.yaml
└── README.txt

Application deployment:

Change to the directory that contains the files needed to build the container:

cd /root/stack/python/nextjs

Then start the application:

text
docker compose up -d

Useful commands:

View running containers:

text
docker compose ps

Stop and remove the application:

text
docker compose down

Rebuild the application after making code changes:

text
docker compose --build -d