Skip to content

Commit febf2de

Browse files
committed
feat(docker-images): support podman for build, push, pull
1 parent 98fb1ab commit febf2de

File tree

5 files changed

+62
-27
lines changed

5 files changed

+62
-27
lines changed

src/docker/itk-wasm-base/build.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
set -exo pipefail
44

55
script_dir="`cd $(dirname $0); pwd`"
6+
source "$script_dir/../oci_exe.sh"
7+
exe=$(ociExe)
68

79
TAG=$(date '+%Y%m%d')-$(git rev-parse --short HEAD)
810
VCS_REF=$(git rev-parse --short HEAD)
@@ -34,15 +36,15 @@ emscripten_debug_c_flags="-fno-lto -Wno-warn-absolute-paths"
3436
wasi_debug_ld_flags="-fno-lto -lwasi-emulated-process-clocks -lwasi-emulated-signal -lc-printscan-long-double"
3537
wasi_debug_c_flags="-fno-lto -D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL"
3638

37-
docker build -t itkwasm/emscripten-base:latest \
39+
$exe build -t itkwasm/emscripten-base:latest \
3840
--build-arg IMAGE=itkwasm/emscripten-base \
3941
--build-arg CMAKE_BUILD_TYPE=Release \
4042
--build-arg VCS_REF=${VCS_REF} \
4143
--build-arg VCS_URL=${VCS_URL} \
4244
--build-arg BUILD_DATE=${BUILD_DATE} \
4345
$script_dir $@
4446
if $version_tag; then
45-
docker build -t itkwasm/emscripten-base:${TAG} \
47+
$exe build -t itkwasm/emscripten-base:${TAG} \
4648
--build-arg IMAGE=itkwasm/emscripten-base \
4749
--build-arg CMAKE_BUILD_TYPE=Release \
4850
--build-arg VERSION=${TAG} \
@@ -53,7 +55,7 @@ if $version_tag; then
5355
fi
5456

5557
if $wasi; then
56-
docker build -t itkwasm/wasi-base:latest \
58+
$exe build -t itkwasm/wasi-base:latest \
5759
--build-arg IMAGE=itkwasm/wasi-base \
5860
--build-arg CMAKE_BUILD_TYPE=Release \
5961
--build-arg VCS_REF=${VCS_REF} \
@@ -64,7 +66,7 @@ if $wasi; then
6466
--build-arg CFLAGS="${wasi_c_flags}" \
6567
$script_dir $@
6668
if $version_tag; then
67-
docker build -t itkwasm/wasi-base:${TAG} \
69+
$exe build -t itkwasm/wasi-base:${TAG} \
6870
--build-arg IMAGE=itkwasm/wasi-base \
6971
--build-arg CMAKE_BUILD_TYPE=Release \
7072
--build-arg VERSION=${TAG} \
@@ -80,7 +82,7 @@ fi
8082

8183

8284
if $debug; then
83-
docker build -t itkwasm/emscripten-base:latest-debug \
85+
$exe build -t itkwasm/emscripten-base:latest-debug \
8486
--build-arg IMAGE=itkwasm/emscripten-base \
8587
--build-arg CMAKE_BUILD_TYPE=Debug \
8688
--build-arg USE_DCMTK=OFF \
@@ -91,7 +93,7 @@ if $debug; then
9193
--build-arg CFLAGS="${emscripten_debug_c_flags}" \
9294
$script_dir $@
9395
if $version_tag; then
94-
docker build -t itkwasm/emscripten-base:${TAG}-debug \
96+
$exe build -t itkwasm/emscripten-base:${TAG}-debug \
9597
--build-arg IMAGE=itkwasm/emscripten-base \
9698
--build-arg CMAKE_BUILD_TYPE=Debug \
9799
--build-arg USE_DCMTK=OFF \
@@ -104,7 +106,7 @@ if $debug; then
104106
$script_dir $@
105107
fi
106108
if $wasi; then
107-
docker build -t itkwasm/wasi-base:latest-debug \
109+
$exe build -t itkwasm/wasi-base:latest-debug \
108110
--build-arg IMAGE=itkwasm/wasi-base \
109111
--build-arg CMAKE_BUILD_TYPE=Debug \
110112
--build-arg VCS_REF=${VCS_REF} \
@@ -115,7 +117,7 @@ if $debug; then
115117
--build-arg CFLAGS="${wasi_debug_c_flags}" \
116118
$script_dir $@
117119
if $version_tag; then
118-
docker build -t itkwasm/wasi-base:${TAG}-debug \
120+
$exe build -t itkwasm/wasi-base:${TAG}-debug \
119121
--build-arg IMAGE=itkwasm/wasi-base \
120122
--build-arg CMAKE_BUILD_TYPE=Debug \
121123
--build-arg VERSION=${TAG} \

