2 回答

TA貢獻1798條經驗 獲得超7個贊
問題的根本原因是 VM t2.micro 的弱點。
t2.micro 只有 1 個 vCPU 和 1GB 內存
我會說這個容量對于應用程序運行時(nginx)來說已經足夠了。
但是對于應用程序構建(npm run build
)來說,這永遠不夠。
根據經驗,我們負責構建 400 多個計劃,并且可以為一些react/angular 項目npm build
占用高達16G的內存。
解決方法
如果您不想花錢打開更大的 VM(實例),這是解決方法:
在您的機器中構建映像。
將構建的鏡像復制到 ec2 實例。
運行 ec2 實例中的圖像。
在你的筆記本電腦中
# build it
docker build -t frontend:v1.0 -f react.Dockerfile .
# save the image as simple file
docker save frontend:v1.0 | gzip > frontend.tar.gz
# copy the file to your ec2 machine
scp frontend.tar.gz [email protected]:/tmp
在您的 ec2 實例中
# load the simple file into an image
docker load < /tmp/frontend.tar.gz
# validate that the image is loaded
docker images
不能幫助更多!祝你好運
添加回答
舉報