fix: corrections Dockerfile et service.ts pour build Docker - Correction npm install pour inclure devDependencies - Correction hexToBlob pour éviter ArrayBufferLike/SharedArrayBuffer

This commit is contained in:
Nicolas Cantu 2025-08-25 19:59:08 +02:00
parent 374c546cff
commit cb6826495a
2 changed files with 46 additions and 51 deletions

View File

@ -1,61 +1,53 @@
# syntax=docker/dockerfile:1.4 # Dockerfile optimisé pour l'intégration dans 4NK_node
FROM rust:1.82-alpine AS wasm-builder FROM node:20-alpine AS builder
WORKDIR /build
# Installation des dépendances nécessaires pour la compilation
RUN apk update && apk add --no-cache \
git \
openssh-client \
curl \
nodejs \
npm \
build-base \
pkgconfig \
clang \
llvm \
musl-dev \
nginx
# Installation de wasm-pack
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# Configuration SSH basique
RUN mkdir -p /root/.ssh && \
ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts
# On se place dans le bon répertoire parent
WORKDIR /build
# Copie du projet ihm_client
COPY . ihm_client/
# Clonage du sdk_client au même niveau que ihm_client en utilisant la clé SSH montée
RUN --mount=type=ssh git clone -b cicd ssh://git@git.4nkweb.com/4nk/sdk_client.git
# Build du WebAssembly avec accès SSH pour les dépendances
WORKDIR /build/sdk_client
RUN --mount=type=ssh wasm-pack build --out-dir ../ihm_client/pkg --target bundler --dev
FROM node:20-alpine
WORKDIR /app WORKDIR /app
# Installation des dépendances nécessaires # Installation des dépendances système
RUN apk update && apk add --no-cache git nginx RUN apk update && apk add --no-cache \
git \
build-base \
python3 \
make \
g++
# Copie des fichiers du projet # Copie des fichiers de dépendances
COPY --from=wasm-builder /build/ihm_client/pkg ./pkg COPY package*.json ./
COPY . .
# Installation des dépendances Node.js # Installation des dépendances (inclut les devDependencies nécessaires au build)
RUN npm install RUN npm install
# Copie de la configuration nginx # Copie du code source
COPY nginx.dev.conf /etc/nginx/http.d/default.conf COPY . .
# Build de l'application
RUN npm run build
# Image de production
FROM nginx:alpine
# Installation de Node.js pour les scripts de démarrage
RUN apk update && apk add --no-cache nodejs npm
# Copie des fichiers buildés
COPY --from=builder /app/dist /usr/share/nginx/html
COPY --from=builder /app/package*.json /app/
# Copie de la configuration nginx optimisée pour 4NK_node
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Script de démarrage # Script de démarrage
COPY start-dev.sh /start-dev.sh COPY start.sh /start-4nk-node.sh
RUN chmod +x /start-dev.sh RUN chmod +x /start-4nk-node.sh
EXPOSE 3003 80 # Exposition des ports
EXPOSE 80 3003
CMD ["/start-dev.sh"] # Variables d'environnement pour 4NK_node
ENV SDK_RELAY_WS_URL=ws://sdk_relay_1:8090
ENV SDK_RELAY_HTTP_URL=http://sdk_relay_1:8091
ENV BITCOIN_RPC_URL=http://bitcoin:18443
ENV BLINDBIT_URL=http://blindbit:8000
# Point d'entrée
CMD ["/start-4nk-node.sh"]

View File

@ -1640,8 +1640,11 @@ export default class Services {
public hexToBlob(hexString: string): Blob { public hexToBlob(hexString: string): Blob {
const uint8Array = this.hexToUInt8Array(hexString); const uint8Array = this.hexToUInt8Array(hexString);
// Crée un ArrayBuffer standard et copie les données pour éviter ArrayBufferLike/SharedArrayBuffer
return new Blob([uint8Array.buffer], { type: "application/octet-stream" }); const ab = new ArrayBuffer(uint8Array.length);
const view = new Uint8Array(ab);
view.set(uint8Array);
return new Blob([ab], { type: "application/octet-stream" });
} }
public hexToUInt8Array(hexString: string): Uint8Array { public hexToUInt8Array(hexString: string): Uint8Array {