使用node容器构建vue项目并部署到指定目录

来源:赵克立博客 分类: Nodejs 标签:Vue发布时间:2021-01-17 19:51:24最后更新:2021-01-17 19:51:24浏览:513
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。o_0。
更新时间:
2021-01-17 19:51:24
温馨提示:
学无止境,技术类文章有它的时效性,请留意文章更新时间,如发现内容有误请留言指出,防止别人"踩坑",我会及时更新文章

执行node容器,挂载源码目录和npm缓存目录到容器,传入参数安装依赖包和构建命令,最后把构建成功的源码复制到指定的网站目录

docker run \
--rm \
--volume ~/.npm:/root/.npm \
--volume ~/dnmp/www/vue:/tmp \
node:12-alpine3.11 /bin/sh -c \
"\
npm install -g cnpm --registry=https://registry.npm.taobao.org \
&& cd /tmp/blogtool \
&& cnpm install \
&& cnpm run build \
"\
&& destPath=/root/****/www/static \
&& srcPath=/www/vue/dist \
&& mkdir -p $destPath \
&& rm -rf ${destPath}/* \
&& cp ${srcPath}/index.html ${destPath}/index.html \
&& cp -R ${srcPath}/vue/* ${destPath}/ \
&& echo 'copy success'

2101171610884279230683.png


微信号:kelicom QQ群:215861553 紧急求助须知
Win32/PHP/JS/Android/Python