From 95763806c862eac85647868bd472cc2821cff5fe Mon Sep 17 00:00:00 2001 From: omaroughriss Date: Mon, 8 Sep 2025 19:22:11 +0200 Subject: [PATCH] Update Dockerfile to use signer image with sdk_client pkg --- Dockerfile | 71 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0132378..f00ac5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,54 @@ -FROM node:20-alpine AS base +# syntax=docker/dockerfile:1.4 +FROM rust:1.82-alpine AS wasm-builder +WORKDIR /build -# Install production dependencies only by default -ENV NODE_ENV=production +# 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 sdk_signer +COPY . sdk_signer/ + +# Clonage du sdk_client au même niveau que sdk_signer en utilisant la clé SSH montée +RUN --mount=type=ssh git clone -b dev 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 ../sdk_signer/pkg --target nodejs --dev + +FROM node:20-alpine WORKDIR /app -# Install build dependencies -FROM base AS deps -ENV NODE_ENV=development -RUN apk add --no-cache python3 make g++ -COPY package.json package-lock.json* ./ -RUN npm ci +# Installation des dépendances nécessaires +RUN apk update && apk add --no-cache git -# Build TypeScript -FROM deps AS build -COPY tsconfig.json ./ -COPY src ./src -COPY pkg ./pkg -RUN npm run build +# Copie des fichiers du projet +COPY --from=wasm-builder /build/sdk_signer/pkg ./pkg +COPY . . + +# Installation des dépendances Node.js +RUN npm install -# Runtime image -FROM base AS runner -WORKDIR /app -ENV NODE_ENV=production -RUN addgroup -S nodejs && adduser -S nodejs -G nodejs -COPY --from=deps /app/node_modules ./node_modules -COPY --from=build /app/dist ./dist -COPY --from=build /app/pkg ./pkg EXPOSE 9090 -USER nodejs -CMD ["node", "dist/index.js"] - +CMD ["npm", "start"]