micmonay / keybd_event

For simulate key press in Linux, Windows and Mac in golang
MIT License
380 stars 57 forks source link

Build failed with Dockerfile #13

Closed skanehira closed 5 years ago

skanehira commented 5 years ago

Hi! Thank you for developing this.

Attempting to build a tool using keybd_event inside a docker container failed. I build on the Mac OS and build success. I don't know the cause of the error.

$ docker build -t skanehira/docui .                                 933ms
Sending build context to Docker daemon  70.03MB
Step 1/13 : FROM golang:1.12.8 AS build-docui
1.12.8: Pulling from library/golang
4ae16bd47783: Already exists 
bbab4ec87ac4: Already exists 
2ea1f7804402: Already exists 
96465440c208: Already exists 
16a3d8aca6cd: Pull complete 
a04ada715f6e: Pull complete 
255e23a40665: Pull complete 
Digest: sha256:2a5dc837ac980ba4576dcb838dfb3710675d72e56debbd9bccea2607626317d8
Status: Downloaded newer image for golang:1.12.8
 ---> 8a91d9dc9d09
Step 2/13 : ENV GOPATH /go
 ---> Running in 00a4cef1741b
Removing intermediate container 00a4cef1741b
 ---> 10f60ec92652
Step 3/13 : ENV GOOS linux
 ---> Running in 69c7e0be9afd
Removing intermediate container 69c7e0be9afd
 ---> da9d6cb6cc5c
Step 4/13 : ENV GOARCH amd64
 ---> Running in 581c84b966f8
Removing intermediate container 581c84b966f8
 ---> 962ef2577ada
Step 5/13 : ENV CGO_ENABLED 0
 ---> Running in b73061e695a2
Removing intermediate container b73061e695a2
 ---> 77193a47df78
Step 6/13 : ENV GO111MODULE on
 ---> Running in 94b86a2bbfb1
Removing intermediate container 94b86a2bbfb1
 ---> 644fbf1358af
Step 7/13 : ENV TERM xterm-256color
 ---> Running in 9551f6ac6cd4
Removing intermediate container 9551f6ac6cd4
 ---> bd443ee96d37
Step 8/13 : COPY . ./src/github.com/skanehira/docui
 ---> a5c579bf9dc7
Step 9/13 : WORKDIR /go/src/github.com/skanehira/docui
 ---> Running in 385c10239283
Removing intermediate container 385c10239283
 ---> df2a4ab18f12
Step 10/13 : RUN go build
 ---> Running in 1d27e17447b4
