blob: 6b59279f963cdae42d1acbd5de82d0deb8aede23 [file] [log] [blame]
# Copyright 2016 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Remember to uprev the alpine in py/umpire/server/e2e_test/Dockerfile too.
FROM alpine:3.17
LABEL maintainer="ChromeOS Factory Eng <chromeos-factory-eng@google.com>"
# need to explicitly assign PYTHONPATH for uwsgi
ENV PYTHONPATH="/usr/local/factory/py_pkg"
ARG server_dir="/usr/local/factory"
ARG dome_dir="${server_dir}/py/dome"
ARG instalog_dir="${server_dir}/py/instalog"
ARG umpire_dir="${server_dir}/py/umpire"
ARG umpire_dir_in_dome
ARG overlord_output_file="overlord.tar.gz"
ARG dome_builder_output_file="frontend.tar"
# add docker client -- do not install docker via apk -- it will try to install
# docker engine which takes a lot of space as well (we don't need it, we need
# only the small client to communicate with the host's docker server)
ADD build/docker/docker.tgz /
RUN cp /docker/* /usr/bin/
# Install packages. Python packages should be installed by pip if possible.
# However, uwsgi-python and psutil from pip needs to build from source, Twisted
# has package signing problem, so we will install them using apk.
#
# pigz, py-pip, py-twisted, py-yaml, python, tar: Used by Umpire
# py-lxml: Used by zeep (SOAP), indirectly imported by Umpire
# (buzybox tar doesn't support -I, which is used in file_utils.ExtractFile)
# gnupg, python-gnupg: Used by umpire/server/service/dkps and archiver
#
# gcompat: Used by adb, because adb uses glibc and alpine does not.
#
# rsync: Used by umpire/server/service/rsync
# curl, jq: Used by cros_payload.
#
# nginx, uwsgi-python, dnsmasq: Used by Dome.
#
# apache2-utils, openssl: Used by Overlord setup.sh
#
# util-linux: For GNU mount since busybox mount doesn't support offset.
# coreutils: For GNU mktemp since busybox mktemp doesn't support --tmpdir.
#
# py-psutil: Dependencies for Python package gnupg that is used by Instalog.
#
# bash: Used by Dome, for Dome auto version check.
RUN apk upgrade --no-cache && apk add --no-cache \
apache2-utils \
bash \
coreutils \
curl \
dnsmasq \
file \
gcompat \
gnupg \
jq \
nginx \
openssl \
pigz \
py3-lxml \
py3-pip \
py3-psutil \
py3-twisted \
python3 \
rsync \
tar \
unzip \
util-linux \
uwsgi-python3 \
xz
# The latest cffi (1.14.3) would always build from source, which requires the
# follow packages.
# TODO(b/169730131): revert this when we can install prebuilt cffi again.
RUN apk add --no-cache \
build-base \
python3-dev \
libffi-dev
# Install java
RUN apk add openjdk17
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk
ENV PATH="$PATH:$JAVA_HOME/bin"
# Download Android SDK and set PATH
# Reference: https://stackoverflow.com/questions/65262340
ENV ANDROID_HOME="/android-sdk"
ARG ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools"
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip && \
mkdir -p "$ANDROID_TOOLS" && \
unzip *.zip -d "$ANDROID_TOOLS" && \
mv "$ANDROID_TOOLS/cmdline-tools" "$ANDROID_TOOLS/latest" && \
rm *.zip
ENV PATH="$PATH:$ANDROID_TOOLS/latest/bin"
# Install platform-tools
RUN yes | sdkmanager "platform-tools"
ENV PATH="$PATH:$ANDROID_HOME/platform-tools"
RUN adb version
# Install build-tools
RUN yes | sdkmanager "build-tools;35.0.0"
ENV PATH="$PATH:$ANDROID_HOME/build-tools/35.0.0"
RUN aapt version
# pixz and lbzip2 are not available in alpine.
ADD build/docker/pixz.tbz2 /usr/bin
ADD build/docker/lbzip2.tbz2 /usr/bin
# Add self-built UFTP binary
ADD build/docker/uftp.tgz /usr/bin
# Prepare requirements file and install pip packages.
COPY py/umpire/server/requirements.txt "${umpire_dir}/"
COPY py/umpire/server/docker-base-tooling.requirement.txt "${umpire_dir}/"
COPY py/dome/requirements.txt "${dome_dir}/"
COPY py/instalog/requirements_for_docker.txt "${instalog_dir}/"
RUN pip3 install --no-cache-dir \
-r "${umpire_dir}/docker-base-tooling.requirement.txt" \
--require-hashes
RUN pip3 install --no-cache-dir \
-r "${umpire_dir}/requirements.txt" \
-r "${dome_dir}/requirements.txt" \
-r "${instalog_dir}/requirements_for_docker.txt" \
--require-hashes
# Create Umpire mount point. Normally we should mount this (and Docker will
# create it for us) when calling the run command, but that's not the case for
# unit tests. Not creating this directory may cause unit tests to fail.
RUN mkdir -p "${umpire_dir_in_dome}"
RUN ln -s "${server_dir}/bin/umpire" /usr/local/bin/
RUN ln -s "${instalog_dir}/cli.py" /usr/bin/instalog
# these files are unlikely to change often, put them here to take advantage of
# docker's cache
COPY py/dome/nginx.conf /etc/nginx/
ADD "build/docker/${overlord_output_file}" "${server_dir}/bin/"
# these files are likely to change often, put them at the end
ADD "build/docker/${dome_builder_output_file}" "${dome_dir}/static/"
COPY py_pkg "${server_dir}/py_pkg"
COPY bin "${server_dir}/bin"
COPY sh "${server_dir}/sh"
COPY py "${server_dir}/py"
# Generate protobuf bindings
RUN python -m grpc_tools.protoc -I/usr/local/factory/py_pkg \
--python_out=/usr/local/factory/py_pkg \
--pyi_out=/usr/local/factory/py_pkg \
--grpc_python_out=/usr/local/factory/py_pkg \
cros/factory/umpire/server/proto/shop_floor.proto \
cros/factory/umpire/server/proto/umpire_dut_commands.proto
# These arguments change every time and ARG instructions will affect all
# following RUN instructions. We should put them in the end of Dockerfile to
# avoid making Docker cache mechanism useless.
ARG docker_image_githash
ARG docker_image_islocal
ARG docker_image_timestamp
ARG resource_cros_docker_url
ENV DOCKER_IMAGE_GITHASH="${docker_image_githash}"
ENV DOCKER_IMAGE_ISLOCAL="${docker_image_islocal}"
ENV DOCKER_IMAGE_TIMESTAMP="${docker_image_timestamp}"
ENV RESOURCE_CROS_DOCKER_URL="${resource_cros_docker_url}"
ENV IN_CROS_FACTORY_SERVER_CONTAINER=1