Gathering detailed insights and metrics for fullstack-nextjs-app-template
Gathering detailed insights and metrics for fullstack-nextjs-app-template
Gathering detailed insights and metrics for fullstack-nextjs-app-template
Gathering detailed insights and metrics for fullstack-nextjs-app-template
create-swift-simplify-nextjs-supabase-starter
A simple CLI to create a Next.js 15 + Supabase project
@deathstrokeaj/create-stack-app
CLI tool to generate full-stack web application templates with modern technologies
create-next-supabase-starter
A simple CLI to create a Next.js 15 + Supabase project
create-4cousin
Create Node.js, React.js, Next.js, and React Native projects with ease. This CLI tool helps you quickly scaffold production-ready applications by offering a selection of templates for Node.js, React.js, Next.js, and React Native. It automatically sets up
A full-stack sample web application based on Next.js that creates a simple whole-website architecture
npm install fullstack-nextjs-app-template
Typescript
Module System
Node Version
NPM Version
TypeScript (66.59%)
JavaScript (30.22%)
PHP (1.32%)
SCSS (1.01%)
Dockerfile (0.86%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
209 Stars
239 Commits
105 Forks
6 Watchers
1 Branches
1 Contributors
Updated on Jul 10, 2025
Latest Version
1.4.0
Package Id
fullstack-nextjs-app-template@1.4.0
Unpacked Size
27.62 MB
Size
8.60 MB
File Count
3,622
NPM Version
9.6.7
Node Version
18.17.0
Published on
Jul 17, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This repository is a full-stack sample web application based on Next.js that creates a simple whole-website architecture, and provides the foundational services, components, and plumbing needed to get a basic web application up and running.
List my progress here:
Function Block | Supports |
---|---|
💎 Pages Router Demo Template | ✅ 👉🏼 Enabling it requires renaming the folder @pages to pages , and deleting app. |
💎 App Router Demo Template | ✅ 👉🏼 Default |
💎 Exporting Pure HTML Static Files (.html) | ✅ 👉🏼 run npm run export and npm run export:fix |
HTTP Navigation (SSR & Async) | ✅ |
Multiple API Constructs | ✅ |
Parameter Acquisition | ✅ |
Pagination | ✅ |
Basic Importing Methods for Components | ✅ |
Authorization | ✅ |
Login | ✅ |
Network Requests | ✅ |
API Demo | ✅ |
CURD Demo | ✅ |
JWT Demo | ✅ |
File Import | ✅ |
SEO Premium | ✅ |
Static Pages | ✅ |
Incremental Static Regeneration | ✅ |
Remote Download | ✅ |
Fully Static HTML Files Generation | ✅ |
Custom Server | ✅ |
Custom Hooks (auth, redux, draggable, keypress etc.) | ✅ |
Frontend Page Interacts With Node | ✅ |
Alias Support | ✅ |
Local PHP Service Association | ✅ |
Server Deployment | ✅ |
Deploy Using Docker | ✅ |
Redux Supplement (for navigation) | ✅ |
Redux SSR (for homepage navigation) | ✅ |
WebSocket Support via socket.io | ✅ |
Additional Node.js Services | ✅ |
Request Cache Demo | ✅ |
Authentication of Microservices | ✅ |
Markdown Render Demo | ✅ |
NestJS Support | 🕒 |
🍗 End-to-end typesafe API (gRPC) | ⚠️ unbundled 👉🏼 gRPC Getting Started |
🍗 React UI Components Libraries | ⚠️ unbundled 👉🏼 Funda UI |
1fullstack-nextjs-app-template/ 2├── README.md 3├── CHANGELOG.md 4├── LICENSE 5├── next.config.js 6├── server.js 7├── ecosystem.config.js 8├── middleware.ts 9├── tsconfig.json 10├── package-lock.json 11├── package.json 12├── .dockerignore 13├── Dockerfile 14├── docker-compose.yml 15├── out/ # Folder generated by export command which contains the HTML/CSS/JS assets for your application 16├── backend/ 17│ ├── server-php.js # test server 18│ └── ... # All other files are optional 19├── scripts/ # Node Script Library 20├── public/ # Contains static resources, PHP remote test files, .md files for markdown rendering, etc. 21├── app/ # App Router Demo Template 22├── @pages/ # Pages Router Demo Template (Enabling it requires renaming the folder `@pages` to `pages`, and deleting `app`.) 23│ ├── api/ 24│ └── *.tsx 25├── src/ 26│ ├── config/ 27│ ├── data/ 28│ ├── contexts/ 29│ ├── interfaces/ 30│ ├── components/ 31│ ├── styles/ 32│ ├── utils/ 33│ └── store/ 34└──
Make sure if NODEJS is installed on your computer.
1$ npm install
It will create node_module
folder in this all dependency files will be install with this command.
1$ npm i next@latest react@latest react-dom@latest eslint-config-next@latest
check out here
1$ npm run dev
With is command file will be compiled and it will be loaded on local server http://localhost:3000.
1$ npm run build
Note: Defer generating all pages on-demand by this command. You can have faster builds by generating all pages on-demand for previews (but not production builds). This is helpful for sites with hundreds/thousands of static pages.
1$ npm run build:static
This build mode will generate static data.
1$ npm run start
Please install php on your computer first.
1$ npm run action:phpserver
Please use a PHP server environment with a local port of 4000, check the file at ./backend/server-php.js
production mode:
1$ npm run build # this command must be run first 2$ npm run deploy:prod
development mode:
1$ npm run deploy:dev
(If it doesn't work because of Node permission, use the following commands)
1$ npm run destroy
FIrst, you need to enable Static Exports.
[!WARNING] ISR cannot be used with "output: export".
Step 1. generate static resources:
1$ npm run export
Step 2. fix name for HTML files:
1$ npm run export:fix
Step 3. preview the static site
Then, test the generated static website (the HTML static website is located in the directory .out/
). Access using the URL http://localhost:12345
1$ npm run export:test
Check out this article
Before you can get started with the App Router, you will first need to create a /app directory as a sibling to your /pages directory.
If you have a Custom Document at /pages/_document.tsx, it should look something like this, though likely with some customization:
/pages/_document.tsx
1import { Html, Head, Main, NextScript } from 'next/document' 2 3export default function Document() { 4 return ( 5 <Html> 6 <Head /> 7 <body> 8 <Main /> 9 <NextScript /> 10 </body> 11 </Html> 12 ) 13}
We need to convert this into a Root Layout, which can be treated as a 1-to-1 corollary to a Custom Document:
<Html>
and </Html>
with the lowercase, HTML equivalent <html>
and </html>
. For accessibility, it's best to add a language to your opening tag, like <html lang="en">
<Head>
and </Head>
with the lowercase, HTML equivalent <head>
and </head>
. If you only have a self-closing <Head />
, you can remove it entirely<Main />
with {children}
, and update the default function export to accept a {children}
argument. For Typescript users, children
is of type React.ReactNode
<NextScript />
entirelyWhen complete, /app/layout.tsx should look more like this, plus your customizations:
/app/layout.tsx
1export default function RootLayout({ children }: { children: React.ReactNode }) { 2 return ( 3 <html lang="en"> 4 <body>{children}</body> 5 </html> 6 ) 7}
Important: /app/layout.tsx is required in the /app directory. If you do not have a Custom Document, you can copy-paste the above sample directly into /app/layout.tsx.
Note: If you do not have a file at /pages/_app.tsx you can skip to Step 3.
If you have a Custom App at /pages/_app.tsx, it should look something like this, though likely with some customization:
/pages/_app.tsx
1import type { AppProps } from 'next/app' 2 3export default function MyApp({ Component, pageProps }: AppProps) { 4 return <Component {...pageProps} /> 5}
The /app directory does not have a 1-to-1 corollary for a Custom App, but it can easily be expressed in the new structure:
"use client"
(with the quotes)Component
and pageProps
arguments, it should only take a children
argument. For Typescript users, children
is of type React.ReactNode
.<Component {...pageProps} />
with <>{children}</>
, or just {children}
if you have another wrapping elementpageProps
, please comment them out for now, and revisit them on a page-by-page basis. Next.js has added a new metadata API that should normally be used in place of accessing pageProps
hereMyApp
to ClientLayout
. It is not strictly necessary, but it is more conventionalWhen complete, /app/ClientLayout.tsx should look more like this, plus your customizations:
/app/ClientLayout.tsx
1'use client' 2 3export default function ClientLayout({ children }: { children: React.ReactNode }) { 4 return <>{children}</> 5}
Now, this is where things get a little different:
ClientLayout
inside /app/layout.tsxOpen /app/layout.tsx, import ClientLayout, and use it to wrap {children}
. When complete, your Root Layout should look like this, plus any customizations from Step 1:
/app/layout.tsx
1import ClientLayout from './ClientLayout' 2 3export default function RootLayout({ children }: { children: React.ReactNode }) { 4 return ( 5 <html lang="en"> 6 <body> 7 <ClientLayout>{children}</ClientLayout> 8 </body> 9 </html> 10 ) 11}
Now that your layout has been copied into the App Router, it's time to start migrating your pages one-by-one. There will be a few steps for each page:
For the avoidance of doubt: yes, we will be splitting your Pages Router page into two files: one for data fetching and one for rendering.
Both the Pages Router and the App Router are "filesystem routers," but they are organized slightly differently. In the App Router, each page gets its own directory. Here is how to determine the directory name:
If your file is named index.tsx, create the same parent directory structure
If your file is not named index.tsx, create a directory with that filename
Inside your page directory, create a file called page.tsx to handle data fetching. Copy-paste the following snippet as the foundation of this file (Note: we will create ClientPage.tsx in 3.3.):
page.tsx
1import ClientPage from './ClientPage' 2 3export default async function Page() { 4 return <ClientPage /> 5}
If your Pages Router file does not have any data fetching, you can continue on to the next step. Otherwise, find your data fetcher below to learn how it can be migrated:
Migrating getStaticProps to the App Router
Consider the following is your implementation of getStaticProps
:
1export const getStaticProps: GetStaticProps<PageProps> = async () => { 2 const res = await fetch('https://api.github.com/repos/vercel/next.js') 3 const repo = await res.json() 4 return { props: { repo } } 5}
To migrate this with as little modification as possible, we will:
getStaticProps
into page.tsxgetStaticProps
from within our Page
componentexport const dynamic = "force-static"
so the page data is fetched once and cached, not refetched on every loadClientPage
componentHere is the end result:
page.tsx
1import ClientPage from './ClientPage' 2 3export const getStaticProps: GetStaticProps<PageProps> = async () => { 4 const res = await fetch('https://api.github.com/repos/vercel/next.js') 5 const repo = await res.json() 6 return { props: { repo } } 7} 8 9export const dynamic = 'force-static' 10 11export default async function Page() { 12 const { props } = await getStaticProps() 13 return <ClientPage {...props} /> 14}
Migrating getServerSideProps to the App Router
Consider the following implementation of getServerSideProps
:
1import { getAuth } from '@clerk/nextjs/server' 2 3export const getServerSideProps: GetServerSideProps<PageProps> = async ({ req }) => { 4 const { userId } = getAuth(req) 5 6 const res = await fetch('https://api.example.com/foo', { 7 headers: { 8 Authorization: `Bearer: ${process.env.API_KEY}`, 9 }, 10 }) 11 const data = await res.json() 12 return { props: { data } } 13}
To migrate this with as little modification as possible, we will:
getServerSideProps
into page.tsxexport const dynamic = "force-dynamic"
so the page data is refetched on every load, reference docsreq
with the App Router equivalentreq.headers
with the new headers() helperreq.cookies
with the new cookies() helperreq.url.searchParams
with the new searchParams helpergetServerSideProps
from within our Page
componentClientPage
componentHere is the end result:
page.tsx
1import { auth } from '@clerk/nextjs' 2import ClientPage from './ClientPage' 3 4export const getServerSideProps: GetServerSideProps<PageProps> = async () => { 5 const { userId } = auth() 6 7 const res = await fetch('https://api.example.com/foo', { 8 headers: { 9 Authorization: `Bearer: ${process.env.API_KEY}`, 10 }, 11 }) 12 const data = await res.json() 13 return { props: { data } } 14} 15 16export const dynamic = 'force-dynamic' 17 18export default async function Page() { 19 const { props } = await getServerSideProps() 20 return <ClientPage {...props} /> 21}
Migrating getStaticPaths to the App Router
Consider the following implementation of getStaticPaths
:
1export async function getStaticPaths() { 2 return { 3 paths: [{ params: { id: '1' } }, { params: { id: '2' } }], 4 } 5}
In the App Router, this implementation barely changes. It's simply given a new name (generateStaticParams
) and the output is transformed to something simpler. That means you can use your old implementation directly, and simply transform the output.
Here is the end result – we included an example of how it can be used in tandem with getStaticProps
:
page.tsx
1import ClientPage from './ClientPage' 2 3export async function getStaticPaths() { 4 return { 5 paths: [{ params: { id: '1' } }, { params: { id: '2' } }], 6 } 7} 8 9export async function generateStaticParams() { 10 const staticPaths = await getStaticPaths() 11 return staticPaths.paths.map((x) => x.params) 12} 13 14export const getStaticProps: GetStaticProps<PageProps> = async ({ params }) => { 15 const res = await fetch(`https://api.example.com/foo/${params.id}`) 16 const data = await res.json() 17 return { props: { data } } 18} 19 20export default async function Page({ params }) { 21 const { props } = await getStaticProps({ params }) 22 return <ClientPage {...props} /> 23}
Now that data fetching is ready, we need to configure the rendering. To accomplish this:
That's it! We have already configured page.tsx to mount this file and pass props, so it should be working.
Now that your page is ready in the App Router, you can delete the old Pages Router variant.
📌 Note: Using server.js may cause an error during [HMR] restart (first loading of the client): WebSocket connection to 'ws://localhost:3000/_next/webpack-hmr' failed: --> InvalidArgumentError: invalid upgrade header You can ignore it.
Create a new file server.js
(do not use .ts
) at the same level as your pages
directory. Take a look at the following example of a custom server:
1const { createServer } = require('http'); 2const { parse } = require('url'); 3const next = require('next'); 4 5let dev = process.env.NODE_ENV !== 'production'; 6dev = false; // need run `npm run build` first 7const hostname = 'localhost'; 8const port = 3000; 9// when using middleware `hostname` and `port` must be provided below 10const app = next({ dev, hostname, port }); 11const handle = app.getRequestHandler(); 12 13app.prepare().then(() => { 14 createServer(async (req, res) => { 15 try { 16 // Be sure to pass `true` as the second argument to `url.parse`. 17 // This tells it to parse the query portion of the URL. 18 const parsedUrl = parse(req.url, true) 19 const { pathname, query } = parsedUrl 20 21 if (pathname === '/a') { 22 await app.render(req, res, '/a', query) 23 } else if (pathname === '/b') { 24 await app.render(req, res, '/b', query) 25 } else { 26 await handle(req, res, parsedUrl) 27 } 28 29 } catch (err) { 30 console.error('Error occurred handling', req.url, err) 31 res.statusCode = 500 32 res.end('internal server error') 33 } 34 }).listen(port, (err) => { 35 if (err) throw err 36 console.log(`> Ready on http://${hostname}:${port}`) 37 }) 38})
Modify the file server.js
, use https.createServer([options][, requestListener]) to wrap the express service, please check out the sample code below:
1// Supprt HTTPS 2const fs = require('fs'); 3const path = require('path'); 4const https = require('https'); 5const cert = fs.readFileSync(path.join(__dirname,'../../path/bundle.crt')); 6const key = fs.readFileSync(path.join(__dirname,'../../path/ca.key')); 7const options = {key: key, cert: cert }; 8 9 10app.prepare().then(() => { 11 https.createServer(options, async (req, res) => { 12 try { 13 ... 14 } catch (err) { 15 console.error('Error occurred handling', req.url, err) 16 res.statusCode = 500 17 res.end('internal server error') 18 } 19 }).listen(port, (err) => { 20 if (err) throw err 21 console.log(`> Ready on https://${hostname}:${port}`) 22 }) 23})
access with https://localhost:3000
or https://{YOUR_IP}:3000
package.json
To run the custom server you'll need to update the scripts in package.json like so:
1"scripts": { 2 "dev": "node server.js", 3 "start": "NODE_ENV=production node server.js" 4}
(Optional). Disabling file-system routing
1module.exports = { 2 useFileSystemPublicRoutes: false, 3}
Start Next.js application with PM2 as a service (only works if you are using Node v18.17.0 or above.)
Node14+ version will be installed here
1$ curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash - 2$ sudo yum install nodejs 3$ node --version #v14.16.1 4$ npm --version #6.14.12
1$ sudo npm install pm2@latest -g
1#into your `"fullstack-nextjs-app-template/"` folder directory. 2$ cd /{your_directory}/fullstack-nextjs-app-template 3 4 5#run app 6$ pm2 start ecosystem.config.js 7 8#other commands 9$ pm2 restart ecosystem.config.js 10$ pm2 stop ecosystem.config.js 11$ pm2 delete ecosystem.config.js 12$ pm2 list 13$ pm2 logs
1$ pm2 start npm --name "fullstack-nextjs-app-template" -- start
destroy process:
1$ pm2 stop "fullstack-nextjs-app-template" & pm2 delete "fullstack-nextjs-app-template"
1$ pm2 startup 2$ systemctl status pm2-root 3$ pm2 start /{your_directory}/fullstack-nextjs-app-template/ecosystem.config.js --restart-delay=3000 4$ pm2 save
💡 Some solutions to problems that may occur when deploying the application with NPM or PM2 on cloud server:
a)The
build
ordev
command failsWhen on an M1 Mac and switching from a Node.js version without M1 support to one with, e.g. v14 to v16, you may need a different swc dependency which can require re-installing
node_modules
(npm i --force or yarn install --force).1$ npm i --force # This can be ignored if you can build 2$ rm -rf /{your_directory}/fullstack-nextjs-app-template/.next # Delete the. Next folder 3$ npm run build 4$ pm2 start ecosystem.config.js
Make sure your server has directory and file permissions to run the project
b)ERROR: permission denied, access '/usr/lib/node_modules'
Solution:
1$ chmod -R a+x node_modules
c)ERROR: JavaScript heap out of memory
There is a strict standard limit for memory usage in V8 to be a maximum of ~1GB (32-bit) and ~1.7GB (64-bit), if you do not increase it manually.
Solution:
1export NODE_OPTIONS=--max_old_space_size=4096
d) Error: EACCES: permission denied, mkdir '/root/.pm2/xxxx'
Solution:
In general, just avoid using
NPM
to run PM2 commands.You could still try the following:
Make sure you kill any PM2 instance before starting PM2 in no deamon mode (pm2 kill).
1# re-install PM2 (optional) 2$ sudo npm i -g pm2 3 4# if pm2 was reinstalled, ts-node must be reinstalled (optional) 5$ sudo npm install -g ts-node@latest 6 7# clear all pm2 instances 8$ pm2 kill 9 10# then restart it 11$ pm2 start xxxxxx
You had created a basic Next.js App from here, then you need to deploy a Next.js App on Apache or Nginx web server. Please refer to the network for the tutorial on setting up the proxy.
Now that the app is ready to be deployed, we should prepare the Nginx end. In case Nginx is not installed, it can be easily installed with the apt packaging system by running the following two commands:
1$ sudo apt update 2$ sudo apt install nginx
or
1$ sudo yum install nginx -y
Start Nginx:
1$ systemctl start nginx
Start at boot:
1$ systemctl enable nginx
Set Up a Firewall Using FirewallD on CentOS 8:
1$ firewall-cmd --permanent --zone=public --add-service=http 2$ firewall-cmd --permanent --zone=public --add-service=https 3$ firewall-cmd --permanent --zone=public --add-port=3000/tcp 4$ firewall-cmd --reload 5$ systemctl restart nginx
We can check if Nginx is running on the system:
1$ systemctl status nginx
Alright, now that the Nginx service has successfully started running, we can go ahead and modify the configuration file found at /etc/nginx/conf.d/default.conf
. This is where we will point the domain to fire up the correct Next.js application:
1$ vi /etc/nginx/conf.d/default.conf
At the end of the file, add:
1server { 2 listen 443 ssl; 3 server_name backend1.example.com; 4 5 ... 6 location / { 7 proxy_set_header Host $http_host; 8 proxy_pass http://{YOUR_IP}:3000; 9 } 10 11}
After adding these lines to the file, we need to restart the Nginx service:
1$ systemctl restart nginx
There probably won’t be any messages if the service restarted successfully. Otherwise, it will spit out lines of error messages.
run the following command
1$ killall -9 node
To change your Site Favicon, navigate the file pages/_document.tsx
and modify the code between <Head>
Navigate the file src/components/Header
and modify it.
In your package.json file, add -p 8080 to the dev/start scripts to start the server on port 8080:
1"scripts": { 2 "dev": "next -p 8080", 3 "start": "next start -p 8080" 4}
Alternatively, if you don't want to hardcode this in the package.json file, you could start the script with ENV variable PORT.
1$ PORT=8080 npm run dev
Change the root directory of the website so that it can be used when you upload the project to another directory. Modify the key siteUrl
of the ./src/data/app.json
.
If the file is in the root directory, you can leave it empty. If in another directory, you can write: "/blog". (no trailing slash)
1{ 2 "siteUrl": "http://localhost:3000", 3 "copyright": "xxxxxxxxxx" 4}
⚠️ Tips: When running the
getServerSideProps
of Next.js,Express
andWebSocket
services of Node.js, the communication would be container to container. So for these requests, routes to localhost (http://localhost:3000
) would not work. Instead it would need to be something likehttp://localhost:7777
instead (when communicating from the frontend service to the backend service). The localhost domain would work as expected on the client side requests.⚠️ Warning: Multiple micro-service containers cannot be opened on the server side at the same time, otherwise the upstream server will terminate the WebSocket connection.
When you run this without docker everything works because all services are on localhost. When run via docker-compose they no longer are.
https://docs.docker.com/desktop/release-notes/#4110
install docker on ubuntu
1$ sudo apt-get update 2$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 3$ sudo docker run hello-world
Dockerfile
in the root directory of the application1$ cd /Applications/MAMP/htdocs/fullstack-nextjs-app-template 2$ touch Dockerfile 3$ vi Dockerfile
the following:
…
next.config.js
file:You can directly set the dockerDeploymentEnabled
property to true
in the current next.config.js
.
[!NOTE] Use Docker container, don't use Static Exports.
1// next.config.js 2module.exports = { 3 // ... rest of the configuration. 4 output: 'standalone', 5}
Syntax: docker build [OPTIONS] PATH | URL | -
! ! ! Note: The last path is a point, don't miss it
1$ docker build -t fullstack-nextjs-app-template:v1 .
[The first deployment takes a few minutes because it needs other docker libraries, and it only takes tens of seconds after that]
❌ If 401 Unauthorized error, first run:
1$ docker pull node:18.17.0-alpine3.17
The -p flag exposes the container's ports to services outside of docker (the first port is the port exposed to the outside). Use of multiple ports: docker run -p <host_port1>:<container_port1> -p <host_port2>:<container_port2>
Run your container:
1$ docker run -p 3000:3000 fullstack-nextjs-app-template:v1
NOTE:
If Ctrl+C does not work to terminate the container, please add the following code in the server file such as Express, and use the following command to temporarily run the container. Access Specify an init process
1// Stop running node in docker with Ctrl+C sends the SIGINT signal. 2// Usage: docker run --init -p <host_port>:<container_port> <image_name:version> 3const process = require('process'); 4process.on('SIGINT', () => { 5 console.info("Interrupted") 6 process.exit(0); 7});
1$ docker run --init -p <host_port>:<container_port> <image_name:version>
Run the image with -d to run the container in detached mode, leaving the container running in the background. The -p flag redirects the public port to a private port inside the container.
1$ docker run -p 3000:3000 -d fullstack-nextjs-app-template:v1
1$ docker ps 2$ docker stop <PID> 3$ docker kill <PID>
The process already exists, to delete, for example, port 3000
1#Query the process of port 3000 2$ lsof -i tcp:3000 3 4#PID is replaced by the id of the process 5$ kill -9 <PID>
Note: change the
192.168.1.140
to yours
Otherwise, an error will be reported:
docker: Error response from daemon: Mounts denied:
Sometimes it may be inconvenient to use a public repository like Docker Hub, and users can create a local repository for private use. For example, an image built based on a company's internal project.
docker-registry
is an official tool that can be used to build a private image.
It can be run by obtaining the official Registry. By default, the repository will be created in the container's /var/lib/registry
directory (for Linux or Mac), and now I reset it to a shared directory on my computer.
1docker run --name registry -d -p 5000:5000 --restart=always -v /Users/changcheng/Desktop/share:/var/lib/registry registry
access:http://192.168.1.140:5000/v2/
Indicates that port 5000
has been successfully proxied by docker.
1$ docker tag fullstack-nextjs-app-template:v1 192.168.1.140:5000/fullstack-nextjs-app-template-v1
push it
1$ docker push 192.168.1.140:5000/fullstack-nextjs-app-template-v1
In case of error:
http: server gave HTTP response to HTTPS client
Please configure registry-mirrors
image sources and insecure-registries
private repositories in Docker Desktop
Modify daemon.json
(can be modified directly through the Docker Desktop)
1$ cat ~/.docker/daemon.json
Add the following configuration:
1{ 2 "registry-mirror":[ 3 "http://hub-mirror.c.163.com" 4 ], 5 "insecure-registries":[ 6 "192.168.1.140:5000" 7 ] 8}
restart docker
1$ docker pull 192.168.1.140:5000/fullstack-nextjs-app-template-v1
View the container that is running in the background (note that you need to run it first to find the id)
1$ docker ps
To package the running docker container into an image image, run docker commit <container_id> <image_name:version>
1$ docker commit 16cb27979742 fullstack-nextjs-app-template:v1
Next, save the newly packaged image as a tar file, run docker save <image_name:version> -o <path_name>
1$ docker save fullstack-nextjs-app-template:v1 -o ./fullstack-nextjs-app-template-v1.tar
docker-compose.yml
, the content as follows:1services: 2 web: 3 build: . 4 ports: 5 - "3000:3000" 6 depends_on: 7 - my_node_service 8 my_node_service: 9 image: "my-node-server:v1" 10 ports: 11 - "4001:4001"
1# build 2$ docker build -t my-node-server:v1 . 3# test 4$ docker run --init -p 4001:4001 my-node-server:v1
1$ docker-compose up
Solution 1:
Using k8s with load balancing, without nginx. Config the sessionAffinity on service:
1service.spec.sessionAffinity = "ClientIP"
Solution 2:
Adding transports: ['websocket'] to socketIOClient options in our multi-pod Kubernetes environment:
1socketIOClient(someUrl, {transports: ['websocket']});
Refer to: Using multiple nodes
a) Has node_modules
folder, just do it directly.
If running npm run <script>
fails because Node has been upgraded, use npx -p node@<version> <your_script>
to run:
such as
1$ npx -p node@15.14.0 npm run dev 2$ npx -p node@14.21.3 npm run start
b) If there is no node_modules
folder, using npm install --legacy-peer-deps
is still unsuccessful. After deleting the dependencies of package.json and remove file package-lock.json, use the following command to reinstall:
1$ npm install <package1> <package2> --legacy-peer-deps 2$ npm install --save-dev <package1> <package2> --legacy-peer-deps
c) NPM or NPX cache error
View the location of the local npm cache:
1$ npm config get cache
Clear cache (npm and npx)
1$ npm cache clean --force
or
1$ rm -rf ~/.npm
Check cache
1$ npm cache verify
Licensed under the MIT.
No vulnerabilities found.
No security vulnerabilities found.