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..1a655a3 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) + if ENV.include? 'DOCKER_SKIP_REBUILD' + exit 1 if system "docker image inspect #{tag} > /dev/null 2>&1" + end +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 Fri, Feb 05, 2021 at 02:56:41PM +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..1a655a3 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)
- if ENV.include? 'DOCKER_SKIP_REBUILD'
- exit 1 if system "docker image inspect #{tag} > /dev/null 2>&1"
- end
you should aviod nested 'if' structure, as follow:
return unless ENV.include? 'DOCKER_SKIP_REBUILD' exit 1 if system "docker image inspect #{tag} > /dev/null 2>&1"
Thanks, Liushaofei
+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
- }
+}
2.23.0
+def docker_skip_rebuild(tag)
- if ENV.include? 'DOCKER_SKIP_REBUILD'
- exit 1 if system "docker image inspect #{tag} > /dev/null 2>&1"
- end
you should aviod nested 'if' structure, as follow:
return unless ENV.include? 'DOCKER_SKIP_REBUILD' exit 1 if system "docker image inspect #{tag} > /dev/null 2>&1"
good
Thanks, Yinsi
Thanks, Liushaofei
+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
- }
+}
2.23.0