mirror of
https://github.com/beego/bee.git
synced 2024-12-22 15:10:49 +00:00
Ability to specify the base image of the Docker container
This commit is contained in:
parent
81c6de6cb3
commit
699d76bc95
12
dockerize.go
12
dockerize.go
@ -34,10 +34,7 @@ var cmdDockerize = &Command{
|
||||
Run: dockerizeApp,
|
||||
}
|
||||
|
||||
const dockerBuildTemplate = `FROM library/golang:latest
|
||||
|
||||
# Get Beego Web Framework
|
||||
RUN go get github.com/astaxie/beego
|
||||
const dockerBuildTemplate = `FROM {{.BaseImage}}
|
||||
|
||||
# Godep for vendoring
|
||||
RUN go get github.com/tools/godep
|
||||
@ -60,17 +57,20 @@ EXPOSE {{.Expose}}
|
||||
`
|
||||
|
||||
type Dockerfile struct {
|
||||
BaseImage string
|
||||
Appdir string
|
||||
Entrypoint string
|
||||
Expose string
|
||||
}
|
||||
|
||||
var (
|
||||
expose string
|
||||
expose string
|
||||
baseImage string
|
||||
)
|
||||
|
||||
func init() {
|
||||
fs := flag.NewFlagSet("dockerize", flag.ContinueOnError)
|
||||
fs.StringVar(&baseImage, "image", "library/golang", "Sets the base image of the Docker container.")
|
||||
fs.StringVar(&expose, "expose", "8080", "Port to expose in the Docker container.")
|
||||
cmdDockerize.Flag = *fs
|
||||
}
|
||||
@ -86,8 +86,10 @@ func dockerizeApp(cmd *Command, args []string) int {
|
||||
|
||||
appdir := strings.Replace(dir, gopath, "", 1)
|
||||
|
||||
// TODO: Check if the base image exists in Docker Hub
|
||||
_, entrypoint := path.Split(appdir)
|
||||
dockerfile := Dockerfile{
|
||||
BaseImage: baseImage,
|
||||
Appdir: appdir,
|
||||
Entrypoint: entrypoint,
|
||||
Expose: expose,
|
||||
|
Loading…
Reference in New Issue
Block a user