2021-07-22 16:32:26 +02:00

49 lines
1.1 KiB
Go

// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.
package cmd
import (
"os"
"time"
"github.com/gitpod-io/gitpod/image-builder/bob/pkg/builder"
log "github.com/gitpod-io/gitpod/common-go/log"
"github.com/spf13/cobra"
)
// buildCmd represents the build command
var buildCmd = &cobra.Command{
Use: "build",
Short: "Runs the image build and is configured using environment variables (see pkg/builder/config.go for details)",
Run: func(cmd *cobra.Command, args []string) {
if os.Geteuid() != 0 {
log.Fatal("must run as root")
}
// give the headless listener some time to attach
time.Sleep(1 * time.Second)
cfg, err := builder.GetConfigFromEnv()
if err != nil {
log.WithError(err).Fatal("cannot get config")
return
}
b := &builder.Builder{
Config: cfg,
}
err = b.Build()
if err != nil {
log.WithError(err).Fatal("build failed")
return
}
},
}
func init() {
rootCmd.AddCommand(buildCmd)
}