Skip to content

bee dockerize produced Dockerfile fails (due to use of godep) #712

@crush-157

Description

@crush-157

I have created a new beego app:

$ bee new quickstart
$ cd quickstart
$ bee run

So it's vanilla but working.

I then run:

$ bee dockerize
$ docker build -t beego-test .

The docker build fails with the following output:

Sending build context to Docker daemon  14.56MB
Step 1/10 : FROM library/golang
 ---> baaca3151cdb
Step 2/10 : RUN go get github.com/tools/godep
 ---> Using cache
 ---> 1142429ea03e
Step 3/10 : RUN CGO_ENABLED=0 go install -a std
 ---> Using cache
 ---> eba8f171d884
Step 4/10 : ENV APP_DIR $GOPATH/src/quickstart
 ---> Using cache
 ---> bd71a713d1ff
Step 5/10 : RUN mkdir -p $APP_DIR
 ---> Using cache
 ---> d945a5880667
Step 6/10 : ENTRYPOINT (cd $APP_DIR && ./quickstart)
 ---> Using cache
 ---> c68868e6049b
Step 7/10 : ADD . $APP_DIR
 ---> Using cache
 ---> e47cc4b72934
Step 8/10 : RUN cd $APP_DIR && CGO_ENABLED=0 godep go build -ldflags '-d -w -s'
 ---> Running in e96e84b45040
godep: No Godeps found (or in any parent directory)
The command '/bin/sh -c cd $APP_DIR && CGO_ENABLED=0 godep go build -ldflags '-d -w -s'' returned a non-zero code: 1

The main issue seems to be use of godep instead of dep.

I have edited the bee dockerize generated Dockerfile as follows:

FROM library/golang

RUN apt-get update
RUN apt-get install -y go-dep

# Recompile the standard library without CGO
RUN CGO_ENABLED=0 go install -a std

WORKDIR $GOPATH/src/quickstart
COPY . .

# Compile the binary and statically link
RUN dep ensure
RUN go mod vendor
RUN CGO_ENABLED=0 go build -ldflags '-d -w -s'

# Set the entrypoint
ENTRYPOINT ./quickstart

EXPOSE 8080

And lo, it worketh.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions