diff --git a/.gitignore b/.gitignore index b558e6ed..1d147dd6 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,8 @@ wasm-client.wasm # Mobile build output build/ +# Reproducible build output +reproducible-builds/ + # Misc *.DS_Store diff --git a/Dockerfile-wasm b/Dockerfile-wasm new file mode 100644 index 00000000..6b8060f2 --- /dev/null +++ b/Dockerfile-wasm @@ -0,0 +1,14 @@ +#Get golang 1.17.3-buster as a base image +FROM golang:1.17.3-buster@sha256:ee3a388a872237ddb600de3ab9512e73df0043f8878f0f355baeb5b723ef16ec as builder + +#Define the working directory in the container +WORKDIR /app + +#Copy all files from root into the container +COPY . ./ + +#Use go mod tidy to handle dependencies +RUN go mod tidy + +#Run the make task +RUN make wasm diff --git a/Makefile b/Makefile index 214cdbba..b205793e 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ build: wasm: # The appengine build tag is needed because of the jessevdk/go-flags library # that has some OS specific terminal code that doesn't compile to WASM. - cd cmd/wasm-client; GOOS=js GOARCH=wasm go build -trimpath -ldflags="$(LDFLAGS)" -tags="$(RPC_TAGS)" -v -o wasm-client.wasm . + cd cmd/wasm-client; CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -trimpath -ldflags="$(LDFLAGS)" -tags="$(RPC_TAGS)" -v -o wasm-client.wasm . $(CP) cmd/wasm-client/wasm-client.wasm example/wasm-client.wasm apple: @@ -91,6 +91,23 @@ android: mobile: ios android +repro-wasm: + #Build the repro-wasm image + docker build -f Dockerfile-wasm -t repro-wasm-image --no-cache . + + #Run the repro-wasm-image in a new container called repro-wasm + docker run --name repro-wasm repro-wasm-image + + #Copy the compiled WASM file to the host machine + mkdir -p reproducible-builds + docker cp repro-wasm:/app/cmd/wasm-client/wasm-client.wasm ./reproducible-builds/ + + #Remove the repro-wasm container + docker rm repro-wasm + + #Remove the repro-wasm-image + docker image rm repro-wasm-image + # ======= # TESTING # =======