godockerfilewebassembly

Standard_init_linux.go:211: exec user process caused “exec format error”


The following code generates an error: standard_init_linux.go:211: exec user process caused “exec format error”

Any pointers to what I’m doing wrong?

FROM golang:alpine AS builder
 
ENV GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOARCH=wasm GOOS=js

WORKDIR /build

COPY . .

COPY wasm_exec.js . 
COPY server.go . 
COPY main.wasm . 
COPY manifest.json . 
COPY sw.js . 
COPY wasm_exec.js . 
COPY app.js . 
COPY index.html .

EXPOSE 8989 
ENTRYPOINT ["./server.go"]

Solution

    1. To use dos2unix fix your files' format, which maybe changed by git from lf to crlf
    2. go build before copy to docker, then, copy and execute the bin
    3. if you don't want to do pre-built, the last line should be ENTRYPOINT ["go","run","./server.go"]