forked from occlum/occlum
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_image.sh
More file actions
executable file
·57 lines (48 loc) · 1.46 KB
/
build_image.sh
File metadata and controls
executable file
·57 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
scripts_dir=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
top_dir=$(dirname "${scripts_dir}")
registry="$(whoami)"
tag="latest"
function usage {
cat << EOM
usage: $(basename "$0") [OPTION]...
-i <occlum package> the occlum instance tar package after doing "occlum package"
-r <registry prefix> the prefix string for registry
-n <container image name>
-g <tag> container image tag
-h <usage> usage help
EOM
exit 0
}
function process_args {
while getopts ":i:r:n:g:h" option; do
case "${option}" in
i) package=${OPTARG};;
r) registry=${OPTARG};;
n) name=${OPTARG};;
g) tag=${OPTARG};;
h) usage;;
esac
done
if [[ "${package}" == "" ]]; then
echo "Error: Please specify your occlum instance package via -i <occlum package>."
exit 1
fi
if [[ "${name}" == "" ]]; then
echo "Error: Please specify your container image name via -n <container image name>."
exit 1
fi
}
function build_docker_occlum_image {
cd ${top_dir}
echo "Build docker Occlum image based on ${package} ..."
sudo -E docker build \
--network host \
--build-arg http_proxy=$http_proxy \
--build-arg https_proxy=$https_proxy \
--build-arg OCCLUM_PACKAGE=${package} \
-f container/Dockerfile_occlum_instance.ubuntu20.04 . \
-t ${registry}/${name}:${tag}
}
process_args "$@"
build_docker_occlum_image