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# Checkout Skia using fetch from depot_tools 14RUN mkdir -p /tmp/skia \ 15 && cd /tmp/skia \ 16 && fetch skia 17 18# Set fake identity for git rebase. See thread in 19# https://skia-review.googlesource.com/c/buildbot/+/286537/5/docker/Dockerfile#46 20RUN cd /tmp/skia/skia \ 21 && git config user.email "skia@skia.org" \ 22 && git config user.name "Skia" 23 24# HASH must be specified. 25ARG HASH 26RUN if [ -z "${HASH}" ] ; then echo "HASH must be specified as a --build-arg"; exit 1; fi 27 28RUN cd /tmp/skia/skia \ 29 && git fetch \ 30 && git reset --hard ${HASH} 31 32# If patch ref is specified then update the ref to patch in a CL. 33ARG PATCH_REF 34RUN if [ ! -z "${PATCH_REF}" ] ; then cd /tmp/skia/skia \ 35 && git fetch https://skia.googlesource.com/skia ${PATCH_REF} \ 36 && git checkout FETCH_HEAD \ 37 && git rebase ${HASH}; fi 38 39RUN cd /tmp/skia/skia \ 40 && gclient sync \ 41 && ./bin/fetch-gn \ 42 && ./bin/activate-emsdk 43 44# PathKit should be in /tmp/skia/skia/out/pathkit/ 45RUN /tmp/skia/skia/modules/pathkit/compile.sh 46 47# CanvasKit should be in /tmp/skia/skia/out/canvaskit_wasm 48RUN /tmp/skia/skia/modules/canvaskit/compile.sh 49 50# Debugger should be in /tmp/skia/skia/out/debugger_wasm 51RUN /tmp/skia/skia/experimental/wasm-skp-debugger/compile.sh 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 75COPY --from=builder /tmp/skia/skia/out/debugger_wasm/debugger* /tmp/debugger/ 76