Example #1
0
// BuildFile builds the specified docker file in the context of the specified
// directory.
func BuildFile(dockerfile, dir, tag string) string {
	if !file.Exists(dockerfile) {
		cli.Fatalf("File does not exist: %s", dockerfile)
	}
	dir = path.Resolve(dir)
	localDockerfile := ".SousDockerfile"
	if file.Exists(localDockerfile) {
		file.Remove(localDockerfile)
	}
	file.RemoveOnExit(localDockerfile)
	// If there is a .gitignore, but no .dockerignore, link it as .dockerignore
	if file.Exists(".gitignore") {
		if file.Exists(".dockerignore") {
			cli.Warn("./.dockerignore found, it is recommended to remove this so Sous can use your .gitignore")
		} else {
			file.TemporaryLink(".gitignore", ".dockerignore")
			// We try to clean this file up early, in preperation for the next build step
			defer file.Remove(".dockerignore")
		}
	}
	file.TemporaryLink(dockerfile, localDockerfile)
	// We try to clean the local Dockerfile up early, in preperation for the next build step
	defer file.Remove(localDockerfile)
	return dockerCmd("build", "-f", localDockerfile, "-t", tag, dir).Out()
}
Example #2
0
func (c *Context) TemporaryLinkResource(name string) {
	fileContents, ok := resources.Files[name]
	if !ok {
		cli.Fatalf("Cannot find resource %s, ensure go generate succeeded", name)
	}
	c.SaveFile(fileContents, name)
	file.TemporaryLink(c.FilePath(name), name)
}
Example #3
0
func (t *AppTarget) PreDockerBuild(c *core.Context) {
	if t.artifactPath == "" {
		cli.Fatalf("Artifact path not set by compile target.")
	}
	if !file.Exists(t.artifactPath) {
		cli.Fatalf("Artifact not at %s", t.artifactPath)
	}
	filename := path.Base(t.artifactPath)
	localArtifact := filename
	file.TemporaryLink(t.artifactPath, "./"+localArtifact)
	t.artifactPath = localArtifact
}