Skip to content

Commit 280c112

Browse files
committed
container/image-builder.sh supports to build podman image
1 parent e32bacd commit 280c112

File tree

4 files changed

+65
-28
lines changed

4 files changed

+65
-28
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ The following script can be used to build a host image for Google Compute Engine
7373
[Check out the AOSP tree](https://source.android.com/setup/build/downloading)
7474
to obtain the script.
7575

76-
## Docker
76+
## Container images
7777

78-
Please read [container/README.md](container/README.md) to know how to use docker image
79-
containing Cuttlefish debian packages.
78+
Please read [container/README.md](container/README.md) to know how to build and
79+
use docker or podman image containing Cuttlefish debian packages.

container/Containerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Docker image for running CF instances in the server.
2-
# Docker image includes HO(Host Orchestrator) inside,
1+
# Container image for running CF instances in the server.
2+
# Container image includes HO(Host Orchestrator) inside,
33
# so it could execute CF instance with API in HO.
44

55
ARG BUILD_OPTION=prod

container/README.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Docker
1+
# Container images
22

3-
We provide docker images with installed cuttlefish debian packages inside;
3+
We provide container images with installed cuttlefish debian packages inside;
44
including `cuttlefish-base`, `cuttlefish-user`, and `cuttlefish-orchestration`.
55
Currently it's available for x86_64 and ARM64 architectures.
66

@@ -18,19 +18,21 @@ docker pull us-docker.pkg.dev/android-cuttlefish-artifacts/cuttlefish-orchestrat
1818
Please refer to
1919
[Cloud Orchestrator documentation for on-premise server](https://github.com/google/cloud-android-orchestration/blob/main/scripts/on-premises/single-server/README.md).
2020

21-
## Build docker image manually
21+
## Build container image manually
2222

23-
To build docker image, building host debian packages for docker image is
24-
required. Please refer to
23+
To build container image, building host debian packages is required in
24+
advance.
25+
Please refer to
2526
[tools/buildutils/cw/README.md](../tools/buildutils/cw/README.md) for building
2627
host debian packages including `base` and `frontend`.
2728

28-
After retrieving host debian packages, please run below command to build
29-
manually.
29+
### Docker
30+
31+
Please run below command to build docker image manually.
3032

3133
```bash
3234
cd /path/to/android-cuttlefish
33-
container/image-builder.sh -m dev
35+
container/image-builder.sh -m dev -c docker
3436
```
3537

3638
You can validate if the docker image is successfully built by checking
@@ -41,3 +43,21 @@ REPOSITORY TAG IMAGE ID CREATED SIZE
4143
cuttlefish-orchestration latest 0123456789ab 2 minutes ago 690MB
4244
...
4345
```
46+
47+
### Podman
48+
49+
Please run below command to build podman image manually.
50+
51+
```bash
52+
cd /path/to/android-cuttlefish
53+
sudo container/image-builder.sh -m dev -c podman
54+
```
55+
56+
You can validate if the podman image is successfully built by checking
57+
`cuttlefish-orchestration` in `sudo podman image list` like below.
58+
```
59+
$ sudo podman image list
60+
REPOSITORY TAG IMAGE ID CREATED SIZE
61+
localhost/cuttlefish-orchestration latest b5870005843b 39 minutes ago 1.12 GB
62+
...
63+
```

container/image-builder.sh

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
#!/usr/bin/env bash
22

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,
55
# so it could execute CF instance with API in HO.
66

77
script_location=`realpath -s $(dirname ${BASH_SOURCE[0]})`
88
android_cuttlefish_root_dir=$(realpath -s $script_location/..)
99

1010
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)"
1313
echo " -m: set mode for build image (default: stable)"
1414
echo " stable - Downloads and installs host packages from stable channel"
1515
echo " unstable - Downloads and installs host packages from unstable channel"
1616
echo " nightly - Downloads and installs host packages from nightly channel"
1717
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"
1820
}
1921

2022
name=cuttlefish-orchestration
2123
mode=stable
22-
while getopts ":hm:t:" opt; do
24+
container_type=docker
25+
while getopts ":hm:t:c:" opt; do
2326
case "${opt}" in
2427
h)
2528
usage
2629
exit 0
2730
;;
31+
c)
32+
container_type="${OPTARG}"
33+
;;
2834
m)
2935
mode="${OPTARG}"
3036
;;
@@ -67,15 +73,26 @@ case "${mode}" in
6773
exit 1
6874
esac
6975

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+
7188
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+
.
8198
popd

0 commit comments

Comments
 (0)