Your actual build line:
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -installsuffix cgo -ldflags '-extldflags "-static"' -o api cmd/api/
is missing a relative path in front of
cmd, making it instead be
./cmd/api will result in a successful build/run.
cmd/api is a real thing apparently, https://golang.org/cmd/api/, so it's not erring out, but also not doing what you are expecting it to do. If you type
go run cmd/api in your terminal you should see a ton of output unrelated to your application.