Beispiel #1
0
func (f Focker) RunStager(writer io.Writer, appDir string) error {
	prepareStagingFilesystem(utils.CloudfockerHome())
	stagingAppDir := prepareStagingApp(appDir, utils.CloudfockerHome()+"/staging")
	runConfig := config.NewStageRunConfig(stagingAppDir)
	cli, Stdout, stdoutpipe := docker.GetNewClient()
	docker.RunConfiguredContainer(cli, Stdout, stdoutpipe, writer, runConfig)
	f.DeleteContainer(writer, runConfig.ContainerName)
	return stager.ValidateStagedApp(utils.CloudfockerHome())
}
Beispiel #2
0
func (f Focker) RunRuntime(writer io.Writer) {
	prepareRuntimeFilesystem(utils.CloudfockerHome())
	runConfig := config.NewRuntimeRunConfig(utils.CloudfockerHome() + "/droplet")
	cli, Stdout, stdoutpipe := docker.GetNewClient()
	if docker.GetContainerId(cli, Stdout, stdoutpipe, runConfig.ContainerName) != "" {
		fmt.Println("Deleting running runtime container...")
		f.StopRuntime(writer)
	}
	cli, Stdout, stdoutpipe = docker.GetNewClient()
	docker.RunConfiguredContainer(cli, Stdout, stdoutpipe, writer, runConfig)
	fmt.Fprintln(writer, "Connect to your running application at http://localhost:8080/")
}
Beispiel #3
0
func NewStageRunConfig(cloudfoundryAppDir string) (runConfig *RunConfig) {
	runConfig = &RunConfig{
		ContainerName: "cloudfocker-staging",
		Mounts: map[string]string{
			cloudfoundryAppDir:                      "/app",
			utils.CloudfockerHome() + "/droplet":    "/tmp/droplet",
			utils.CloudfockerHome() + "/result":     "/tmp/result",
			utils.CloudfockerHome() + "/buildpacks": "/tmp/cloudfockerbuildpacks",
			utils.CloudfockerHome() + "/cache":      "/tmp/cache",
			utils.CloudfockerHome() + "/focker":     "/focker",
		},
		ImageTag: "cloudfocker-base:latest",
		Command:  []string{"/focker/fock", "stage", "internal"},
	}
	return
}
Beispiel #4
0
func (Focker) ListBuildpacks(writer io.Writer, buildpackDirOptional ...string) {
	buildpackDir := utils.CloudfockerHome() + "/buildpacks"
	if len(buildpackDirOptional) > 0 {
		buildpackDir = buildpackDirOptional[0]
	}
	buildpack.List(writer, abs(buildpackDir))
}
Beispiel #5
0
func (Focker) DeleteBuildpack(writer io.Writer, bpack string, buildpackDirOptional ...string) {
	buildpackDir := utils.CloudfockerHome() + "/buildpacks"
	if len(buildpackDirOptional) > 0 {
		buildpackDir = buildpackDirOptional[0]
	}
	buildpack.Delete(writer, bpack, abs(buildpackDir))
}
Beispiel #6
0
func (Focker) AddBuildpack(writer io.Writer, url string, buildpackDirOptional ...string) {
	buildpackDir := utils.CloudfockerHome() + "/buildpacks"
	if len(buildpackDirOptional) > 0 {
		buildpackDir = buildpackDirOptional[0]
	}
	buildpack.Add(writer, url, abs(buildpackDir))
}
Beispiel #7
0
				os.Setenv("FOCKER_ROOTFS_URL", "")
				Expect(utils.GetRootfsUrl()).To(Equal("https://s3.amazonaws.com/blob.cfblob.com/fee97b71-17d7-4fab-a5b0-69d4112521e6"))
			})
		})
		Context("with a rootfs env var set", func() {
			It("should return the specified URL", func() {
				os.Setenv("FOCKER_ROOTFS_URL", "dave")
				Expect(utils.GetRootfsUrl()).To(Equal("dave"))
			})
		})
	})
	Describe("Getting the CLOUDFOCKER_HOME", func() {
		Context("without a CLOUDFOCKER_HOME env var set", func() {
			It("should return the default URL", func() {
				os.Setenv("CLOUDFOCKER_HOME", "")
				Expect(utils.CloudfockerHome()).To(Equal(os.Getenv("HOME") + "/.cloudfocker"))
			})
		})
		Context("with a CLOUDFOCKER_HOME env var set", func() {
			It("should return the specified URL", func() {
				os.Setenv("CLOUDFOCKER_HOME", "/dave")
				Expect(utils.CloudfockerHome()).To(Equal("/dave"))
			})
		})
	})
	Describe("Creating and cleaning application directories", func() {
		Context("without a previously staged application", func() {
			It("should create the correct directory structure", func() {
				cloudfockerHome, _ := ioutil.TempDir(os.TempDir(), "utils-test-create-clean")
				err := utils.CreateAndCleanAppDirs(cloudfockerHome)
				Expect(err).ShouldNot(HaveOccurred())