Buildozer: Running buildozer in docker

Created on 8 Oct 2019  路  2Comments  路  Source: kivy/buildozer

I've built the buildozer app according to README

docker build --tag=buildozer .

docker run --volume "$(pwd)":/home/user/hostcwd buildozer --version

I ran this command in my project directory:

$ docker run --volume "$(pwd)":/home/user/hostcwd buildozer android debug

First time it downloaded all the SDKs, built a lot of dependencies and finally successfully built an apk file in pwd/bin, which is an easily expected behavior. I tried to build the same apk again with the same command line, expecting it to be reasonably fast, but it started the process of downloading SDKs again, which I aborted. What is the right way of running buildozer routinely the docker way?

I'm afraid, the README is a bit terse on docker. It'd be nice to tell explicitly where am I supposed to clone the buildozer which I intend to build with docker, where the big .buildozer should go, how to run buildozer correctly every time. Very close for me, but still no cigar. As I am not a docker expert I turned out to be unable to troubleshoot this minor nuisance.

Most helpful comment

I did it like this:

  • Build basic image:
$ cd
$ git clone https://github.com/kivy/buildozer
$ cd buildozer
$ docker build --tag=buildozer .
$ docker run --volume "$(pwd)":/home/user/hostcwd buildozer --version
  • Create a project:
[pong]$ docker run --volume "$(pwd)":/home/user/hostcwd buildozer init
  • Edit buildozer.spec:
android.accept_sdk_license = True
  • Build:
[pong]$ docker run --volume "$(pwd)":/home/user/hostcwd buildozer android debug
  • Check the containers:
$ docker ps -a
  • Commit the container where the successful build happened, like this:
$ docker commit angry_black tyrn/buildozer:propio
$ docker images

The resulting image is about 5GB.

  • Run it like this on any project:
$ docker run --volume "$(pwd)":/home/user/hostcwd tyrn/buildozer:propio android debug

Subsequent builds of the same project are fast. When I start yet another project, the first run still takes a lot of time: it builds about 1.2GB of local .buildozer directory from scratch. Is it by design, or is it my incompetence?

All 2 comments

Since you didn't rm your container, you can use docker start container_name to run it again, it'll still have everything it downloaded. You can use docker ps -a to ee all existing containers, the last column is their user friendly random name.

If you don't want to reuse containers, add --rm to the run command to automatically remove them, to avoid pile up to eat your disc space. And use more --volume options to save ~/.buildozer outside of the container and reuse it in next runs.

I did it like this:

  • Build basic image:
$ cd
$ git clone https://github.com/kivy/buildozer
$ cd buildozer
$ docker build --tag=buildozer .
$ docker run --volume "$(pwd)":/home/user/hostcwd buildozer --version
  • Create a project:
[pong]$ docker run --volume "$(pwd)":/home/user/hostcwd buildozer init
  • Edit buildozer.spec:
android.accept_sdk_license = True
  • Build:
[pong]$ docker run --volume "$(pwd)":/home/user/hostcwd buildozer android debug
  • Check the containers:
$ docker ps -a
  • Commit the container where the successful build happened, like this:
$ docker commit angry_black tyrn/buildozer:propio
$ docker images

The resulting image is about 5GB.

  • Run it like this on any project:
$ docker run --volume "$(pwd)":/home/user/hostcwd tyrn/buildozer:propio android debug

Subsequent builds of the same project are fast. When I start yet another project, the first run still takes a lot of time: it builds about 1.2GB of local .buildozer directory from scratch. Is it by design, or is it my incompetence?

Was this page helpful?
0 / 5 - 0 ratings