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 with its own plugins and extensions.

Next.js is a framework for Node.js that enables front-end design by facilitating the connection between the user interface and 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
β”œβ”€β”€ nginx
β”‚   └── default.conf
β”œβ”€β”€ backup
β”‚   └── backup-runner.sh
β”œβ”€β”€ .env
└── .env.example

Application deployment:

We change to the directory that contains the files required to build the container:

cd /root/stack/python/nextjs

Then start the application:

text
docker compose up -d

Useful commands:

View the containers that are running:

text
docker compose ps

Stop and remove the application:

text
docker compose down

Rebuild the application after making changes to the code:

text
docker compose up -d --build
Guide g.0291 Β· Source version 1 Β· en