src/docker/itk-wasm/build.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
set -exo pipefail
44

55
script_dir="`cd $(dirname $0); pwd`"
6+
source "$script_dir/../oci_exe.sh"
7+
exe=$(ociExe)
68

79
cd $script_dir
810

@@ -34,15 +36,15 @@ for param; do
3436
done
3537
set -- "${newparams[@]}" # overwrites the original positional params
3638

37-
docker build -t itkwasm/emscripten:latest \
39+
$exe build -t itkwasm/emscripten:latest \
3840
--build-arg IMAGE=itkwasm/emscripten \
3941
--build-arg CMAKE_BUILD_TYPE=Release \
4042
--build-arg VCS_REF=${VCS_REF} \
4143
--build-arg VCS_URL=${VCS_URL} \
4244
--build-arg BUILD_DATE=${BUILD_DATE} \
4345
$script_dir $@
4446
if $version_tag; then
45-
docker build -t itkwasm/emscripten:${TAG} \
47+
$exe build -t itkwasm/emscripten:${TAG} \
4648
--build-arg IMAGE=itkwasm/emscripten \
4749
--build-arg CMAKE_BUILD_TYPE=Release \
4850
--build-arg VERSION=${TAG} \
@@ -53,7 +55,7 @@ if $version_tag; then
5355
fi
5456

5557
if $wasi; then
56-
docker build -t itkwasm/wasi:latest \
58+
$exe build -t itkwasm/wasi:latest \
5759
--build-arg IMAGE=itkwasm/wasi \
5860
--build-arg CMAKE_BUILD_TYPE=Release \
5961
--build-arg BASE_IMAGE=itkwasm/wasi-base \
@@ -62,7 +64,7 @@ if $wasi; then
6264
--build-arg BUILD_DATE=${BUILD_DATE} \
6365
$script_dir $@
6466
if $version_tag; then
65-
docker build -t itkwasm/wasi:${TAG} \
67+
$exe build -t itkwasm/wasi:${TAG} \
6668
--build-arg IMAGE=itkwasm/wasi \
6769
--build-arg CMAKE_BUILD_TYPE=Release \
6870
--build-arg VERSION=${TAG} \
@@ -76,7 +78,7 @@ if $wasi; then
7678
fi
7779

7880
if $debug; then
79-
docker build -t itkwasm/emscripten:latest-debug \
81+
$exe build -t itkwasm/emscripten:latest-debug \
8082
--build-arg IMAGE=itkwasm/emscripten \
8183
--build-arg CMAKE_BUILD_TYPE=Debug \
8284
--build-arg BASE_TAG=${TAG}-debug \
@@ -85,7 +87,7 @@ if $debug; then
8587
--build-arg BUILD_DATE=${BUILD_DATE} \
8688
$script_dir $@
8789
if $version_tag; then
88-
docker build -t itkwasm/emscripten:${TAG}-debug \
90+
$exe build -t itkwasm/emscripten:${TAG}-debug \
8991
--build-arg IMAGE=itkwasm/emscripten \
9092
--build-arg CMAKE_BUILD_TYPE=Debug \
9193
--build-arg VERSION=${TAG}-debug \
@@ -96,7 +98,7 @@ if $debug; then
9698
$script_dir $@
9799
fi
98100
if $wasi; then
99-
docker build -t itkwasm/wasi:latest-debug \
101+
$exe build -t itkwasm/wasi:latest-debug \
100102
--build-arg IMAGE=itkwasm/wasi \
101103
--build-arg CMAKE_BUILD_TYPE=Debug \
102104
--build-arg BASE_IMAGE=itkwasm/wasi-base \
@@ -106,7 +108,7 @@ if $debug; then
106108
--build-arg BUILD_DATE=${BUILD_DATE} \
107109
$script_dir $@
108110
if $version_tag; then
109-
docker build -t itkwasm/wasi:${TAG}-debug \
111+
$exe build -t itkwasm/wasi:${TAG}-debug \
110112
--build-arg IMAGE=itkwasm/wasi \
111113
--build-arg CMAKE_BUILD_TYPE=Debug \
112114
--build-arg VERSION=${TAG} \

