我正在尝试缩短节点/快速应用程序的启动时间。
我注意到需要某些模块会花费很长时间:
const StyledIframe = styled.iframe`
width: 100vw;
height: 100vh;
position: absolute;
z-index: 99999;
`;
const BooksyWidget = ({ isOpen }) => {
const src = "https://booksy.com/widget/index.html?id=9178&lang=pl&country=pl&mode=dialog&theme=default"
const Content = () => {
return isOpen ? <StyledIframe src={ src }/> : null
}
return (
<>
{Content()}
</>
)
};
需要这样的模块:
tracer: 2490.321ms
createError: 73.287ms
express: 975.461ms
expressHbs: 2592.473ms
path: 0.050ms
cookieparser: 22.411ms
logger: 57.616ms
objection: 1219.993ms
knex: 883.697ms
knexConfig: 4.241ms
passport: 92.907ms
session: 127.029ms
RedisStore: 65.394ms
app.js: 10214.760ms
我正在从Macbook Pro上的本地docker容器运行应用程序。
Dockerfile
const express = require('express');
如何加快加载过程?
答案 0 :(得分:0)
将所有依赖项包含在package.json中,并按如下所示重写Dockerfile
FROM节点:10.16.0
WORKDIR / app
COPY [“ package.json”,“ ./”]
运行npm i --production && mv node_modules ../
复制..
EXPOSE 3000
CMD [“ npm”,“ run”,“ start-dev”]