コード例 #1
0
ファイル: compile_target.go プロジェクト: liamjbennett/sous
func (t *CompileTarget) DockerRun(c *core.Context) *docker.Run {
	containerName := t.ContainerName(c)
	run := docker.NewRun(c.DockerTag())
	run.Name = containerName
	run.AddEnv("ARTIFACT_NAME", t.artifactName(c))
	uid := cmd.Stdout("id", "-u")
	gid := cmd.Stdout("id", "-g")
	artifactOwner := fmt.Sprintf("%s:%s", uid, gid)
	run.AddEnv("ARTIFACT_OWNER", artifactOwner)
	artDir := t.artifactDir(c)
	dir.EnsureExists(artDir)
	run.AddVolume(artDir, "/artifacts")
	run.AddVolume(c.WorkDir, "/wd")
	binName := fmt.Sprintf("%s-%s", c.CanonicalPackageName(), c.BuildVersion)
	run.Command = fmt.Sprintf("[ -d Godeps ] && godep go build -o %s || go build -o %s",
		binName, binName)
	return run
}
コード例 #2
0
ファイル: app_target.go プロジェクト: liamjbennett/sous
func (t *AppTarget) Dockerfile(c *core.Context) *docker.Dockerfile {
	if t.artifactPath == "" {
		// Actually, it is first set by compile target, then the PreDockerBuild
		// step links it into the WD and resets artifactPath to a local, relative
		// path.
		t.artifactPath = "<¡ artifact path set by compile target !>"
	}
	df := &docker.Dockerfile{}
	df.From = t.pack.baseImageTag("app")

	// Since the artifact is tar.gz, and the dest is a directory, docker automatically unpacks it.
	df.AddAdd(t.artifactPath, "/srv/app/")
	// Pick out the contents of NPM start to invoke directly (using npm start in
	// production shields the app from signals, which are required to be handled by
	// the app itself to do graceful shutdown.
	df.Entrypoint = []string{
		fmt.Sprintf("/srv/app/%s-%s", c.CanonicalPackageName(), c.BuildVersion),
	}
	return df
}
コード例 #3
0
ファイル: compile_target.go プロジェクト: liamjbennett/sous
// ContainerName returns the name that will be given to the next container we
// build. This does not have to change for each build, Sous will automatically
// deleted any pre-existing containers with this name before creating a new one.
func (t *CompileTarget) ContainerName(c *core.Context) string {
	return fmt.Sprintf("%s_reusable-builder", c.CanonicalPackageName())
}
コード例 #4
0
ファイル: compile_target.go プロジェクト: liamjbennett/sous
func (t *CompileTarget) artifactName(c *core.Context) string {
	return fmt.Sprintf("%s-%s-%s-%d", c.CanonicalPackageName(), c.BuildVersion, c.Git.CommitSHA, c.BuildNumber())
}
コード例 #5
0
ファイル: test_target.go プロジェクト: liamjbennett/sous
func (t *TestTarget) ContainerName(c *core.Context) string {
	return c.CanonicalPackageName() + "_test"
}
コード例 #6
0
ファイル: app_target.go プロジェクト: liamjbennett/sous
func (t *AppTarget) ContainerName(c *core.Context) string {
	return c.CanonicalPackageName()
}
コード例 #7
0
ファイル: test_target.go プロジェクト: liamjbennett/sous
func (t *TestTarget) ContainerName(c *core.Context) string {
	return fmt.Sprintf("%s_test-container", c.CanonicalPackageName())
}