简体   繁体   English

部署 Next.js

[英]Deployment Next.js

As already mentioned, we cannot use dynamic routes with next export.如前所述,我们不能在下一个导出中使用动态路由。 For example, I have /post/:id, where the identifier cannot be predefined.例如,我有 /post/:id,其中标识符无法预定义。 I heard about npm run start, but I don't know how to deploy in this way.听说过npm run start,但是不知道怎么部署。 I use Caddy instead of NGINX.我使用 Caddy 而不是 NGINX。 The main problem is how to build next.js SSR.主要问题是如何构建next.js SSR。 When I do SPA I setup NGINX in Dockerfile and copy out/ folder to /usr/share/nginx/html.当我做 SPA 时,我在 Dockerfile 中设置 NGINX 并将 out/ 文件夹复制到 /usr/share/nginx/html。 But in SSR I need to start node.js server and here I have problems.但是在 SSR 中我需要启动 node.js 服务器,在这里我遇到了问题。

The question is closed, my problem was that I didn't copy src/ folder.问题结束了,我的问题是我没有复制src/文件夹。

Dockerfile: Dockerfile:

FROM node:alpine

RUN mkdir -p /app
WORKDIR /app

COPY package*.json ./
COPY src/ ./src/
COPY public/ ./public/

RUN npm install
RUN npm run build

EXPOSE 80

CMD ["npm", "start"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM