コード例 #1
0
ファイル: analyzer.go プロジェクト: kamerblauwlicht/starter
func (a *Analyzer) FillServices(services *[]*common.Service) error {
	service := a.GetOrCreateWebService(services)
	service.Ports = []*common.PortMapping{common.NewPortMapping()}
	isRails, _ := common.GetGemVersion(a.Gemfile, "rails")

	if service.Command == "" {
		if isRails {
			service.Command = "bundle exec rails server -e _env:RAILS_ENV"
			service.Ports[0].Container = "3000"
		} else {
			service.Command = "bundle exec rackup -E _env:RACK_ENV"
			service.Ports[0].Container = "9292"
		}
		a.Messages.Add("No command was defined for 'web' service so '" + service.Command + "' was assumed. Please make sure this is using a production server.")
	} else {
		var err error
		hasFoundServer, server := a.detectWebServer(service.Command)
		service.Ports[0].Container, err = a.FindPort(hasFoundServer, server, &service.Command)

		if err != nil {
			return err
		}
	}

	if isRails {
		service.BuildCommand = a.AskForCommand("/bin/sh -c \"RAILS_ENV=_env:RAILS_ENV bundle exec rake db:schema:load\"", "build")
		service.DeployCommand = a.AskForCommand("/bin/sh -c \"RAILS_ENV=_env:RAILS_ENV bundle exec rake db:migrate\"", "deployment")
	} else {
		service.BuildCommand = a.AskForCommand("", "build")
		service.DeployCommand = a.AskForCommand("", "deployment")
	}

	return nil
}
コード例 #2
0
ファイル: analyzer.go プロジェクト: kamerblauwlicht/starter
func (a *Analyzer) GuessPackages() *common.Lister {
	packages := common.NewLister()
	common.PrintlnL2("Analyzing dependencies")
	if hasRmagick, _ := common.GetGemVersion(a.Gemfile, "rmagick", "refile-mini_magick", "mini_magick"); hasRmagick {
		packages.Add("imagemagick", "libmagickwand-dev")
		common.PrintlnL2("Found Image Magick")
	}

	if hasSqlite, _ := common.GetGemVersion(a.Gemfile, "sqlite"); hasSqlite {
		packages.Add("libsqlite3-dev")
		common.PrintlnL2("Found sqlite")
	}

	if hasMemcache, _ := common.GetGemVersion(a.Gemfile, "dalli"); hasMemcache {
		packages.Add("memcached")
		common.PrintlnL2("Found Memcache")
	}
	return packages
}
コード例 #3
0
ファイル: analyzer.go プロジェクト: kamerblauwlicht/starter
func (a *Analyzer) FindDatabases() *common.Lister {
	dbs := common.NewLister()
	if hasMysql, _ := common.GetGemVersion(a.Gemfile, "mysql2"); hasMysql {
		dbs.Add("mysql")
	}

	if hasPg, _ := common.GetGemVersion(a.Gemfile, "pg"); hasPg {
		dbs.Add("postgresql")
	}

	if hasRedis, _ := common.GetGemVersion(a.Gemfile, "redis", "redis-rails"); hasRedis {
		dbs.Add("redis")
	}

	if hasMongoDB, _ := common.GetGemVersion(a.Gemfile, "mongo", "mongo_mapper", "dm-mongo-adapter", "mongoid"); hasMongoDB {
		dbs.Add("mongodb")
	}

	if hasElasticsearch, _ := common.GetGemVersion(a.Gemfile, "elasticsearch", "tire", "flex", "chewy"); hasElasticsearch {
		dbs.Add("elasticsearch")
	}

	if hasDatabaseYaml := common.FileExists("config/database.yml"); hasDatabaseYaml {
		common.PrintlnL2("Found config/database.yml")
		a.Messages.Add(
			fmt.Sprintf("%s %s-> %s",
				"database.yml: Make sure you are using environment variables.",
				common.MsgReset, "http://help.cloud66.com/deployment/environment-variables"))
	}

	if hasMongoIdYaml := common.FileExists("config/mongoid.yml"); hasMongoIdYaml {
		common.PrintlnL2("Found config/mongoid.yml")
		a.Messages.Add(
			fmt.Sprintf("%s %s-> %s",
				"mongoid.yml: Make sure you are using environment variables.",
				common.MsgReset, "http://help.cloud66.com/deployment/environment-variables"))
	}
	return dbs
}
コード例 #4
0
ファイル: analyzer.go プロジェクト: kamerblauwlicht/starter
func (a *Analyzer) HasPackage(pack string) bool {
	hasFound, _ := common.GetGemVersion(a.Gemfile, pack)
	return hasFound
}