Last active
November 7, 2019 14:43
-
-
Save NinoFocus/4530ede443068d812df05ae21f8aed64 to your computer and use it in GitHub Desktop.
将前端本地构建任务代理到docker上执行
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
# 依赖的node版本 | |
requiredNodeVersion="8.12.0" | |
# docker image | |
requiredImage="node:${requiredNodeVersion}" | |
# 本机已经安装的node images版本 | |
installedNodeImageVersions=`docker images node --format "{{json .Tag}}"` | |
if [[ $installedNodeImageVersions =~ $requiredNodeVersion ]] | |
then | |
echo "${*}" | |
else | |
echo "不存在镜像 ${requiredImage},启动下载..." | |
docker pull $requiredImage | |
fi | |
# 当前项目路径 | |
projectPath=`pwd` | |
# 执行命令 | |
docker run -it -v $projectPath:/project $requiredImage /bin/sh -c "cd /project && ${*}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
比如在项目目录下执行