Skip to content

Commit

Permalink
Merge pull request #537 from php-coder/extended_build_improvements
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Jul 14, 2016
2 parents 516ec95 + 215226b commit fdd091d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/s2i/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ $ s2i build . centos/ruby-22-centos7 hello-world-app
buildCmd.Flags().StringVarP(&(cfg.AssembleUser), "assemble-user", "", "", "Specify the user to run assemble with")
buildCmd.Flags().StringVarP(&(cfg.ContextDir), "context-dir", "", "", "Specify the sub-directory inside the repository with the application sources")
buildCmd.Flags().StringVarP(&(cfg.ExcludeRegExp), "exclude", "", tar.DefaultExclusionPattern.String(), "Regular expression for selecting files from the source tree to exclude from the build, where the default excludes the '.git' directory (see https://golang.org/pkg/regexp for syntax, but note that \"\" will be interpreted as allow all files and exclude no files)")
buildCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts-url", "s", "", "Specify a URL for the assemble and run scripts")
buildCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts-url", "s", "", "Specify a URL for the assemble, assemble-runtime and run scripts")
buildCmd.Flags().StringVar(&(oldScriptsFlag), "scripts", "", "DEPRECATED: Specify a URL for the assemble and run scripts")
buildCmd.Flags().BoolVar(&(useConfig), "use-config", false, "Store command line options to .s2ifile")
buildCmd.Flags().StringVarP(&(cfg.EnvironmentFile), "environment-file", "E", "", "Specify the path to the file with environment")
buildCmd.Flags().StringVarP(&(cfg.DisplayName), "application-name", "n", "", "Specify the display name for the application (default: output image name)")
buildCmd.Flags().StringVarP(&(cfg.Description), "description", "", "", "Specify the description of the application")
buildCmd.Flags().VarP(&(cfg.AllowedUIDs), "allowed-uids", "u", "Specify a range of allowed user ids for the builder image")
buildCmd.Flags().VarP(&(cfg.AllowedUIDs), "allowed-uids", "u", "Specify a range of allowed user ids for the builder and runtime images")
buildCmd.Flags().VarP(&(cfg.Injections), "inject", "i", "Specify a directory to inject into the assemble container")
buildCmd.Flags().VarP(&(cfg.BuildVolumes), "volume", "v", "Specify a volume to mount into the assemble container")
buildCmd.Flags().StringSliceVar(&(cfg.DropCapabilities), "cap-drop", []string{}, "Specify a comma-separated list of capabilities to drop when running Docker containers")
Expand Down
21 changes: 7 additions & 14 deletions pkg/build/strategies/sti/postexecutorstep.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,12 @@ func (step *startRuntimeImageAndUploadFilesStep) execute(ctx *postExecutorStepCo
artifactsDir := filepath.Join(step.builder.config.WorkingDir, api.RuntimeArtifactsDir)

// We copy scripts to a directory with artifacts to upload files in one shot
if err := step.copyScriptIfNeeded(api.AssembleRuntime, artifactsDir); err != nil {
return err
}

// "run" script must be inside of "scripts" subdir, see createCommandForExecutingRunScript()
if err := step.copyScriptIfNeeded(api.Run, filepath.Join(artifactsDir, "scripts")); err != nil {
return err
for _, script := range []string{api.AssembleRuntime, api.Run} {
// scripts must be inside of "scripts" subdir, see createCommandForExecutingRunScript()
destinationDir := filepath.Join(artifactsDir, "scripts")
if err := step.copyScriptIfNeeded(script, destinationDir); err != nil {
return err
}
}

image := step.builder.config.RuntimeImage
Expand All @@ -239,11 +238,6 @@ func (step *startRuntimeImageAndUploadFilesStep) execute(ctx *postExecutorStepCo
return fmt.Errorf("Couldn't get working dir of %q image: %v", image, err)
}

user, err := step.docker.GetImageUser(image)
if err != nil {
return fmt.Errorf("Couldn't get user of %q image: %v", image, err)
}

commandBaseDir := workDir
useExternalAssembleScript := step.builder.externalScripts[api.AssembleRuntime]
if !useExternalAssembleScript {
Expand All @@ -259,7 +253,7 @@ func (step *startRuntimeImageAndUploadFilesStep) execute(ctx *postExecutorStepCo
}

cmd := fmt.Sprintf(
"while [ ! -f %q ]; do sleep 0.5; done; %s/%s; exit $?",
"while [ ! -f %q ]; do sleep 0.5; done; %s/scripts/%s; exit $?",
lastFileDstPath,
commandBaseDir,
api.AssembleRuntime,
Expand All @@ -276,7 +270,6 @@ func (step *startRuntimeImageAndUploadFilesStep) execute(ctx *postExecutorStepCo
CapDrop: step.builder.config.DropCapabilities,
PostExec: step.builder.postExecutor,
Env: step.builder.env,
User: user,
}

opts.OnStart = func(containerID string) error {
Expand Down

0 comments on commit fdd091d

Please sign in to comment.