Skip to content

Commit

Permalink
Fix current dir configuration. Add docker-build-push flag
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras committed Jan 24, 2021
1 parent f2957d0 commit 6158398
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type dockerFlags struct {
DockerContext string `mapstructure:"docker-context"`
DockerSkipPull bool `mapstructure:"docker-pull-skip"`
DockerSkipPush bool `mapstructure:"docker-push-skip"`
DockerBuildpPush bool `mapstructure:"docker-build-push"`
DockerReleaseRegistry string `mapstructure:"docker-release-registry"`
DockerReleaseRepoPrefix string `mapstructure:"docker-release-group"`
DockerReleaseRepository string `mapstructure:"docker-release-repository"`
Expand Down Expand Up @@ -45,6 +46,7 @@ var (
DockerfileProfile: op.DockerfileProfile,
Context: op.DockerContext,
SkipPull: op.DockerSkipPull,
SkipPush: !op.DockerBuildpPush,
Versions: createVersions(p, op.Project),
}
docker.Build()
Expand Down Expand Up @@ -110,6 +112,7 @@ func initDocker() {
addFlag(dockerBuildCmd, "docker-file-profile", "p", "", "profile of the Dockerfile.<profile>")
addFlag(dockerBuildCmd, "docker-context", "", ".", "the docker build context")
addBoolFlag(dockerBuildCmd, "docker-pull-skip", "", false, "skip docker pull for the build")
addBoolFlag(dockerBuildCmd, "docker-build-push", "", false, "push docker images after build")

addChildCmd(dockerCmd, dockerPushCmd)
addBoolFlag(dockerPushCmd, "docker-push-skip", "", false, "skip docker push of release image to registry")
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ func initConfig() {
log.Fatal(err)
}

// Search config in home directory with name ".cobra" (without extension).
// Search confing in current directory
viper.AddConfigPath(".")
// Search config in home directory with name ".samo" (without extension).
viper.AddConfigPath(home)
viper.SetConfigName(".samo")
}
Expand Down
9 changes: 9 additions & 0 deletions docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ func (request DockerRequest) Build() {
"image": dockerImage,
"tags": tags,
}).Info("Docker build done!")

if !request.SkipPush {
request.Push()
} else {
log.WithFields(log.Fields{
"image": dockerImage,
"tags": tags,
}).Debug("Skip push docker images after build.")
}
}

// DockerPush push docker image of the project
Expand Down

0 comments on commit 6158398

Please sign in to comment.