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 43# PathKit should be in /tmp/skia/skia/out/pathkit/ 44RUN /tmp/skia/skia/modules/pathkit/compile.sh 45 46# CanvasKit should be in /tmp/skia/skia/out/canvaskit_wasm 47RUN /tmp/skia/skia/modules/canvaskit/compile.sh 48 49# Debugger should be in /tmp/skia/skia/out/debugger_wasm 50RUN /tmp/skia/skia/experimental/wasm-skp-debugger/compile.sh 51 52RUN cd /tmp/skia/skia && git rev-parse HEAD > /tmp/VERSION 53 54############################################################################# 55# Multi-stage build part 2, in which we only have the compiled results and 56# a VERSION in /tmp 57# See https://docs.docker.com/develop/develop-images/multistage-build/ 58############################################################################# 59 60FROM alpine:latest 61 62WORKDIR /tmp/ 63 64RUN mkdir /tmp/pathkit /tmp/canvaskit 65 66COPY --from=builder /tmp/VERSION /tmp/VERSION 67 68COPY --from=builder /tmp/skia/skia/out/pathkit/pathkit* /tmp/pathkit/ 69 70COPY --from=builder /tmp/skia/skia/out/canvaskit_wasm/canvaskit* /tmp/canvaskit/ 71 72COPY --from=builder /tmp/skia/skia/modules/canvaskit/npm_build/types/index.d.ts /tmp/canvaskit/canvaskit.d.ts 73 74COPY --from=builder /tmp/skia/skia/out/debugger_wasm/debugger* /tmp/debugger/ 75