when execute `sparrow/4-docker/buildall run-only`, if caller script export env DOCKER_SKIP_REBUILD, then image already is exist, just exit build script, not rebuild container.
Signed-off-by: Liu Yinsi liuyinsi@163.com --- container/defconfig.rb | 6 ++++++ container/defconfig.sh | 9 +++++++++ 2 files changed, 15 insertions(+)
diff --git a/container/defconfig.rb b/container/defconfig.rb index f9b0824..820147a 100755 --- a/container/defconfig.rb +++ b/container/defconfig.rb @@ -47,3 +47,9 @@ def get_available_memory # take the middle value according to the system memory size. [1024, 30720, Math.sqrt(memtotal) * 1024].sort[1].to_i end + +def docker_skip_rebuild(tag) + return unless ENV.include? 'DOCKER_SKIP_REBUILD' + + exit 1 if system "docker image inspect #{tag} > /dev/null 2>&1" +end diff --git a/container/defconfig.sh b/container/defconfig.sh index 54e65b5..7612e2d 100755 --- a/container/defconfig.sh +++ b/container/defconfig.sh @@ -41,3 +41,12 @@ push_image() docker tag "$src_tag" "$dst_tag" docker push "$dst_tag" } + +docker_skip_rebuild() +{ + tag=$1 + [ $DOCKER_SKIP_REBUILD ] && { + docker image inspect $tag > /dev/null 2>&1 + [ "$?" == "0" ] && exit 1 + } +}
On Sun, Feb 07, 2021 at 07:05:06PM +0800, Liu Yinsi wrote:
when execute `sparrow/4-docker/buildall run-only`, if caller script export env DOCKER_SKIP_REBUILD, then image already is exist, just exit build script, not rebuild container.
Signed-off-by: Liu Yinsi liuyinsi@163.com
container/defconfig.rb | 6 ++++++ container/defconfig.sh | 9 +++++++++ 2 files changed, 15 insertions(+)
diff --git a/container/defconfig.rb b/container/defconfig.rb index f9b0824..820147a 100755 --- a/container/defconfig.rb +++ b/container/defconfig.rb @@ -47,3 +47,9 @@ def get_available_memory # take the middle value according to the system memory size. [1024, 30720, Math.sqrt(memtotal) * 1024].sort[1].to_i end
+def docker_skip_rebuild(tag)
- return unless ENV.include? 'DOCKER_SKIP_REBUILD'
- exit 1 if system "docker image inspect #{tag} > /dev/null 2>&1"
+end diff --git a/container/defconfig.sh b/container/defconfig.sh index 54e65b5..7612e2d 100755 --- a/container/defconfig.sh +++ b/container/defconfig.sh @@ -41,3 +41,12 @@ push_image() docker tag "$src_tag" "$dst_tag" docker push "$dst_tag" }
+docker_skip_rebuild() +{
- tag=$1
[ -z $DOCKER_SKIP_REBUILD ] && return docker image inspect $tag > /dev/null 2>&1 [ "$?" == "0" ] && exit 1
Thanks, Jihui
+}
2.23.0