Skip to content

Commit 4008b92

Browse files
authored
Merge pull request #62 from lightninglabs/reproducible-builds
Reproducible builds: WASM
2 parents 4422761 + 490e713 commit 4008b92

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ wasm-client.wasm
1919
# Mobile build output
2020
build/
2121

22+
# Reproducible build output
23+
reproducible-builds/
24+
2225
# Misc
2326
*.DS_Store

Dockerfile-wasm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#Get golang 1.17.3-buster as a base image
2+
FROM golang:1.17.3-buster@sha256:ee3a388a872237ddb600de3ab9512e73df0043f8878f0f355baeb5b723ef16ec as builder
3+
4+
#Define the working directory in the container
5+
WORKDIR /app
6+
7+
#Copy all files from root into the container
8+
COPY . ./
9+
10+
#Use go mod tidy to handle dependencies
11+
RUN go mod tidy
12+
13+
#Run the make task
14+
RUN make wasm

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ build:
7474
wasm:
7575
# The appengine build tag is needed because of the jessevdk/go-flags library
7676
# that has some OS specific terminal code that doesn't compile to WASM.
77-
cd cmd/wasm-client; GOOS=js GOARCH=wasm go build -trimpath -ldflags="$(LDFLAGS)" -tags="$(RPC_TAGS)" -v -o wasm-client.wasm .
77+
cd cmd/wasm-client; CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -trimpath -ldflags="$(LDFLAGS)" -tags="$(RPC_TAGS)" -v -o wasm-client.wasm .
7878
$(CP) cmd/wasm-client/wasm-client.wasm example/wasm-client.wasm
7979

8080
apple:
@@ -104,6 +104,23 @@ android:
104104

105105
mobile: ios android
106106

107+
repro-wasm:
108+
#Build the repro-wasm image
109+
docker build -f Dockerfile-wasm -t repro-wasm-image --no-cache .
110+
111+
#Run the repro-wasm-image in a new container called repro-wasm
112+
docker run --name repro-wasm repro-wasm-image
113+
114+
#Copy the compiled WASM file to the host machine
115+
mkdir -p reproducible-builds
116+
docker cp repro-wasm:/app/cmd/wasm-client/wasm-client.wasm ./reproducible-builds/
117+
118+
#Remove the repro-wasm container
119+
docker rm repro-wasm
120+
121+
#Remove the repro-wasm-image
122+
docker image rm repro-wasm-image
123+
107124
# =======
108125
# TESTING
109126
# =======

0 commit comments

Comments
 (0)