// Build a candidate docker image that will re-tagged with the final
// tags once the e2e tests pass.
Build a candidate docker image that will re-tagged with the final
tags once the e2e tests pass.
// Build a candidate docker image that will re - tagged with the final // tags once the e2e tests pass .
func buildCandidateDockerImage(app, version, tag string) Operation {
	return func(pipeline *bk.Pipeline) {
		image := strings.ReplaceAll(app, "/", "-")
		localImage := "sourcegraph/" + image + ":" + version
		cmds := []bk.StepOpt{
			bk.Cmd(fmt.Sprintf(`echo "Building candidate %s image..."`, app)),
			bk.Env("DOCKER_BUILDKIT", "1"),
			bk.Env("IMAGE", localImage),
			bk.Env("VERSION", version),
			bk.Cmd("yes | gcloud auth configure-docker"),
		}
		if _, err := os.Stat(filepath.Join("docker-images", app)); err == nil {
			cmds = append(cmds, bk.Cmd(filepath.Join("docker-images", app, "build.sh")))
		} else {
			cmdDir := func() string {
				if _, err := os.Stat(filepath.Join("enterprise/cmd", app)); err != nil {
					fmt.Fprintf(os.Stderr, "github.com/sourcegraph/sourcegraph/enterprise/cmd/%s does not exist so building github.com/sourcegraph/sourcegraph/cmd/%s instead\n", app, app)
					return "cmd/" + app
				}
				return "enterprise/cmd/" + app
			}()
			preBuildScript := cmdDir + "/pre-build.sh"
			if _, err := os.Stat(preBuildScript); err == nil {
				cmds = append(cmds, bk.Cmd(preBuildScript))
			}
			cmds = append(cmds, bk.Cmd(cmdDir+"/build.sh"))
		}
		devImage := fmt.Sprintf("%s/%s", images.SourcegraphDockerDevRegistry, image)
		cmds = append(cmds,
			bk.Cmd(fmt.Sprintf("docker tag %s %s:%s", localImage, devImage, tag)),
			bk.Cmd(fmt.Sprintf("docker push %s:%s", devImage, tag)),
		)
		pipeline.AddStep(fmt.Sprintf(":docker: :construction: %s", app), cmds...)
	}
}
func buildCandidateDockerImage ( app , version , tag string ) Operation { return func ( pipeline * bk . Pipeline ) { image := strings . ReplaceAll ( app , " " , " " ) localImage := " " + image + " " + version cmds := [ ] bk . StepOpt { bk . Cmd ( fmt . Sprintf ( `echo "Building candidate %s image..."` , app ) ) , bk . Env ( " " , " " ) , bk . Env ( " " , localImage ) , bk . Env ( " " , version ) , bk . Cmd ( " " ) , } if _ , err := os . Stat ( filepath . Join ( " " , app ) ) ; err == nil { cmds = append ( cmds , bk . Cmd ( filepath . Join ( " " , app , " " ) ) ) } else { cmdDir := func ( ) string { if _ , err := os . Stat ( filepath . Join ( " " , app ) ) ; err != nil { fmt . Fprintf ( os . Stderr , " \n " , app , app ) return " " + app } return " " + app } ( ) preBuildScript := cmdDir + " " if _ , err := os . Stat ( preBuildScript ) ; err == nil { cmds = append ( cmds , bk . Cmd ( preBuildScript ) ) } cmds = append ( cmds , bk . Cmd ( cmdDir + " " ) ) } devImage := fmt . Sprintf ( " " , images . SourcegraphDockerDevRegistry , image ) cmds = append ( cmds , bk . Cmd ( fmt . Sprintf ( " " , localImage , devImage , tag ) ) , bk . Cmd ( fmt . Sprintf ( " " , devImage , tag ) ) , ) pipeline . AddStep ( fmt . Sprintf ( " " , app ) , cmds ... ) } }
Build a candidate docker image that will re-tagged with the final
tags once the e2e tests pass.
Build a candidate docker image that will re - tagged with the final tags once the e2e tests pass .
// Building Docker image located under $REPO_ROOT/docker-images/ // Building Docker images located under $REPO_ROOT/cmd/ // Retag the local image for dev registry // Publish tagged image