Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

hec7orci7o/next-fs-template

Repository files navigation

next-fs-template Production CI

node npm

Next JS TailwindCSS ESLint Docker Nginx Prisma cypress

Folder structure

Note _document.js vs. _app.js -- What is the difference?

  • _app.js: Core of the application, everything is assembled from here at runtime.
  • _document.js: Where side effects are possible.
  • components: Contains the reusable layouts of the application.
  • context: Encapsulates a global state that can be accessed from anywhere in the application.
  • hooks: Encapsulates small pieces of code that represent a certain type of logic.
  • lib: Chaos property, stores here functionalities that do not have to do with the rest of the mentioned sections.
  • pages/api: Endpoints for creating an api rest.
  • pages: pages accessible from the browser via .../page
  • public: Static content.
  • styles: Contains the styles of the application. Override or new styles in tailwind.config.js.
  • nginx: Contains the nginx server configuration.

Getting Started

Setting up the database

Note To change the database you have to modify the provider value found in the prisma/schema.prisma file and the environment variable DATABASE_URL

npx prisma generate
npx prisma db push

Warning If your project does not require a database, you can follow the following actions.

npm uninstall prisma @prisma/client
rm -rf prisma

Running the app

Run for a development environment

Warning This version does not include nginx redirectión.
Server will be available in: localhost:3000

npm i --force
npm run dev

Run for a production environment

Warning This version does not include nginx redirectión.
Server will be available in: localhost:3000

npm run build
npm run start

Run for a production environment with pm2

Warning This version does not include nginx redirectión.
Server will be available in: localhost:3000

pm2 start pm2-deploy.json

Compile for docker

docker build --tag next-template-image .
docker build --tag nginx-image ./nginx

docker network create my-network

docker run --network my-network --name next-template-container next-template-image
docker run --network my-network --link next-template-container:nextjs --publish 80:80 nginx-image

Compile for docker compose

Note This version includes nginx redirectión.
Server will be available in: localhost:80

docker-compose up -d

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the NextJS GitHub repository