https://github.com/bbachi/nextjs-nginx-docker
https://github.com/bbachi/nextjs-nginx-docker/blob/main/Dockerfile
# stage1 as builderFROM node:10-alpine as builder# copy the package.json to install dependenciesCOPY package.json package-lock.json ./# Install the dependencies and make the folderRUN npm install && mkdir /nextjs-ui && mv ./node_modules ./nextjs-uiWORKDIR /nextjs-uiCOPY . .# Build the project and copy the filesRUN npm run buildFROM nginx:alpine#!/bin/shCOPY ./.nginx/nginx.conf /etc/nginx/nginx.conf## Remove default nginx index pageRUN rm -rf /usr/share/nginx/html/*# Copy from the stahg 1COPY --from=builder /nextjs-ui/out /usr/share/nginx/htmlEXPOSE 3000 80ENTRYPOINT ["nginx", "-g", "daemon off;"]https://github.com/bbachi/nextjs-nginx-docker/blob/main/.nginx/nginx.conf
worker_processes 4;events { worker_connections 1024; }http { server { listen 80; root /usr/share/nginx/html; include /etc/nginx/mime.types; location /appui { try_files $uri /index.html; } }}Wondering if there's anything that can make it faster.
1 Answer1
To makeit faster?
(Assuming "it" is the build)Look into buildkit, see this SO question:https://stackoverflow.com/questions/65913706/how-do-i-make-yarn-cache-modules-when-building-containers
Otherwise, using yarn instead of npm might speed you up a little bit in the building process.
(Assuming "it" is the NextJS server (building))Make sure that you are using Next version >12. The Rust compiler is MUCH faster than the javascript one.
(Assuming "it" is the NextJS server (running))Make sure that all of your pages (or as many as possible) are statically generated. This allows the Next Server to serve them on demand instead of needing to Server Side Render them on demand.