1# Dockerfile for building the WASM libraries used by jsfiddle.skia.org and debugger.skia.org 2FROM gcr.io/skia-public/emsdk-base:prod as builder 3 4RUN apt-get update && apt-get upgrade -y && apt-get install -y \ 5 git \ 6 libfreetype6-dev 7 8RUN cd /tmp \ 9 && git clone --depth 1 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' 10 11ENV PATH=${PATH}:/tmp/depot_tools 12 13# See skbug.com/13128 14ENV DEPOT_TOOLS_UPDATE=0 15# Checkout Skia using fetch from depot_tools 16RUN mkdir -p /tmp/skia \ 17 && cd /tmp/skia \ 18 && fetch skia 19 20# Set fake identity for git rebase. See thread in 21# https://skia-review.googlesource.com/c/buildbot/+/286537/5/docker/Dockerfile#46 22RUN cd /tmp/skia/skia \ 23 && git config user.email "[email protected]" \ 24 && git config user.name "Skia" 25 26# HASH must be specified. 27ARG HASH 28RUN if [ -z "${HASH}" ] ; then echo "HASH must be specified as a --build-arg"; exit 1; fi 29 30RUN cd /tmp/skia/skia \ 31 && git fetch \ 32 && git reset --hard ${HASH} 33 34# If patch ref is specified then update the ref to patch in a CL. 35ARG PATCH_REF 36RUN if [ ! -z "${PATCH_REF}" ] ; then cd /tmp/skia/skia \ 37 && git fetch https://skia.googlesource.com/skia ${PATCH_REF} \ 38 && git checkout FETCH_HEAD \ 39 && git rebase ${HASH}; fi 40 41RUN cd /tmp/skia/skia \ 42 && gclient sync \ 43 && ./bin/fetch-gn \ 44 && ./bin/activate-emsdk 45 46# PathKit should be in /tmp/skia/skia/out/pathkit/ 47RUN /tmp/skia/skia/modules/pathkit/compile.sh 48 49# CanvasKit should be in /tmp/skia/skia/out/canvaskit_wasm 50# We also want to include the debugger bindings to run debugger.skia.org 51RUN /tmp/skia/skia/modules/canvaskit/compile.sh enable_debugger 52 53RUN cd /tmp/skia/skia && git rev-parse HEAD > /tmp/VERSION 54 55############################################################################# 56# Multi-stage build part 2, in which we only have the compiled results and 57# a VERSION in /tmp 58# See https://docs.docker.com/develop/develop-images/multistage-build/ 59############################################################################# 60 61FROM alpine:latest 62 63WORKDIR /tmp/ 64 65RUN mkdir /tmp/pathkit /tmp/canvaskit 66 67COPY --from=builder /tmp/VERSION /tmp/VERSION 68 69COPY --from=builder /tmp/skia/skia/out/pathkit/pathkit* /tmp/pathkit/ 70 71COPY --from=builder /tmp/skia/skia/out/canvaskit_wasm/canvaskit* /tmp/canvaskit/ 72 73COPY --from=builder /tmp/skia/skia/modules/canvaskit/npm_build/types/index.d.ts /tmp/canvaskit/canvaskit.d.ts 74