src/docker/oci_exe.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function ociExe() {
2+
# Check for OCI_EXE environmental variable
3+
if [[ -n "$OCI_EXE" && -x "$OCI_EXE" ]]; then
4+
echo "$OCI_EXE"
5+
return
6+
fi
7+
8+
# Check for podman executable
9+
if which podman > /dev/null 2>&1; then
10+
echo "podman"
11+
return
12+
fi
13+
14+
# Check for docker executable
15+
if which docker > /dev/null 2>&1; then
16+
echo "docker"
17+
return
18+
fi
19+
20+
# If none of the above exist, return nothing
21+
echo "Could not find podman or docker executable" >&2
22+
exit 1
23+
}

src/docker/pull.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#!/usr/bin/env bash
22

3+
script_dir="`cd $(dirname $0); pwd`"
4+
source "$script_dir/oci_exe.sh"
5+
exe=$(ociExe)
6+
37
set -eo pipefail
48

5-
docker pull itkwasm/emscripten:latest
6-
docker pull itkwasm/emscripten:latest-debug
9+
$exe pull itkwasm/emscripten:latest
10+
$exe pull itkwasm/emscripten:latest-debug
711

8-
docker pull itkwasm/wasi:latest
9-
docker pull itkwasm/wasi:latest-debug
12+
$exe pull itkwasm/wasi:latest
13+
$exe pull itkwasm/wasi:latest-debug

src/docker/push.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env bash
22

3+
script_dir="`cd $(dirname $0); pwd`"
4+
source "$script_dir/oci_exe.sh"
5+
exe=$(ociExe)
6+
37
set -eo pipefail
48

59
debug=true
@@ -15,20 +19,20 @@ set -- "${newparams[@]}" # overwrites the original positional params
1519
TAG=$(date '+%Y%m%d')-$(git rev-parse --short HEAD)
1620

1721
if test ! -z ${DOCKERHUB_ITKWasm_PASSWORD+x}; then
18-
echo $DOCKERHUB_ITKWasm_PASSWORD | docker login --username "$DOCKERHUB_ITKWasm_USERNAME" --password-stdin
22+
echo $DOCKERHUB_ITKWasm_PASSWORD | $exe login --username "$DOCKERHUB_ITKWasm_USERNAME" --password-stdin
1923
fi
2024

2125
function push_image() {
2226
local image=$1
2327
local tag=$2
2428
local debug=$3
25-
docker push ${image}:${tag}
26-
docker tag ${image}:${tag} quay.io/${image}:${tag}
27-
docker push quay.io/${image}:${tag}
29+
$exe push ${image}:${tag}
30+
$exe tag ${image}:${tag} quay.io/${image}:${tag}
31+
$exe push quay.io/${image}:${tag}
2832
if $debug; then
29-
docker push ${image}:${tag}-debug
30-
docker tag ${image}:${tag}-debug quay.io/${image}:${tag}-debug
31-
docker push quay.io/${image}:${tag}-debug
33+
$exe push ${image}:${tag}-debug
34+
$exe tag ${image}:${tag}-debug quay.io/${image}:${tag}-debug
35+
$exe push quay.io/${image}:${tag}-debug
3236
fi
3337
}
3438

0 commit comments

Comments
 (0)