Skip to content

Updated Dockerfile template (fixes beego/bee#712) #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions cmd/commands/dockerize/dockerize.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ import (
)

const dockerBuildTemplate = `FROM {{.BaseImage}}

# Godep for vendoring
RUN go get github.com/tools/godep
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

ENV APP_DIR $GOPATH{{.Appdir}}
RUN mkdir -p $APP_DIR

# Set the entrypoint
ENTRYPOINT (cd $APP_DIR && ./{{.Entrypoint}})
ADD . $APP_DIR
WORKDIR $GOPATH{{.Appdir}}
COPY . .

# Compile the binary and statically link
RUN cd $APP_DIR && CGO_ENABLED=0 godep go build -ldflags '-d -w -s'
RUN dep init
RUN go mod vendor
RUN CGO_ENABLED=0 go build -ldflags '-d -w -s'

# Set the entrypoint
ENTRYPOINT ./{{.Entrypoint}}

EXPOSE {{.Expose}}
`
Expand All @@ -62,7 +62,7 @@ var CmdDockerize = &commands.Command{
UsageLine: "dockerize",
Short: "Generates a Dockerfile for your Beego application",
Long: `Dockerize generates a Dockerfile for your Beego Web Application.
The Dockerfile will compile, get the dependencies with {{"godep"|bold}}, and set the entrypoint.
The Dockerfile will compile, get the dependencies with {{"dep"|bold}}, and set the entrypoint.

{{"Example:"|bold}}
$ bee dockerize -expose="3000,80,25"
Expand Down