go: finding github.com/micmonay/keybd_event v0.0.0-20190804163414-202c5b2c8150
go: finding github.com/google/go-cmp v0.2.0
go: finding github.com/docker/go-units v0.3.3
go: finding github.com/docker/go-connections v0.4.0
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.2
go: finding github.com/Microsoft/go-winio v0.4.11
go: finding github.com/opencontainers/image-spec v1.0.1
go: finding github.com/opencontainers/go-digest v1.0.0-rc1
go: finding golang.org/x/time v0.0.0-20181108054448-85acf8d2951c
go: finding google.golang.org/grpc v1.18.0
go: finding github.com/rivo/uniseg v0.0.0-20190313204849-f699dde9c340
go: finding github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78
go: finding github.com/docker/docker v0.7.3-0.20190111153827-295413c9d0e1
go: finding github.com/gorilla/mux v1.7.0
go: finding github.com/lucasb-eyer/go-colorful v1.0.1
go: finding github.com/mitchellh/go-homedir v1.1.0
go: finding github.com/gdamore/tcell v1.1.1
go: finding golang.org/x/text v0.3.2
go: finding github.com/rivo/tview v0.0.0-20190324182152-8a9e26fab0ff
go: finding gotest.tools v2.2.0+incompatible
go: finding golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
go: finding golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52
go: finding github.com/stretchr/testify v1.3.0
go: finding github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5
go: finding github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
go: finding cloud.google.com/go v0.26.0
go: finding github.com/DATA-DOG/go-sqlmock v1.3.3
go: finding github.com/mattn/go-runewidth v0.0.4
go: finding honnef.co/go/tools v0.0.0-20180728063816-88497007e858
go: finding github.com/client9/misspell v0.3.4
go: finding golang.org/x/sys v0.0.0-20190428183149-804c0c7841b5
go: finding github.com/golang/protobuf v1.2.0
go: finding golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
go: finding google.golang.org/appengine v1.1.0
go: finding github.com/golang/mock v1.1.1
go: finding github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08
go: finding github.com/docker/distribution v2.7.1+incompatible
go: finding google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
go: finding github.com/stretchr/objx v0.1.0
go: finding golang.org/x/text v0.3.0
go: finding github.com/gogo/protobuf v1.2.0
go: finding github.com/davecgh/go-spew v1.1.0
go: finding github.com/sirupsen/logrus v1.4.1
go: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0
go: finding golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3
go: finding golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: finding golang.org/x/sys v0.0.0-20180830151530-49385e6e1522
go: finding github.com/jroimartin/gocui v0.4.0
go: finding github.com/gdamore/encoding v1.0.0
go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: finding golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
go: finding golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
go: finding github.com/stretchr/objx v0.1.1
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/kisielk/gotool v1.0.0
go: finding golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: downloading github.com/docker/docker v0.7.3-0.20190111153827-295413c9d0e1
go: downloading github.com/micmonay/keybd_event v0.0.0-20190804163414-202c5b2c8150
go: downloading github.com/sirupsen/logrus v1.4.1
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/rivo/tview v0.0.0-20190324182152-8a9e26fab0ff
go: extracting github.com/micmonay/keybd_event v0.0.0-20190804163414-202c5b2c8150
go: extracting github.com/mitchellh/go-homedir v1.1.0
go: extracting github.com/sirupsen/logrus v1.4.1
go: downloading github.com/jroimartin/gocui v0.4.0
go: extracting github.com/jroimartin/gocui v0.4.0
go: extracting github.com/rivo/tview v0.0.0-20190324182152-8a9e26fab0ff
go: extracting github.com/docker/docker v0.7.3-0.20190111153827-295413c9d0e1
go: downloading github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
go: downloading golang.org/x/sys v0.0.0-20190428183149-804c0c7841b5
go: downloading github.com/gdamore/tcell v1.1.1
go: downloading github.com/mattn/go-runewidth v0.0.4
go: downloading github.com/lucasb-eyer/go-colorful v1.0.1
go: downloading github.com/docker/go-units v0.3.3
go: downloading github.com/pkg/errors v0.8.1
go: extracting github.com/mattn/go-runewidth v0.0.4
go: downloading github.com/opencontainers/go-digest v1.0.0-rc1
go: downloading github.com/docker/go-connections v0.4.0
go: downloading github.com/rivo/uniseg v0.0.0-20190313204849-f699dde9c340
go: extracting github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
go: downloading github.com/docker/distribution v2.7.1+incompatible
go: extracting github.com/docker/go-units v0.3.3
go: downloading github.com/opencontainers/image-spec v1.0.1
go: extracting github.com/pkg/errors v0.8.1
go: extracting github.com/lucasb-eyer/go-colorful v1.0.1
go: extracting github.com/docker/go-connections v0.4.0
go: downloading github.com/gogo/protobuf v1.2.0
go: extracting github.com/opencontainers/go-digest v1.0.0-rc1
go: downloading golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6
go: extracting github.com/rivo/uniseg v0.0.0-20190313204849-f699dde9c340
go: extracting github.com/opencontainers/image-spec v1.0.1
go: extracting github.com/gdamore/tcell v1.1.1
go: extracting golang.org/x/sys v0.0.0-20190428183149-804c0c7841b5
go: extracting github.com/docker/distribution v2.7.1+incompatible
go: downloading github.com/gdamore/encoding v1.0.0
go: downloading golang.org/x/text v0.3.2
go: extracting github.com/gdamore/encoding v1.0.0
go: extracting golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6
go: extracting github.com/gogo/protobuf v1.2.0
go: extracting golang.org/x/text v0.3.2
# github.com/micmonay/keybd_event
/go/pkg/mod/github.com/micmonay/keybd_event@v0.0.0-20190804163414-202c5b2c8150/keybd_event.go:19:9: undefined: initKeyB

Does you know anything?

skanehira commented 5 years ago

My Dockerfile is wrong. CGO_ENABLED must be 1. When I enable CGO_ENABLED building is success

# build docui
FROM golang:1.12.8 AS build-docui
ENV GOPATH /go
ENV GOOS linux
ENV GOARCH amd64
ENV CGO_ENABLED 0
ENV GO111MODULE on
ENV TERM xterm-256color
COPY . ./src/github.com/skanehira/docui
WORKDIR /go/src/github.com/skanehira/docui
RUN go build

# copy artifact from the build stage
FROM busybox:1.30
COPY --from=build-docui /go/src/github.com/skanehira/docui/docui /usr/local/bin/docui

ENTRYPOINT ["docui"]