builder-webassembly/Dockerfile.emscripten

28 lines
1.1 KiB
Docker

# SPDX-FileCopyrightText: 2024 Daniel Wolf <nephatrine@gmail.com>
#
# SPDX-License-Identifier: ISC
# hadolint ignore=DL3007
FROM code.nephatrine.net/nephnet/nxb-debian:latest
LABEL maintainer="Daniel Wolf <nephatrine@gmail.com>"
ENV EMSCRIPTEN_PATH=/opt/emsdk
ARG EMSCRIPTEN_VERSION=3.1.56
RUN git -C /opt clone -b "$EMSCRIPTEN_VERSION" --single-branch --depth=1 https://github.com/emscripten-core/emsdk.git
WORKDIR /opt/emsdk
# hadolint ignore=SC1091
RUN ./emsdk install "${EMSCRIPTEN_VERSION}" --shallow --generator=Ninja \
&& ./emsdk activate "${EMSCRIPTEN_VERSION}" \
&& . ./emsdk_env.sh \
&& embuilder build SYSTEM --pic --lto \
&& rm -rf /tmp/* /var/tmp/*
ENV PATH=${EMSCRIPTEN_PATH}:${EMSCRIPTEN_PATH}/upstream/emscripten:$PATH
COPY override/usr/local/bin/nxbuild-emscripten /usr/local/bin/
# hadolint ignore=DL3003
RUN git -C "${HOME}" clone --single-branch --depth=1 https://code.nephatrine.net/nephatrine/hello-test.git \
&& mkdir /tmp/build-emscripten && cd /tmp/build-emscripten \
&& nxbuild-emscripten -GNinja "${HOME}/hello-test" \
&& ninja && node HelloTest \
&& cd .. && rm -rf /tmp/* /var/tmp/* "${HOME}/hello-test"