ihm_client/Dockerfile
4NK CI Bot 01b1b50d6b
Some checks failed
Build and Push Docker image (ext) / docker (push) Failing after 3m44s
ci: docker_tag=ext - Fix WASM compilation for web target
- Recompile sdk_client WASM with --target web for ES modules
- Update Dockerfile to build WASM in web target instead of bundler
- Modify index.html to initialize WASM before router
- Update service.ts and router.ts to use ES module imports
- Fix 'module is not defined' error in browser
2025-09-18 15:41:05 +00:00

57 lines
1.5 KiB
Docker
Executable File

# syntax=docker/dockerfile:1.4
# Stage 1: Build WASM for web target
FROM rust:1.82-alpine AS wasm-builder
WORKDIR /build
# Install dependencies for WASM compilation
RUN apk update && apk add --no-cache git openssh-client curl nodejs npm build-base pkgconfig clang llvm musl-dev
# Install wasm-bindgen-cli
RUN cargo install wasm-bindgen-cli --version 0.2.103 --locked && rustup target add wasm32-unknown-unknown
# Setup SSH for git clone
RUN mkdir -p /root/.ssh && ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts
# Copy project files
COPY . ihm_client/
# Clone and build sdk_client for web target
RUN --mount=type=ssh git clone -b dev ssh://git@git.4nkweb.com/4nk/sdk_client.git
WORKDIR /build/sdk_client
# Build WASM for web target (ES modules)
RUN cargo build --target wasm32-unknown-unknown --profile dev && \
wasm-bindgen target/wasm32-unknown-unknown/debug/sdk_client.wasm \
--out-dir /build/ihm_client/pkg \
--typescript \
--target web \
--debug
# Stage 2: Final application
FROM node:20-alpine
WORKDIR /app
# Installation des dépendances nécessaires
RUN apk update && apk add --no-cache git nginx
# Copy project files
COPY . .
# Copy the web-compiled WASM package
COPY --from=wasm-builder /build/ihm_client/pkg ./pkg
# Installation des dépendances Node.js
RUN npm install
# Copie de la configuration nginx
COPY nginx.dev.conf /etc/nginx/http.d/default.conf
# Script de démarrage
COPY start-dev.sh /start-dev.sh
RUN chmod +x /start-dev.sh
EXPOSE 3003 80
CMD ["/start-dev.sh"]