58 lines
1.5 KiB
Docker
Executable File
58 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 \
|
|
--no-reference-types \
|
|
--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"]
|