Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ to WebAssembly. It allows you to use Miniscript in NodeJS and in the browser.

- [Rust](https://www.rust-lang.org/) nightly
- [wasm-pack](https://rustwasm.github.io/wasm-pack/) (install with `cargo install wasm-pack`)
- [NodeJS](https://nodejs.org/en/)
- [NodeJS](https://nodejs.org/en/)

# Building

You can use the Docker image / Makefile to build the wasm files:

```bash
make build-image
make build-wasm
```
1 change: 1 addition & 0 deletions packages/wasm-miniscript/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
25 changes: 25 additions & 0 deletions packages/wasm-miniscript/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Start from a Node.js base image
FROM node:20

# Install Rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Install wasm-pack
RUN cargo install wasm-pack

# Install clang
RUN apt-get update && apt-get install -y clang

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
COPY package*.json ./
RUN npm install

# Bundle app source
COPY . .

# Build the project
RUN npm run build
22 changes: 22 additions & 0 deletions packages/wasm-miniscript/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.PHONY: build-image build-wasm enter-image clean-container clean-image

CONTAINER_ENGINE ?= docker

build-image:
$(CONTAINER_ENGINE) build --tag wasm-builder .

build-wasm:
$(CONTAINER_ENGINE) run -v $(shell pwd)/src:/usr/src/app/src \
--name wasm-builder-container wasm-builder \
npm run build
$(CONTAINER_ENGINE) cp wasm-builder-container:/usr/src/app/dist .
$(CONTAINER_ENGINE) cp wasm-builder-container:/usr/src/app/js/wasm ./js/wasm

enter-image:
$(CONTAINER_ENGINE) run -it wasm-builder /bin/bash

clean-container:
$(CONTAINER_ENGINE) rm wasm-builder-container

clean-image:
$(CONTAINER_ENGINE) rmi wasm-builder