From e3de9ed86d7cbaaafb365b5d406be777440a5eed Mon Sep 17 00:00:00 2001 From: Ewan Slater Date: Fri, 7 Aug 2020 22:32:13 +0100 Subject: [PATCH 1/2] updated Dockerfile template --- cmd/commands/dockerize/dockerize.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/commands/dockerize/dockerize.go b/cmd/commands/dockerize/dockerize.go index 3aad82e..a5bbf9f 100644 --- a/cmd/commands/dockerize/dockerize.go +++ b/cmd/commands/dockerize/dockerize.go @@ -29,22 +29,23 @@ 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 dep ensure +RUN go mod vendor +RUN CGO_ENABLED=0 go build -ldflags '-d -w -s' + +# Set the entrypoint +ENTRYPOINT ./{{.Entrypoint}} EXPOSE {{.Expose}} ` @@ -62,7 +63,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" From f7d13000f96026faa62342a769b700ed136a3b0e Mon Sep 17 00:00:00 2001 From: Ewan Slater Date: Fri, 7 Aug 2020 22:34:07 +0100 Subject: [PATCH 2/2] deleted commented code --- cmd/commands/dockerize/dockerize.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/commands/dockerize/dockerize.go b/cmd/commands/dockerize/dockerize.go index a5bbf9f..114b332 100644 --- a/cmd/commands/dockerize/dockerize.go +++ b/cmd/commands/dockerize/dockerize.go @@ -40,7 +40,6 @@ COPY . . # Compile the binary and statically link RUN dep init -# RUN dep ensure RUN go mod vendor RUN CGO_ENABLED=0 go build -ldflags '-d -w -s'