skia2/docker/skia-wasm-release/Dockerfile
Kevin Lubick 157577b866 [canvaskit,pathkit] Update to emsdk 2.0
There was a break that was solved by adding -lGL to our link
steps. I discovered a few extra flags to aid in debugging builds
and I've left those in (they aren't too noisy IMO).

This changes the base dockerfile to use the official emscripten one.

Code size delta for full build is +5 kb

For future reference, emsdk decides which "library JS" files to
pull in using a83ba99d60/tools/building.py (L1553)
Those JS files live in src (e.g. a83ba99d60/src/library_html5_webgl.js (L222))
and define functions that the C++ code can call.

I'd like to follow-up on what -lEGL is doing.

Also, since the new image no longer has depot_tools, we need
to make docker/skia-wasm-release/Dockerfile install it.

Change-Id: I5a38e61e5080e9c4cb1e0a7e031509bcb107ff86
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311726
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-08-20 14:55:50 +00:00

73 lines
2.3 KiB
Docker

# Dockerfile for building the WASM libraries used by jsfiddle.skia.org and debugger.skia.org
FROM gcr.io/skia-public/emsdk-base:prod as builder
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
git \
libfreetype6-dev
RUN cd /tmp \
&& git clone --depth 1 'https://chromium.googlesource.com/chromium/tools/depot_tools.git'
ENV PATH=${PATH}:/tmp/depot_tools
# Checkout Skia using fetch from depot_tools
RUN mkdir -p /tmp/skia \
&& cd /tmp/skia \
&& fetch skia
# Set fake identity for git rebase. See thread in
# https://skia-review.googlesource.com/c/buildbot/+/286537/5/docker/Dockerfile#46
RUN cd /tmp/skia/skia \
&& git config user.email "skia@skia.org" \
&& git config user.name "Skia"
# HASH must be specified.
ARG HASH
RUN if [ -z "${HASH}" ] ; then echo "HASH must be specified as a --build-arg"; exit 1; fi
RUN cd /tmp/skia/skia \
&& git fetch \
&& git reset --hard ${HASH}
# If patch ref is specified then update the ref to patch in a CL.
ARG PATCH_REF
RUN if [ ! -z "${PATCH_REF}" ] ; then cd /tmp/skia/skia \
&& git fetch https://skia.googlesource.com/skia ${PATCH_REF} \
&& git checkout FETCH_HEAD \
&& git rebase ${HASH}; fi
RUN cd /tmp/skia/skia \
&& gclient sync \
&& ./bin/fetch-gn
# PathKit should be in /tmp/skia/skia/out/pathkit/
RUN /tmp/skia/skia/modules/pathkit/compile.sh
# CanvasKit should be in /tmp/skia/skia/out/canvaskit_wasm
RUN /tmp/skia/skia/modules/canvaskit/compile.sh
# Debugger should be in /tmp/skia/skia/out/debugger_wasm
RUN /tmp/skia/skia/experimental/wasm-skp-debugger/compile.sh
RUN cd /tmp/skia/skia && git rev-parse HEAD > /tmp/VERSION
#############################################################################
# Multi-stage build part 2, in which we only have the compiled results and
# a VERSION in /tmp
# See https://docs.docker.com/develop/develop-images/multistage-build/
#############################################################################
FROM alpine:latest
WORKDIR /tmp/
RUN mkdir /tmp/pathkit /tmp/canvaskit
COPY --from=builder /tmp/VERSION /tmp/VERSION
COPY --from=builder /tmp/skia/skia/out/pathkit/pathkit* /tmp/pathkit/
COPY --from=builder /tmp/skia/skia/out/canvaskit_wasm/canvaskit* /tmp/canvaskit/
COPY --from=builder /tmp/skia/skia/out/debugger_wasm/debugger* /tmp/debugger/