|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -# This shell script exists for building docker image. |
4 | | -# Docker image includes HO(Host Orchestrator) inside, |
| 3 | +# This shell script exists for building container images. |
| 4 | +# Container image includes HO(Host Orchestrator) inside, |
5 | 5 | # so it could execute CF instance with API in HO. |
6 | 6 |
|
7 | 7 | script_location=`realpath -s $(dirname ${BASH_SOURCE[0]})` |
8 | 8 | android_cuttlefish_root_dir=$(realpath -s $script_location/..) |
9 | 9 |
|
10 | 10 | usage() { |
11 | | - echo "usage: $0 [-t <tag>] [-m <mode>]" |
12 | | - echo " -t: name or name:tag of docker image (default cuttlefish-orchestration)" |
| 11 | + echo "usage: $0 [-t <tag>] [-m <mode>] [-c <container_type>]" |
| 12 | + echo " -t: name or name:tag of container image (default: cuttlefish-orchestration)" |
13 | 13 | echo " -m: set mode for build image (default: stable)" |
14 | 14 | echo " stable - Downloads and installs host packages from stable channel" |
15 | 15 | echo " unstable - Downloads and installs host packages from unstable channel" |
16 | 16 | echo " nightly - Downloads and installs host packages from nightly channel" |
17 | 17 | echo " dev - Use *.deb files under repo dir as prebuilt of host packages" |
| 18 | + echo " -c: type of container (default: docker)" |
| 19 | + echo " Available container type: docker, podman" |
18 | 20 | } |
19 | 21 |
|
20 | 22 | name=cuttlefish-orchestration |
21 | 23 | mode=stable |
22 | | -while getopts ":hm:t:" opt; do |
| 24 | +container_type=docker |
| 25 | +while getopts ":hm:t:c:" opt; do |
23 | 26 | case "${opt}" in |
24 | 27 | h) |
25 | 28 | usage |
26 | 29 | exit 0 |
27 | 30 | ;; |
| 31 | + c) |
| 32 | + container_type="${OPTARG}" |
| 33 | + ;; |
28 | 34 | m) |
29 | 35 | mode="${OPTARG}" |
30 | 36 | ;; |
@@ -67,15 +73,26 @@ case "${mode}" in |
67 | 73 | exit 1 |
68 | 74 | esac |
69 | 75 |
|
70 | | -# Build docker image |
| 76 | +case "${container_type}" in |
| 77 | + docker) |
| 78 | + DOCKER_BUILDKIT=1 |
| 79 | + ;; |
| 80 | + podman) |
| 81 | + ;; |
| 82 | + *) |
| 83 | + echo "Invalid container type: ${container type}" >&2 |
| 84 | + usage |
| 85 | + exit 1 |
| 86 | +esac |
| 87 | + |
71 | 88 | pushd $android_cuttlefish_root_dir |
72 | | -DOCKER_BUILDKIT=1 docker build \ |
73 | | - --force-rm \ |
74 | | - --no-cache \ |
75 | | - -f container/Containerfile \ |
76 | | - -t $name \ |
77 | | - --target runner \ |
78 | | - --build-arg BUILD_OPTION=$build_option \ |
79 | | - --build-arg REPO=$repo \ |
80 | | - . |
| 89 | +"${container_type}" build \ |
| 90 | + --force-rm \ |
| 91 | + --no-cache \ |
| 92 | + -f container/Containerfile \ |
| 93 | + -t "${name}" \ |
| 94 | + --target runner \ |
| 95 | + --build-arg "BUILD_OPTION=${build_option}" \ |
| 96 | + --build-arg "REPO=${repo}" \ |
| 97 | + . |
81 | 98 | popd |
0 commit comments