Thanks for the reply, Curtis.
Yes, I am deploying a Go server to serve the WASM app. Note that I am not trying to build the WASM code in Docker. I built the example.wasm
locally and I am trying to load the compiled app into the Docker image. This was my first attempt at a Dockerfile…
FROM golang:alpine
ADD . /Users/carlca/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty/index.html
ADD . /Users/carlca/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty/example.wasm
ADD . /go/src/github.com/carlca/server
RUN go install github.com/carlca/server
CMD ["/go/bin/server"]
EXPOSE 3000
This gave me errors about dependencies…
now --public +869 1:05 ❰─┘
> Deploying ~/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty under carl.caulkett@gmail.com
> https://markdownvecty-frnkxqbkwp.now.sh [in clipboard] (bru1) [6s]
> Building…
> ▲ docker build
Sending build context to Docker daemon 3.891 MBkB
> Step 1/7 : FROM golang:alpine
> ---> c4b5d89b27f4
> Step 2/7 : ADD . /Users/carlca/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty/index.html
> ---> 8d798d950a48
> Step 3/7 : ADD . /Users/carlca/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty/example.wasm
> ---> 7d91edb3d290
> Step 4/7 : ADD . /go/src/github.com/carlca/server
> ---> 0ab68faa3748
> Step 5/7 : RUN go install github.com/carlca/server
> ---> Running in d6dfda8510d2
> src/github.com/carlca/server/markdown.go:4:2: cannot find package "github.com/gowasm/vecty" in any of:
> /usr/local/go/src/github.com/gowasm/vecty (from $GOROOT)
> /go/src/github.com/gowasm/vecty (from $GOPATH)
> src/github.com/carlca/server/markdown.go:5:2: cannot find package "github.com/gowasm/vecty/elem" in any of:
> /usr/local/go/src/github.com/gowasm/vecty/elem (from $GOROOT)
> /go/src/github.com/gowasm/vecty/elem (from $GOPATH)
> src/github.com/carlca/server/markdown.go:6:2: cannot find package "github.com/gowasm/vecty/event" in any of:
> /usr/local/go/src/github.com/gowasm/vecty/event (from $GOROOT)
> /go/src/github.com/gowasm/vecty/event (from $GOPATH)
> src/github.com/carlca/server/markdown.go:7:2: cannot find package "github.com/microcosm-cc/bluemonday" in any of:
> /usr/local/go/src/github.com/microcosm-cc/bluemonday (from $GOROOT)
> /go/src/github.com/microcosm-cc/bluemonday (from $GOPATH)
> src/github.com/carlca/server/markdown.go:8:2: cannot find package "github.com/russross/blackfriday" in any of:
> /usr/local/go/src/github.com/russross/blackfriday (from $GOROOT)
> /go/src/github.com/russross/blackfriday (from $GOPATH)
> The command '/bin/sh -c go install github.com/carlca/server' returned a non-zero code: 1
> Error! Build failed
I then tried to address those dependencies with these changes to the Dockerfile…
FROM golang:alpine
ADD . /Users/carlca/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty/index.html
ADD . /Users/carlca/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty/example.wasm
ADD . /go/src/github.com/carlca/server
ADD . /go/src/github.com/gowasm/vecty
ADD . /go/src/github.com/gowasm/vecty/elem
ADD . /go/src/github.com/gowasm/vecty/event
ADD . /go/src/github.com/microcosm-cc/bluemonday
ADD . /go/src/github.com/russross/blackfriday
RUN go install github.com/carlca/server
CMD ["/go/bin/server"]
EXPOSE 3000
This gave me some different error which I don’t recognise or understand…
now --public 1 ⏎ +871 1:09 ❰─┘
> Deploying ~/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty under carl.caulkett@gmail.com
> https://markdownvecty-kmivimddsf.now.sh [in clipboard] (bru1) [4s]
> Building…
> ▲ docker build
Sending build context to Docker daemon 3.892 MBkB
> Step 1/12 : FROM golang:alpine
> ---> c4b5d89b27f4
> Step 2/12 : ADD . /Users/carlca/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty/index.html
> ---> cbfb203e3c9e
> Step 3/12 : ADD . /Users/carlca/code/go/src/github.com/carlca/wasm/first/wasmplay/markdownvecty/example.wasm
> ---> 94564b6e1973
> Step 4/12 : ADD . /go/src/github.com/carlca/server
> ---> a24ecf2985cc
> Step 5/12 : ADD . /go/src/github.com/gowasm/vecty
> ---> e022088f661a
> Step 6/12 : ADD . /go/src/github.com/gowasm/vecty/elem
> ---> 62dc45676328
> Step 7/12 : ADD . /go/src/github.com/gowasm/vecty/event
> ---> 27a04c2fd1f4
> Step 8/12 : ADD . /go/src/github.com/microcosm-cc/bluemonday
> ---> cee6e0d9a801
> Step 9/12 : ADD . /go/src/github.com/russross/blackfriday
> ---> de56d64728ba
> Step 10/12 : RUN go install github.com/carlca/server
> ---> Running in 1b6ae9f47c77
> src/github.com/carlca/server/markdown.go:4:2: import "github.com/gowasm/vecty" is a program, not an importable package
> src/github.com/carlca/server/markdown.go:5:2: import "github.com/gowasm/vecty/elem" is a program, not an importable package
> src/github.com/carlca/server/markdown.go:6:2: import "github.com/gowasm/vecty/event" is a program, not an importable package
> src/github.com/carlca/server/markdown.go:7:2: import "github.com/microcosm-cc/bluemonday" is a program, not an importable package
> src/github.com/carlca/server/markdown.go:8:2: import "github.com/russross/blackfriday" is a program, not an importable package
> The command '/bin/sh -c go install github.com/carlca/server' returned a non-zero code: 1
> Error! Build failed
The server part is a simple Golang app…
package main
import (
"log"
"net/http"
)
func wasmHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/wasm")
http.ServeFile(w, r, "example.wasm")
}
func main() {
mux := http.NewServeMux()
mux.Handle("/", http.FileServer(http.Dir(".")))
mux.HandleFunc("/example.wasm", wasmHandler)
log.Fatal(http.ListenAndServe(":3000", mux))
}