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