Skip to content

emu/containers: return emulator ID if image is not available locally #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Given an emulator zip file and a system image zip file, we can build a directory
that can be sent to `docker build` via the following invocation of `emu-docker`:

emu-docker create <emulator-zip> <system-image-zip> [--dest docker-src-dir
(getcwd()/src by default)]
(getcwd()/bld/emulator by default)]

This places all the right elements to run a docker image, but does not build,
run or publish yet. A Linux emulator zip file must be used.
Expand All @@ -195,7 +195,7 @@ run or publish yet. A Linux emulator zip file must be used.

To build the Docker image corresponding to these emulators and system images:

docker build <docker-src-dir, either ./src or specified argument to
docker build <docker-src-dir, either ./bld/emulator or specified argument to
emu_docker.py>

A Docker image ID will output; save this image ID.
Expand Down
1 change: 1 addition & 0 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if [ "${BASH_SOURCE-}" = "$0" ]; then
exit 33
fi

# prefer <= python3.12 if available.
PYTHON=python3
VENV=.venv

Expand Down
15 changes: 12 additions & 3 deletions create_web_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,27 @@ generate_keys
# Copy the private adbkey over
cp ~/.android/adbkey js/docker/certs

# compose v1 (`docker-compose`) is no longer receiving updates,
# default to compose v2 (`docker compose`) if available.
if docker compose version >/dev/null 2>&1; then
DOCKER_COMPOSE="docker compose"
else
DOCKER_COMPOSE="docker-compose"
fi


# compose the container
python -m venv .docker-venv
source .docker-venv/bin/activate
pip install docker-compose
docker-compose -f ${DOCKER_YAML} build
$DOCKER_COMPOSE -f ${DOCKER_YAML} build
rm js/docker/certs/adbkey

if [ "${START}" = "yes" ]; then
docker-compose -f ${DOCKER_YAML} up
$DOCKER_COMPOSE -f ${DOCKER_YAML} up
else
echo "Created container, you can launch it as follows:"
echo "docker-compose -f ${DOCKER_YAML} up"
echo "$DOCKER_COMPOSE -f ${DOCKER_YAML} up"
fi

if [ "${INSTALL}" = "yes" ]; then
Expand Down
2 changes: 1 addition & 1 deletion emu/containers/docker_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def full_name(self) -> str:
if local:
return local.tags[0]

return ""
return self.image_name()

def latest_name(self):
if self.repo:
Expand Down
11 changes: 11 additions & 0 deletions emu/templates/Dockerfile.emulator
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
# limitations under the License.
FROM {{from_base_img}} AS emulator

RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
echo "deb http://mirrors.kernel.org/ubuntu/ focal main restricted universe multiverse" > /etc/apt/sources.list && \
echo "deb http://mirrors.kernel.org/ubuntu/ focal-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
echo "deb http://mirrors.kernel.org/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list && \
echo "deb http://mirrors.kernel.org/ubuntu/ focal-backports main restricted universe multiverse" >> /etc/apt/sources.list && \
echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries && \
echo 'Acquire::http::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries && \
echo 'Acquire::https::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries && \
apt-get update --fix-missing

# Install all the required emulator dependencies.
# You can get these by running ./android/scripts/unix/run_tests.sh --verbose --verbose --debs | grep apt | sort -u
# pulse audio is needed due to some webrtc dependencies.
Expand Down