build: add wasm bits to Dockerfile and bump to go v1.15.6 (#3992)
This commit is contained in:
parent
46e26fa47d
commit
8fe829d5fd
19
Makefile
19
Makefile
@ -1,4 +1,4 @@
|
||||
GO_VERSION ?= 1.15.5
|
||||
GO_VERSION ?= 1.15.6
|
||||
GOOS ?= linux
|
||||
GOARCH ?= amd64
|
||||
GOPATH ?= $(shell go env GOPATH)
|
||||
@ -144,6 +144,14 @@ storagenode-console:
|
||||
/usr/bin/env echo -e '\nfunc init() { FileSystem = AssetFile() }' >> storagenode/console/consoleassets/bindata.resource.go
|
||||
gofmt -w -s storagenode/console/consoleassets/bindata.resource.go
|
||||
|
||||
.PHONY: satellite-wasm
|
||||
satellite-wasm:
|
||||
docker run --rm -i -v "${PWD}":/go/src/storj.io/storj -e GO111MODULE=on \
|
||||
-e GOOS=js -e GOARCH=wasm -e GOARM=6 -e CGO_ENABLED=1 \
|
||||
-v /tmp/go-cache:/tmp/.cache/go-build -v /tmp/go-pkg:/go/pkg \
|
||||
-w /go/src/storj.io/storj -e GOPROXY -e TAG=${TAG} -u $(shell id -u):$(shell id -g) storjlabs/golang:${GO_VERSION} \
|
||||
scripts/build-wasm.sh ;\
|
||||
|
||||
.PHONY: images
|
||||
images: satellite-image segment-reaper-image storagenode-image uplink-image versioncontrol-image ## Build satellite, segment-reaper, storagenode, uplink, and versioncontrol Docker images
|
||||
echo Built version: ${TAG}
|
||||
@ -228,6 +236,13 @@ binary:
|
||||
-w /go/src/storj.io/storj -e GOPROXY -u $(shell id -u):$(shell id -g) storjlabs/golang:${GO_VERSION} \
|
||||
scripts/release.sh build $(EXTRA_ARGS) -o release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT} \
|
||||
storj.io/storj/cmd/${COMPONENT}
|
||||
|
||||
if [ "${COMPONENT}" = "satellite" ] && [ "${GOARCH}" = "amd64" ]; \
|
||||
then \
|
||||
echo "Building wasm code"; \
|
||||
$(MAKE) satellite-wasm; \
|
||||
fi
|
||||
|
||||
chmod 755 release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT}
|
||||
[ "${FILEEXT}" = ".exe" ] && storj-sign release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT} || echo "Skipping signing"
|
||||
rm -f release/${TAG}/${COMPONENT}_${GOOS}_${GOARCH}.zip
|
||||
@ -307,7 +322,7 @@ push-images: ## Push Docker images to Docker Hub (jenkins)
|
||||
binaries-upload: ## Upload binaries to Google Storage (jenkins)
|
||||
cd "release/${TAG}"; for f in *; do \
|
||||
zipname=$$(echo $${f} | sed 's/.exe//g') && \
|
||||
zip "$${zipname}.zip" "$${f}" \
|
||||
zip -r "$${zipname}.zip" "$${f}" \
|
||||
; done
|
||||
cd "release/${TAG}"; gsutil -m cp -r *.zip "gs://storj-v3-alpha-builds/${TAG}/"
|
||||
|
||||
|
@ -26,6 +26,8 @@ COPY --from=ui /app/static /app/static
|
||||
COPY --from=ui /app/dist /app/dist
|
||||
COPY --from=ui /app/marketing /app/marketing
|
||||
COPY --from=ca-cert /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY release/${TAG}/wasm/access.wasm /app/static/wasm/
|
||||
COPY release/${TAG}/wasm/wasm_exec.js /app/static/wasm/
|
||||
COPY release/${TAG}/satellite_linux_${GOARCH:-amd64} /app/satellite
|
||||
COPY release/${TAG}/inspector_linux_${GOARCH:-amd64} /app/inspector
|
||||
COPY cmd/satellite/entrypoint /entrypoint
|
||||
|
@ -6,7 +6,7 @@ In order to use the uplink library from the browser, we can compile the uplink l
|
||||
|
||||
To generate wasm code that can create access grants in the web browser, run the following from the storj/wasm directory:
|
||||
```
|
||||
$ GOOS=js GOARCH=wasm go build -o access.wasm access.go
|
||||
$ GOOS=js GOARCH=wasm go build -o access.wasm storj.io/storj/satellite/console/wasm
|
||||
```
|
||||
|
||||
The `access.wasm` code can then be loaded into the browser in a script tag in an html page. Also needed is a JavaScript support file which ships with golang.
|
||||
|
13
scripts/build-wasm.sh
Executable file
13
scripts/build-wasm.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
# Ensure the directory exists
|
||||
mkdir -p release/$TAG/wasm/
|
||||
|
||||
# Copy wasm javascript to match the go version
|
||||
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" release/$TAG/wasm/
|
||||
|
||||
# Build wasm code
|
||||
exec go build -o release/$TAG/wasm/access.wasm storj.io/storj/satellite/console/wasm
|
Loading…
Reference in New Issue
Block a user