|
| 1 | +# We build our DevContainer on MS' Typescript-Node Devcontainer |
| 2 | +# This gives us lots of standard stuff, and lets us layer a few custom things on top, like the Emscripten compiler, Puppeteer |
| 3 | + |
| 4 | +# -------------------------------------------------------------------- |
| 5 | +# BEGIN Standard MS Devcontainer for Typescript-Node |
| 6 | + |
| 7 | +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/typescript-node/.devcontainer/base.Dockerfile |
| 8 | +# [Choice] Node.js version: 14, 12, 10 |
| 9 | +ARG VARIANT="14-buster" |
| 10 | +FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT} |
| 11 | + |
| 12 | +# [Optional] Uncomment if you want to install an additional version of node using nvm |
| 13 | +# ARG EXTRA_NODE_VERSION=10 |
| 14 | +# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" |
| 15 | + |
| 16 | +# [Optional] Uncomment if you want to install more global node packages |
| 17 | +# RUN su node -c "npm install -g <your-package-list -here>" |
| 18 | + |
| 19 | +# END Standard MS Devcontainer for Typescript-Node |
| 20 | +# -------------------------------------------------------------------- |
| 21 | + |
| 22 | +# -------------------------------------------------------------------- |
| 23 | +# BEGIN EMSDK |
| 24 | +# Install EMSDK to /emsdk just like the EMSDK Dockerfile: https://github.com/emscripten-core/emsdk/blob/master/docker/Dockerfile |
| 25 | +ENV EMSDK /emsdk |
| 26 | +# We pin the EMSDK version rather than 'latest' so that everyone is using the same compiler version |
| 27 | +ENV EMSCRIPTEN_VERSION 3.1.20 |
| 28 | + |
| 29 | +RUN git clone https://github.com/emscripten-core/emsdk.git $EMSDK |
| 30 | + |
| 31 | +RUN echo "## Install Emscripten" \ |
| 32 | + && cd ${EMSDK} \ |
| 33 | + && ./emsdk install ${EMSCRIPTEN_VERSION} \ |
| 34 | + && echo "## Done" |
| 35 | + |
| 36 | +# Copied directly from https://github.com/emscripten-core/emsdk/blob/master/docker/Dockerfile |
| 37 | +RUN cd ${EMSDK} \ |
| 38 | + && echo "## Generate standard configuration" \ |
| 39 | + && ./emsdk activate ${EMSCRIPTEN_VERSION} \ |
| 40 | + && chmod 777 ${EMSDK}/upstream/emscripten \ |
| 41 | + && chmod -R 777 ${EMSDK}/upstream/emscripten/cache \ |
| 42 | + && echo "int main() { return 0; }" > hello.c \ |
| 43 | + && ${EMSDK}/upstream/emscripten/emcc -c hello.c \ |
| 44 | + && cat ${EMSDK}/upstream/emscripten/cache/sanity.txt \ |
| 45 | + && echo "## Done" |
| 46 | + |
| 47 | +ENV PATH $EMSDK:$EMSDK/upstream/emscripten/:$PATH |
| 48 | + |
| 49 | +# Cleanup Emscripten installation and strip some symbols |
| 50 | +# Copied directly from https://github.com/emscripten-core/emsdk/blob/master/docker/Dockerfile |
| 51 | +RUN echo "## Aggressive optimization: Remove debug symbols" \ |
| 52 | + && cd ${EMSDK} && . ./emsdk_env.sh \ |
| 53 | + # Remove debugging symbols from embedded node (extra 7MB) |
| 54 | + && strip -s `which node` \ |
| 55 | + # Tests consume ~80MB disc space |
| 56 | + && rm -fr ${EMSDK}/upstream/emscripten/tests \ |
| 57 | + # Fastcomp is not supported |
| 58 | + && rm -fr ${EMSDK}/upstream/fastcomp \ |
| 59 | + # strip out symbols from clang (~extra 50MB disc space) |
| 60 | + && find ${EMSDK}/upstream/bin -type f -exec strip -s {} + || true \ |
| 61 | + && echo "## Done" |
| 62 | + |
| 63 | +RUN echo ". /emsdk/emsdk_env.sh" >> /etc/bash.bashrc |
| 64 | +# We must set the EM_NODE_JS environment variable for a somewhat silly reason |
| 65 | +# We run our build scripts with `npm run`, which sets the NODE environment variable as it runs. |
| 66 | +# The EMSDK picks up on that environment variable and gives a deprecation warning: warning: honoring legacy environment variable `NODE`. Please switch to using `EM_NODE_JS` instead` |
| 67 | +# So, we are going to put this environment variable here explicitly to avoid the deprecation warning. |
| 68 | +RUN echo 'export EM_NODE_JS="$EMSDK_NODE"' >> /etc/bash.bashrc |
| 69 | + |
| 70 | +# END EMSDK |
| 71 | +# -------------------------------------------------------------------- |
| 72 | + |
| 73 | +# -------------------------------------------------------------------- |
| 74 | +# BEGIN PUPPETEER dependencies |
| 75 | +# Here we install all of the packages depended upon by Chrome (that Puppeteer will use for headless tests). |
| 76 | +# We could also take a page from https://github.com/buildkite/docker-puppeteer/blob/master/Dockerfile instead, |
| 77 | +# and install the latest stable version of Chrome to get the right dependencies, but that version changes over time, |
| 78 | +# so the stable version of Chrome and the version installed by Puppeteer might diverge over time. |
| 79 | +# It also means they end up having Chrome downloaded and installed twice. |
| 80 | +# We could install the particular version of Chrome that our version of Puppeteer would use and then tell Puppeteer not to download its own version of Chrome, |
| 81 | +# but then we'd have to rebuild our Docker container every time we revved Puppeteer, and that feels fiddly too. |
| 82 | +# For all of these reasons, it seems safer to simply install the explicit list packages depended upon by Chrome, assume that's unlikely to change |
| 83 | +# and move on. |
| 84 | + |
| 85 | +# List taken from: |
| 86 | +# https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix |
| 87 | +RUN apt-get update \ |
| 88 | + && apt-get install -y \ |
| 89 | + ca-certificates \ |
| 90 | + fonts-liberation \ |
| 91 | + libappindicator3-1 \ |
| 92 | + libasound2 \ |
| 93 | + libatk-bridge2.0-0 \ |
| 94 | + libatk1.0-0 \ |
| 95 | + libc6 \ |
| 96 | + libcairo2 \ |
| 97 | + libcups2 \ |
| 98 | + libdbus-1-3 \ |
| 99 | + libexpat1 \ |
| 100 | + libfontconfig1 \ |
| 101 | + libgbm1 \ |
| 102 | + libgcc1 \ |
| 103 | + libglib2.0-0 \ |
| 104 | + libgtk-3-0 \ |
| 105 | + libnspr4 \ |
| 106 | + libnss3 \ |
| 107 | + libpango-1.0-0 \ |
| 108 | + libpangocairo-1.0-0 \ |
| 109 | + libstdc++6 \ |
| 110 | + libx11-6 \ |
| 111 | + libx11-xcb1 \ |
| 112 | + libxcb1 \ |
| 113 | + libxcomposite1 \ |
| 114 | + libxcursor1 \ |
| 115 | + libxdamage1 \ |
| 116 | + libxext6 \ |
| 117 | + libxfixes3 \ |
| 118 | + libxi6 \ |
| 119 | + libxrandr2 \ |
| 120 | + libxrender1 \ |
| 121 | + libxss1 \ |
| 122 | + libxtst6 \ |
| 123 | + lsb-release \ |
| 124 | + wget \ |
| 125 | + xdg-utils |
| 126 | + |
| 127 | +# Installs the command "sha3sum", which is used check the download integrity of sqlite source. |
| 128 | +RUN apt-get install -y libdigest-sha3-perl |
| 129 | + |
| 130 | +# We set this env variable (RUN_WORKER_TEST_WITHOUT_PUPPETEER_SANDBOX=1) this to tell our sql.js test harness to run Puppeteer without the sandbox. |
| 131 | +# Otherwise, when we instantiate Puppeteer, we get this error: |
| 132 | +# Puppeteer can't start due to a sandbox error. (Details follow.) |
| 133 | +# [0321/173044.694524:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox. |
| 134 | +ENV RUN_WORKER_TEST_WITHOUT_PUPPETEER_SANDBOX=1 |
| 135 | + |
| 136 | +# END PUPPETEER |
| 137 | +# -------------------------------------------------------------------- |
0 commit comments