Skip to content

Commit

Permalink
chore(ci): Update docker build for wasm (#2294)
Browse files Browse the repository at this point in the history
* update wasm build for docker

* lock wasm-pack version on build runners

Signed-off-by: onur-ozkan <work@onurozkan.dev>

---------

Signed-off-by: onur-ozkan <work@onurozkan.dev>
Co-authored-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
smk762 and onur-ozkan authored Dec 24, 2024
1 parent 72bc73e commit ea5f307
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
11 changes: 6 additions & 5 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM docker.io/debian:10

MAINTAINER Onur Özkan <onur@komodoplatform.com>
LABEL authors="Onur Özkan <onur@komodoplatform.com>"

RUN apt-get update -y

Expand All @@ -11,6 +11,7 @@ RUN apt-get install -y \
curl \
wget \
unzip \
libudev-dev \
gnupg

RUN ln -s /usr/bin/python3 /bin/python
Expand Down Expand Up @@ -49,8 +50,8 @@ RUN apt-get install -y \
docker-buildx-plugin

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile minimal --default-toolchain nightly-2023-06-01 -y

RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.1/protoc-3.20.1-linux-x86_64.zip
RUN unzip protoc-3.20.1-linux-x86_64.zip && mv ./include/google /usr/include/google

ENV PATH="/root/.cargo/bin:$PATH"
RUN cargo install wasm-pack --version 0.10.3
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-linux-x86_64.zip
RUN unzip protoc-25.3-linux-x86_64.zip && mv ./include/google /usr/include/google

2 changes: 1 addition & 1 deletion .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ jobs:
rustup target add wasm32-unknown-unknown
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | bash -s -- -y
run: CARGO_HOME=/root/.cargo cargo install wasm-pack --version 0.10.3

- name: Calculate commit hash for PR commit
if: github.event_name == 'pull_request'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ jobs:
rustup target add wasm32-unknown-unknown
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | bash -s -- -y
run: CARGO_HOME=/root/.cargo cargo install wasm-pack --version 0.10.3

- name: Calculate commit hash for PR commit
if: github.event_name == 'pull_request'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ jobs:
deps: ('protoc')

- name: Install wasm-pack
# Use the latest wasm-pack for up-to-date compatibility coverage on KDF.
# As we don't share any build artifacts from this pipeline, we don't need
# to lock the version here.
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Download geckodriver
Expand Down
19 changes: 18 additions & 1 deletion docs/WASM_BUILD.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Building WASM binary

## From Container:

If you want to build from source without installing prerequisites to your host system, you can do so by binding the source code inside a container and compiling it there.

Build the image:

```sh
docker build -t kdf-build-container -f .docker/Dockerfile .
```

Bind source code into container and compile it:
```sh
docker run -v "$(pwd)":/app -w /app kdf-build-container wasm-pack build mm2src/mm2_bin_lib --target web --out-dir wasm_build/deps/pkg/
```

## Setting up the environment

To build WASM binary from source, the following prerequisites are required:
Expand Down Expand Up @@ -39,4 +54,6 @@ If you want to disable optimizations to reduce the compilation time, run `wasm-p
wasm-pack build mm2src/mm2_bin_lib --target web --out-dir wasm_build/deps/pkg/ --dev
```

Please don't forget to specify `CC` and `AR` if you run the command on OSX.
Please don't forget to specify `CC` and `AR` if you run the command on OSX.


0 comments on commit ea5f307

Please sign in to comment.