mil-tokyo-webdnn
SUCCESS
30m 44s
History Source
SummaryIterations3Transcript17Dockerfile
Dockerfile63 lines · 1788 chars
# Multi-stage build for WebDNN
# Stage 1: Build with emscripten and Node.js tooling
FROM emscripten/emsdk:latest AS build

# Install system dependencies including Node.js, Python tooling, and build essentials
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        curl \
        ca-certificates \
        git \
        build-essential \
        cmake \
        python3 \
        python3-pip \
        wget \
        && rm -rf /var/lib/apt/lists/*

# Ensure python binary exists for shader scripts (some scripts expect 'python')
RUN ln -s /usr/bin/python3 /usr/bin/python || true

# Install Node.js 18.x (LTS) using NodeSource
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
    apt-get update && \
    apt-get install -y --no-install-recommends nodejs && \
    rm -rf /var/lib/apt/lists/*

# Work directory
WORKDIR /workspace

# Make sure OpenSSL legacy provider is available for webpack builds on newer Node
ENV NODE_OPTIONS=--openssl-legacy-provider

# Copy package manifests first to leverage caching
COPY package.json yarn.lock* ./

# Install npm/yarn dependencies
RUN npm install -g yarn && \
    yarn install --frozen-lockfile

# Copy the rest of the source
COPY . .

# Build the project (this will also build shaders via the included scripts)
RUN yarn build:all


# Stage 2: Lightweight runtime image that serves the built artifacts
FROM node:18-bullseye-slim AS runtime

WORKDIR /workspace

# Copy built artifacts from the build stage
COPY --from=build /workspace/dist /workspace/dist

# Install a lightweight static server
RUN npm install -g http-server

# Expose a convenient port for the static server
EXPOSE 8080

# Serve the built distribution using a tiny static HTTP server
CMD ["http-server", "dist", "-p", "8080", "-c", "-1"]