FROM node:lts
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 python3-dev python3-pip build-essential ca-certificates && \
ln -s /usr/bin/python3 /usr/bin/python && \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY package.json yarn.lock* ./
RUN npm install
COPY . .
RUN npm run build:all
EXPOSE 8080
CMD ["npm", "run", "server"]
node_modules dist .vm *.log *.tmp .DS_Store .git
Summary (under 1500 chars): - Failing command/step: - RUN npm run build:all (Dockerfile: line 18), during [7/7] build stage - Exact error message and exit code: - Exit code: 1 - Error: FileNotFoundError: [Errno 2] No such file or directory: 'emcc' - Docker build halt: "ERROR: failed to build: failed to solve: process \"/bin/sh -c npm run build:all\" did not complete successfully: exit code: 1" - Where it occurred (context): - npm run build:all triggers shader:wasm, which runs python src/shader/wasm/compile.py and attempts to execute emcc via subprocess.check_call(...) - Trace shows the file not found error for emcc during this subprocess call - Missing packages or files mentioned: - emcc binary not found (No such file or directory: 'emcc') - Implies Emscripten toolchain is not installed or not in PATH in the image - Version mismatch info: - None reported. The failure is due to a missing emcc binary, not a version conflict. The build uses node:lts-bookworm base image, but no version mismatch is indicated as the cause.
FROM node:lts
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 python3-dev python3-pip build-essential ca-certificates emscripten && \
ln -s /usr/bin/python3 /usr/bin/python && \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY package.json ./
RUN npm install
COPY . .
RUN npm run build:all
EXPOSE 8080
CMD ["npm", "run", "server"]
Smoke [FAIL]: curl -sS -o /dev/null -w '%{http_code}' http://localhost:8080/ | grep -q '^200$
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [PASS]: curl -sS http://localhost:8080/ | head -n 5
Smoke [PASS]: node -v# Stage 1: builder with emsdk to compile shaders (wasm) and build project
FROM node:lts as builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and Python for shader compilation and build
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-dev \
python3-pip \
git \
build-essential \
ca-certificates \
curl && \
rm -rf /var/lib/apt/lists/*
# Install Emscripten SDK to provide emcc for shader compilation
RUN mkdir -p /emsdk && \
git clone https://github.com/emscripten-core/emsdk.git /emsdk && \
cd /emsdk && \
./emsdk install latest && \
./emsdk activate latest
# Ensure emcc is in PATH during build
ENV PATH="/emsdk/upstream/emscripten:${PATH}"
WORKDIR /usr/src/app
# Copy package manifest and install dependencies
COPY package.json package.json
RUN npm install
# Copy the rest of the repository and build from source
COPY . .
RUN npm run build:all
# Stage 2: runtime image
FROM node:lts as runtime
WORKDIR /usr/src/app
# Copy built artifacts and package manifest for runtime use
COPY --from=builder /usr/src/app/dist /usr/src/app/dist
COPY --from=builder /usr/src/app/package.json /usr/src/app/package.json
# Expose a port for the example server
EXPOSE 8080
CMD ["npm", "run", "server"]
Concerns: Runtime stage does not install dependencies; there is no node_modules in /usr/src/app which will likely cause npm run server to fail at runtime., COPY --from=builder /usr/src/app/dist and package.json in the runtime stage is not sufficient; there is no npm install/npm ci in the runtime image or copying of node_modules, so production dependencies may be missing.
FROM node:lts as builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-dev \
python3-pip \
git \
build-essential \
ca-certificates \
curl \
emscripten && \
ln -s /usr/bin/python3 /usr/bin/python && \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY package.json yarn.lock* ./
RUN npm install
COPY . .
RUN npm run build:all
FROM node:lts
WORKDIR /usr/src/app
# Copy built artifacts and necessary assets
COPY --from=builder /usr/src/app/dist /usr/src/app/dist
COPY --from=builder /usr/src/app/package.json /usr/src/app/package.json
# Install runtime dependencies
RUN npm install --omit=dev
EXPOSE 8080
CMD ["node", "dist/index.js"]
- Failing step: [builder 7/7] RUN npm run build:all
- Exact error message and exit code:
- Error: error:0308010C:digital envelope routines::unsupported
- opensslErrorStack: [
'error:03000086:digital envelope routines::initialization error',
'error:0308010C:digital envelope routines::unsupported'
],
- library: 'digital envelope routines',
- reason: 'unsupported',
- code: 'ERR_OSSL_EVP_UNSUPPORTED'
- Node.js v24.14.0
- Exit code: 1
- Failing command/step context: npm run build:all invoked during the webpack build inside the final Docker stage
- Missing packages or files mentioned: None reported as missing; the log shows the OpenSSL/Node issue rather than a missing file or package
- Version/mismatch information:
- Node.js version in the build: v24.14.0
- Base image used: node:lts
- The error stems from an OpenSSL compatibility issue (ERR_OSSL_EVP_UNSUPPORTED) during webpack hashing, common when using newer Node/OpenSSL combinations with older webpack configurations.FROM node:lts AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 python3-dev python3-pip build-essential ca-certificates && \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY package.json ./
RUN npm install
COPY . .
# Build from source
RUN npm run build
FROM node:lts
WORKDIR /usr/src/app
# Copy built artifacts
COPY --from=builder /usr/src/app/dist /usr/src/app/dist
COPY --from=builder /usr/src/app/package.json /usr/src/app/package.json
# Install runtime dependencies (exclude devDependencies)
RUN npm install --omit=dev
EXPOSE 8080
CMD ["npm", "run", "server"]
- Build status: VerifyBuild status: build_failed
- Build context concerns:
- Builder step copies the entire repo after npm install; risk of overwriting node_modules. Add a .dockerignore to exclude node_modules and large artifacts.
- Assumes npm run server script exists in package.json; runtime dependencies must be in dependencies (not devDependencies).
- If a package-lock.json exists, copy it or use npm ci in final image.
- Failing command / exit:
- Failing step: builder step 7/7, RUN npm run build
- Docker exit code: 1
- Exact error messages (selected, verbatim):
- ERROR in ./src/descriptor_runner/index.ts 38:17-58
Module not found: Error: Can't resolve './operators/wasm/worker/worker' in '/usr/src/app/src/descriptor_runner'
- ERROR in /usr/src/app/src/descriptor_runner/index.ts
./src/descriptor_runner/index.ts 12:33-65
[tsl] ERROR in /usr/src/app/src/descriptor_runner/index.ts(12,34)
TS2307: Cannot find module './operators/wasm/worker/worker' or its corresponding type declarations.
- ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorCPU.ts
1:48-79
[tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorCPU.ts(1,49)
TS2307: Cannot find module '../operators/cpu/opEntriesAll' or its corresponding type declarations.
- ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWasm.ts
1:48-79
[tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWasm.ts(1,49)
TS2307: Cannot find module '../operators/cpu/opEntriesAll' or its corresponding type declarations.
2:49-81
[tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWasm.ts(2,50)
TS2307: Cannot find module '../operators/wasm/opEntriesAll' or its corresponding type declarations.
3:33-66
[tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWasm.ts(3,34)
TS2307: Cannot find module '../operators/wasm/worker/worker' or its corresponding type declarations.
- ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGL.ts
1:48-79
[tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGL.ts(1,49)
TS2307: Cannot find module '../operators/cpu/opEntriesAll' or its corresponding type declarations.
2:50-83
[tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGL.ts(2,51)
TS2307: Cannot find module '../operators/webgl/opEntriesAll' or its corresponding type declarations.
- ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGPU.ts
1:48-79
[tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGPU.ts(1,49)
TS2307: Cannot find module '../operators/cpu/opEntriesAll' or its corresponding type declarations.
2:51-85
[tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGPU.ts(2,52)
TS2307: Cannot find module '../operators/webgpu/opEntriesAll' or its corresponding type declarations.
- 1 error has detailed information that is not shown.
- webpack 5.105.4 compiled with 10 errors in 4354 ms
- Missing packages/files referenced:
- ./operators/wasm/worker/worker
- ../operators/cpu/opEntriesAll
- ../operators/wasm/opEntriesAll
- ../operators/wasm/worker/worker
- ../operators/webgl/opEntriesAll
- ../operators/webgpu/opEntriesAll
- Version / mismatch notes:
- Base image: node:lts (Dockerfile uses a Node LTS image)
- Webpack/TS tooling: webpack 5.105.4, ts-loader; TS2307 errors
- No explicit version mismatch shown; failures are due to missing modules/files. npm deprecation notices shown during install, but not the root cause.import glob
import os
import re
def make_operator_entries(base_dir, standard):
os.chdir(base_dir)
import_lines = []
push_lines = []
glob_path = "./operators/standard/**/*.ts" if standard else "./operators/**/*.ts"
for ts_path in sorted(glob.glob(glob_path, recursive=True)):
ts_relative_path = ts_path.replace("\\", "/")[:-3]
func_name = "getOpEntries" + re.sub("[^a-zA-Z0-9]", "", ts_relative_path)
import_lines.append(f"import {{ getOpEntries as {func_name} }} from \"{ts_relative_path}\";")
push_lines.append(f" entries.push(...{func_name}());")
entry_src = """// auto-generated by scripts/make_operator_entries.py
import { OperatorEntry } from "../../interface/core/operator";
"""+"\n".join(import_lines)+"""
export function getOpEntries(): OperatorEntry[] {
const entries: OperatorEntry[] = [];
"""+"\n".join(push_lines)+"""
return entries;
}
"""
with open(f"{base_dir}/opEntries{'Standard' if standard else 'All'}.ts", "w", newline="\n") as f:
f.write(entry_src)
def make_operator_entries_all_backend():
operators_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + "/src/descriptor_runner/operators/"
for standard in [False, True]:
for backend in ["cpu", "wasm", "webgl", "webgpu"]:
make_operator_entries(operators_root_dir + backend, standard)
def main():
make_operator_entries_all_backend()
main()
FROM node:lts
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 python3-dev python3-pip build-essential ca-certificates && \
ln -s /usr/bin/python3 /usr/bin/python && \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY package.json ./
RUN npm install
COPY . .
RUN npm run build:all
EXPOSE 8080
CMD ["npm", "run", "server"]
FROM node:lts AS builder WORKDIR /usr/src/app COPY package.json ./ RUN npm install COPY . . # Build the project from source RUN npm run build FROM node:lts WORKDIR /usr/src/app # Copy built artifacts from the builder COPY --from=builder /usr/src/app/dist /usr/src/app/dist # Copy package manifest so we can reuse npm scripts if needed COPY package.json ./ EXPOSE 8080 CMD ["npm", "run", "server"]
Build status - verifyBuild status: build_failed - Concerns: Final stage may not install runtime dependencies; copying dist and package.json could miss node_modules unless dist is fully bundled. If dist missing dist/index.js or dist/server.js, entry point may be absent and container startup could fail. Build error - Failing step: Builder stage 6/6: RUN npm run build - Exit code: 1 - Top-level Docker error: "ERROR: failed to build: failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1" Exact error messages (build-time) - ERROR in ./src/descriptor_runner/index.ts 38:17-58 Module not found: Can't resolve './operators/wasm/worker/worker' in '/usr/src/app/src/descriptor_runner' - ERROR in /usr/src/app/src/descriptor_runner/index.ts ./src/descriptor_runner/index.ts 12:33-65 [tsl] ERROR in /usr/src/app/src/descriptor_runner/index.ts(12,34) TS2307: Cannot find module './operators/wasm/worker/worker' or its corresponding type declarations. - ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorCPU.ts [tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorCPU.ts(1,49) TS2307: Cannot find module '../operators/cpu/opEntriesAll' or its corresponding type declarations. - ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWasm.ts [tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWasm.ts(1,49) TS2307: Cannot find module '../operators/cpu/opEntriesAll' or its corresponding type declarations. [tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWasm.ts(2,50) TS2307: Cannot find module '../operators/wasm/opEntriesAll' or its corresponding type declarations. [tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWasm.ts(3,34) Cannot find module '../operators/wasm/worker/worker' or its corresponding type declarations. - ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGL.ts [tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGL.ts(1,49) TS2307: Cannot find module '../operators/cpu/opEntriesAll' or its corresponding type declarations. - ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGL.ts [tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGL.ts(2,51) TS2307: Cannot find module '../operators/webgl/opEntriesAll' or its corresponding type declarations. - ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGPU.ts [tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGPU.ts(1,49) TS2307: Cannot find module '../operators/cpu/opEntriesAll' or its corresponding type declarations. - ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGPU.ts [tsl] ERROR in /usr/src/app/src/descriptor_runner/separateBuild/operatorWebGPU.ts(2,52) TS2307: Cannot find module '../operators/webgpu/opEntriesAll' or its corresponding type declarations. Missing packages/files mentioned - ./operators/wasm/worker/worker - ../operators/cpu/opEntriesAll - ../operators/wasm/opEntriesAll - ../operators/wasm/worker/worker - ../operators/webgl/opEntriesAll - ../operators/webgpu/opEntriesAll Version-related notes - npm notice: New minor version of npm available! 11.9.0 -> 11.12.0 - Webpack version in build: webpack 5.105.4 - Base image: node:lts (via docker.io/library/node:lts)
"""
compile operator kernels of c++ into wasm, then embed them in single ts file, to distribute single webdnn.js
"""
import base64
import glob
import os
import subprocess
import sys
CPP_SRC_DIR = "src"
DST_DIR = "../../descriptor_runner/operators/wasm/worker"
OPTIMIZATION = "-O3"
# change current directory to where this file is
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# dependency C++ library
if not os.path.exists("./lib/eigen-3.3.9"):
sys.stderr.write(f"downloading eigen library into {os.path.join(os.getcwd(), 'lib')}\n")
os.makedirs("./lib", exist_ok=True)
import urllib.request
import tarfile
thetarfile = "https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.bz2"
ftpstream = urllib.request.urlopen(thetarfile)
thetarfile = tarfile.open(fileobj=ftpstream, mode="r|bz2")
thetarfile.extractall("./lib")
srcs = glob.glob(CPP_SRC_DIR + "/**/*.cpp", recursive=True)
subprocess.check_call(["emcc", "-std=c++11", "--pre-js", "pre.js", "-I", "lib/eigen-3.3.9", "-o", f"{DST_DIR}/workerRaw.js", OPTIMIZATION, "-s", "ALLOW_MEMORY_GROWTH=1", *srcs], shell=os.name=='nt')
# embed wasm into worker js
with open(f"{DST_DIR}/workerRaw.wasm", "rb") as f:
worker_wasm = f.read()
with open(f"{DST_DIR}/workerRaw.js", "rt", encoding="utf-8") as f:
worker_js = f.read()
worker_js_with_wasm = worker_js.replace("WASM_WORKER_WASM_BINARY_BASE64", base64.b64encode(worker_wasm).decode("ascii"))
worker_js_with_wasm_escaped = worker_js_with_wasm.replace("\\", "\\\\").replace("`", "\\`").replace("$", "\\$")
worker_data_url_src = f"""/* eslint-disable */
export const wasmWorkerSrcUrl = URL.createObjectURL(new File([`{worker_js_with_wasm_escaped}`], "worker.js", {{type: "text/javascript"}}));
"""
with open(f"{DST_DIR}/worker.ts", "wt", encoding="utf-8", newline="\n") as f:
f.write(worker_data_url_src)
// auto-generated by scripts/make_operator_entries.py
import { OperatorEntry } from "../../interface/core/operator";
import { getOpEntries as getOpEntriesoperatorsstandardbinary7 } from "./operators/standard/binary7";
import { getOpEntries as getOpEntriesoperatorsstandarddynamicunary } from "./operators/standard/dynamicunary";
import { getOpEntries as getOpEntriesoperatorsstandardflatten } from "./operators/standard/flatten";
import { getOpEntries as getOpEntriesoperatorsstandardgemm } from "./operators/standard/gemm";
import { getOpEntries as getOpEntriesoperatorsstandardreshape5 } from "./operators/standard/reshape5";
import { getOpEntries as getOpEntriesoperatorsstandardsqueeze } from "./operators/standard/squeeze";
import { getOpEntries as getOpEntriesoperatorsstandardunary } from "./operators/standard/unary";
import { getOpEntries as getOpEntriesoperatorsstandardunsqueeze } from "./operators/standard/unsqueeze";
export function getOpEntries(): OperatorEntry[] {
const entries: OperatorEntry[] = [];
entries.push(...getOpEntriesoperatorsstandardbinary7());
entries.push(...getOpEntriesoperatorsstandarddynamicunary());
entries.push(...getOpEntriesoperatorsstandardflatten());
entries.push(...getOpEntriesoperatorsstandardgemm());
entries.push(...getOpEntriesoperatorsstandardreshape5());
entries.push(...getOpEntriesoperatorsstandardsqueeze());
entries.push(...getOpEntriesoperatorsstandardunary());
entries.push(...getOpEntriesoperatorsstandardunsqueeze());
return entries;
}
Summary of actionable details:
- Purpose: load(directory, options) -> Promise<Runner> for WebDNN backends.
- InitOption interface:
- backendOrder?: Backend[]; optimized?: boolean;
- backendOptions?: { wasm?: WebDNNWebGLContextOption; webgl?: WebDNNWebGLContextOption; webgpu?: WebDNNWebGPUContextOption; }
- progressCallback?: (loaded, total) => unknown;
- onnxBaseName?: string;
- Default backend order: ["webgl", "wasm", "cpu"].
- Optimized flag: if options.optimized is true, throws:
"Currently, webdnn.js does not support optimized model. Use webdnn-core.js instead."
- Context caching (defaultContexts):
- cpu, wasm, webgl, webgpu initialized to null and reused across loads.
- CPU context: if missing, creates WebDNNCPUContextImpl, initializes it, and registers CPU operators (getOpEntriesCPU()).
- Backends tried in order:
- wasm: create WebDNNWasmContextImpl(cpuContext, options.backendOptions?.wasm || {}), initialize(wasmWorkerSrcUrl), register operators (getOpEntriesWasm()).
- webgl: create WebDNNWebGLContextImpl(cpuContext, options.backendOptions?.webgl || {}), initialize(), register operators (getOpEntriesWebGL()).
- webgpu: create WebDNNWebGPUContextImpl(cpuContext, options.backendOptions?.webgpu || {}), initialize(), register operators (getOpEntriesWebGPU()).
- If a backend fails to initialize, it’s skipped (empty catch). If an existing cached context is present, it’s reused.
- Backends must succeed to proceed; if none succeed, errors: "No backend available".
- After success: actualBackendOrder is:
- ["cpu"] if chosen backend is cpu;
- [succeedBackend, "cpu"] otherwise.
- Runner: new RunnerImpl(actualBackendOrder, backendContexts).
- Model loading: await runner.loadModel(directory, options.onnxBaseName || "model.onnx", options.progressCallback).
- wasm uses wasmWorkerSrcUrl and registers wasm operators; other backends register their respective operator entries.
Exports and related items:
- Exports InitOption interface and CPUTensor alias (CPUTensor from backend/cpu/cpuTensorImpl).
- Exports include Image and Math modules, and Logging (WebDNNLogging) alias.FROM node:lts AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-dev \
python3-pip \
git \
build-essential \
ca-certificates \
curl && \
ln -s /usr/bin/python3 /usr/bin/python && \
rm -rf /var/lib/apt/lists/*
# Install Emscripten SDK to provide emcc for shader compilation
RUN mkdir -p /emsdk && \
git clone https://github.com/emscripten-core/emsdk.git /emsdk && \
cd /emsdk && \
./emsdk install latest && \
./emsdk activate latest
ENV PATH="/emsdk/upstream/emscripten:/emsdk:${PATH}"
WORKDIR /workspace
COPY package.json ./
RUN npm install
COPY . .
# Build steps
RUN npm run shader:wasm
RUN npm run makeShaderList
RUN npm run shader:webgpu
RUN npm run build
RUN npm run build:core
FROM node:lts
WORKDIR /workspace
# Copy built artifacts from builder
COPY --from=builder /workspace/dist /workspace/dist
COPY --from=builder /workspace/package.json /workspace/package.json
# Install runtime dependencies and http-server for serving
RUN npm install --omit=dev
RUN npm install -g http-server
EXPOSE 8080
CMD ["npm", "run", "server"]
Concerns: Build relies on network access to clone emsdk and fetch dependencies; may fail in restricted environments., No HEALTHCHECK defined; container startup health is not automatically verified., Runtime startup depends on a 'server' script in package.json; if that script is missing or renamed, CMD will fail. Smoke [PASS]: test -d /workspace/dist Smoke [PASS]: test -f /workspace/package.json Smoke [PASS]: command -v http-server >/dev/null 2>&1 && echo OK || exit 1