Mercurial
comparison third_party/emsdk/docker/Dockerfile @ 179:8d17f6e6e290
[ThirdParty] Added emsdk bazel rules that can be supported by bazel 9.0.0
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Thu, 22 Jan 2026 21:23:17 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 178:94705b5986b3 | 179:8d17f6e6e290 |
|---|---|
| 1 FROM ubuntu:jammy AS stage_build | |
| 2 | |
| 3 ARG EMSCRIPTEN_VERSION=tot | |
| 4 ENV EMSDK /emsdk | |
| 5 | |
| 6 # ------------------------------------------------------------------------------ | |
| 7 | |
| 8 RUN echo "## Start building" \ | |
| 9 && echo "## Update and install packages" \ | |
| 10 && apt-get -qq -y update \ | |
| 11 && apt-get -qq install -y --no-install-recommends \ | |
| 12 binutils \ | |
| 13 build-essential \ | |
| 14 ca-certificates \ | |
| 15 file \ | |
| 16 git \ | |
| 17 python3 \ | |
| 18 python3-pip \ | |
| 19 && echo "## Done" | |
| 20 | |
| 21 # Copy the contents of this repository to the container | |
| 22 COPY . ${EMSDK} | |
| 23 | |
| 24 RUN echo "## Install Emscripten" \ | |
| 25 && cd ${EMSDK} \ | |
| 26 && ./emsdk install ${EMSCRIPTEN_VERSION} \ | |
| 27 && echo "## Done" | |
| 28 | |
| 29 # This generates configuration that contains all valid paths according to installed SDK | |
| 30 # TODO(sbc): We should be able to use just emcc -v here but it doesn't | |
| 31 # currently create the sanity file. | |
| 32 RUN cd ${EMSDK} \ | |
| 33 && echo "## Generate standard configuration" \ | |
| 34 && ./emsdk activate ${EMSCRIPTEN_VERSION} \ | |
| 35 && chmod 777 ${EMSDK}/upstream/emscripten \ | |
| 36 && chmod -R 777 ${EMSDK}/upstream/emscripten/cache \ | |
| 37 && echo "int main() { return 0; }" > hello.c \ | |
| 38 && ${EMSDK}/upstream/emscripten/emcc -c hello.c \ | |
| 39 && cat ${EMSDK}/upstream/emscripten/cache/sanity.txt \ | |
| 40 && echo "## Done" | |
| 41 | |
| 42 # Cleanup Emscripten installation and strip some symbols | |
| 43 RUN echo "## Aggressive optimization: Remove debug symbols" \ | |
| 44 && cd ${EMSDK} && . ./emsdk_env.sh \ | |
| 45 # Remove debugging symbols from embedded node (extra 7MB) | |
| 46 && strip -s `which node` \ | |
| 47 # Tests consume ~80MB disc space | |
| 48 && rm -fr ${EMSDK}/upstream/emscripten/tests \ | |
| 49 # strip out symbols from clang (~extra 50MB disc space) | |
| 50 && find ${EMSDK}/upstream/bin -type f -exec strip -s {} + || true \ | |
| 51 && echo "## Done" | |
| 52 | |
| 53 # ------------------------------------------------------------------------------ | |
| 54 # -------------------------------- STAGE DEPLOY -------------------------------- | |
| 55 # ------------------------------------------------------------------------------ | |
| 56 | |
| 57 FROM ubuntu:jammy AS stage_deploy | |
| 58 | |
| 59 COPY --from=stage_build /emsdk /emsdk | |
| 60 | |
| 61 # These fallback environment variables are intended for situations where the | |
| 62 # entrypoint is not utilized (as in a derived image) or overridden (e.g. when | |
| 63 # using `--entrypoint /bin/bash` in CLI). | |
| 64 # This corresponds to the env variables set during: `source ./emsdk_env.sh` | |
| 65 ENV EMSDK=/emsdk \ | |
| 66 PATH="/emsdk:/emsdk/upstream/emscripten:/emsdk/node/22.16.0_64bit/bin:${PATH}" | |
| 67 | |
| 68 # ------------------------------------------------------------------------------ | |
| 69 # Create a 'standard` 1000:1000 user | |
| 70 # Thanks to that this image can be executed as non-root user and created files | |
| 71 # will not require root access level on host machine Please note that this | |
| 72 # solution even if widely spread (i.e. Node.js uses it) is far from perfect as | |
| 73 # user 1000:1000 might not exist on host machine, and in this case running any | |
| 74 # docker image will cause other random problems (mostly due `$HOME` pointing to | |
| 75 # `/`) | |
| 76 RUN echo "## Create emscripten user (1000:1000)" \ | |
| 77 && groupadd --gid 1000 emscripten \ | |
| 78 && useradd --uid 1000 --gid emscripten --shell /bin/bash --create-home emscripten \ | |
| 79 && echo "## Done" | |
| 80 | |
| 81 # ------------------------------------------------------------------------------ | |
| 82 | |
| 83 RUN echo "## Update and install packages" \ | |
| 84 && apt-get -qq -y update \ | |
| 85 # Somewhere in here apt sets up tzdata which asks for your time zone and blocks | |
| 86 # waiting for the answer which you can't give as docker build doesn't read from | |
| 87 # the terminal. The env vars set here avoid the interactive prompt and set the TZ. | |
| 88 && DEBIAN_FRONTEND="noninteractive" TZ="America/San_Francisco" apt-get -qq install -y --no-install-recommends \ | |
| 89 sudo \ | |
| 90 libxml2 \ | |
| 91 ca-certificates \ | |
| 92 python3 \ | |
| 93 python3-pip \ | |
| 94 wget \ | |
| 95 curl \ | |
| 96 zip \ | |
| 97 unzip \ | |
| 98 git \ | |
| 99 git-lfs \ | |
| 100 ssh-client \ | |
| 101 build-essential \ | |
| 102 make \ | |
| 103 ant \ | |
| 104 libidn12 \ | |
| 105 cmake \ | |
| 106 openjdk-11-jre-headless \ | |
| 107 # Standard Cleanup on Debian images | |
| 108 && apt-get -y clean \ | |
| 109 && apt-get -y autoclean \ | |
| 110 && apt-get -y autoremove \ | |
| 111 && rm -rf /var/lib/apt/lists/* \ | |
| 112 && rm -rf /var/cache/debconf/*-old \ | |
| 113 && rm -rf /usr/share/doc/* \ | |
| 114 && rm -rf /usr/share/man/?? \ | |
| 115 && rm -rf /usr/share/man/??_* \ | |
| 116 && echo "## Done" | |
| 117 | |
| 118 # ------------------------------------------------------------------------------ | |
| 119 # Use commonly used /src as working directory | |
| 120 WORKDIR /src | |
| 121 | |
| 122 ENTRYPOINT ["/emsdk/docker/entrypoint.sh"] | |
| 123 | |
| 124 LABEL maintainer="[email protected]" \ | |
| 125 org.label-schema.name="emscripten" \ | |
| 126 org.label-schema.description="The official container with Emscripten SDK" \ | |
| 127 org.label-schema.url="https://emscripten.org" \ | |
| 128 org.label-schema.vcs-url="https://github.com/emscripten-core/emsdk" \ | |
| 129 org.label-schema.docker.dockerfile="/docker/Dockerfile" | |
| 130 | |
| 131 # ------------------------------------------------------------------------------ |