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
.
βββ 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:
docker compose up -d
Useful commands:
View the containers that are running:
docker compose ps
Stop and remove the application:
docker compose down
Rebuild the application after making changes to the code:
docker compose up -d --build