| ARG CIPD_ROOT="/cipd" |
| |
| # Keep the tag for base-cipd in sync with the tag used here for debian. |
| FROM debian:testing-slim AS base |
| RUN apt-get update && apt-get upgrade -y && apt-get install -y \ |
| adduser \ |
| ca-certificates \ |
| curl \ |
| && rm -rf /var/lib/apt/lists/* \ |
| && addgroup --gid 2000 skia \ |
| && adduser --uid 2000 --gid 2000 skia |
| USER skia:skia |
| |
| # Install the CIPD client by syncing depot_tools to the revision specified in |
| # DEPS and running the wrapper script. This process requires temporarily |
| # installing some packages that we prefer to obtain via CIPD. |
| FROM base AS install_cipd |
| USER root |
| RUN apt-get update && apt-get upgrade -y && apt-get install -y git curl python3-minimal |
| USER skia:skia |
| COPY ./tmp/DEPS /tmp/DEPS |
| RUN cat /tmp/DEPS | \ |
| grep "depot_tools.git" | grep -oP "[a-f0-9]{40}" > /tmp/depot_tools_rev \ |
| && cd $(mktemp -d) \ |
| && git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git \ |
| && cd depot_tools \ |
| && git reset --hard "$(cat /tmp/depot_tools_rev)" \ |
| && ./cipd --version \ |
| && cp ./.cipd_client /tmp/cipd |
| |
| # This stage brings us back to the base image, plus the CIPD binary. |
| FROM base AS cipd |
| USER root |
| COPY --from=install_cipd /tmp/cipd /usr/local/bin/cipd |
| USER skia:skia |
| |
| # Now install the desired packages. |
| FROM cipd AS install_pkgs |
| ARG CIPD_ROOT |
| ENV CIPD_ROOT=$CIPD_ROOT |
| USER root |
| RUN mkdir -p ${CIPD_ROOT} && chown skia:skia ${CIPD_ROOT} |
| USER skia |
| COPY ./tmp/cipd.ensure /tmp/cipd.ensure |
| ENV CIPD_CACHE_DIR="/tmp/.cipd_cache" |
| RUN cipd ensure -root=${CIPD_ROOT} -ensure-file /tmp/cipd.ensure |
| |
| # The final stage brings us back to the base image with the installed CIPD packages. |
| FROM base AS base-cipd |
| ARG CIPD_ROOT |
| ENV CIPD_ROOT=$CIPD_ROOT |
| COPY --from=install_pkgs ${CIPD_ROOT} ${CIPD_ROOT} |
| ENV PATH="${CIPD_ROOT}:${CIPD_ROOT}/cipd_bin_packages/gsutil:${CIPD_ROOT}/cipd_bin_packages:${CIPD_ROOT}/cipd_bin_packages/bin:${CIPD_ROOT}/cipd_bin_packages/cpython:${CIPD_ROOT}/cipd_bin_packages/cpython/bin:${CIPD_ROOT}/cipd_bin_packages/cpython3:${CIPD_ROOT}/cipd_bin_packages/cpython3/bin:${PATH}" |