Make container persistent and privileged

When the docker container is removed at the end of a build step only to
be re-created on the next one (even if we pass --reuse), the build
script has to install the rust toolchain to the continer's home
directory and download all the crates as part of the build process.
This takes time.

This patch makes the docker container persistent, which is to say that
when we call docker run on, it boots into systemd and acts more like a
traditional Linux system.  A non-root user account is created to run the
actual crosvm build.  A subsequent docker exec call logs into that
account and triggers the build script.  When the build is done, we pause
the container.

When we pass the --reuse option, we simply unpause the container and
re-run the build script, which has the benefit of accessing the cached
rust toolchain and crates in the container-build user's home directory.

A down side of this approach is that the docker container is now
privileged.

The default of not passing --reuse still builds and creates the
container from scratch.

Bug: b/148642775 Clean up the crosvm build
Test: built for gce, arm, docker

Change-Id: I07cc4332b079707ed3f795d294bbdf94b0902b9c
Signed-off-by: Iliyan Malchev <malchev@google.com>
3 files changed