diff --git a/cmd/project/functions.go b/cmd/project/functions.go index d8c387d..73b125b 100644 --- a/cmd/project/functions.go +++ b/cmd/project/functions.go @@ -623,16 +623,20 @@ func deployProject(networkVolumeId string) (endpointId string, err error) { return deployedEndpointId, nil } -func upsertProjectFromEndpointConfig() (endpointId string, err error) { +func upsertProjectFromEndpointConfig(imagePrefix string) (endpointId string, err error) { // check for presence of endpoint config, error otherwise config := loadTomlConfig("endpoint.toml") //create template based on image / config uuid := mustGetPathAs[string](config, "uuid") env := mapToApiEnv(createEnvVars(mustGetPathAs[*toml.Tree](config, "template", "env_vars"), uuid)) endpointName := mustGetPathAs[string](config, "template", "name") + imageName := mustGetPathAs[string](config, "template", "image_name") + if imagePrefix != "" { + imageName = filepath.Join(imagePrefix, imageName) + } projectEndpointTemplateId, err := api.CreateTemplate(&api.CreateTemplateInput{ Name: fmt.Sprintf("%s-%d", endpointName, time.Now().UTC().UnixMilli()), - ImageName: mustGetPathAs[string](config, "template", "image_name"), + ImageName: imageName, Env: env, DockerStartCmd: mustGetPathAs[string](config, "template", "docker_start_cmd"), IsServerless: true, diff --git a/cmd/project/project.go b/cmd/project/project.go index fcab36a..160ec1c 100644 --- a/cmd/project/project.go +++ b/cmd/project/project.go @@ -24,6 +24,7 @@ var ( setDefaultNetworkVolume bool includeEnvInDockerfile bool showPrefixInPodLogs bool + imagePrefix string ) const inputPromptPrefix string = " > " @@ -301,7 +302,7 @@ var DeployProjectFromEndpointConfigCmd = &cobra.Command{ Long: "deploys a serverless endpoint from the provided endpoint config", Run: func(cmd *cobra.Command, args []string) { fmt.Println("Deploying project...") - endpointId, err := upsertProjectFromEndpointConfig() + endpointId, err := upsertProjectFromEndpointConfig(imagePrefix) if err != nil { fmt.Println("Failed to deploy project: ", err) return @@ -376,4 +377,5 @@ func init() { StartProjectCmd.Flags().BoolVar(&showPrefixInPodLogs, "prefix-pod-logs", true, "Include the Pod ID as a prefix in log messages from the project Pod.") BuildProjectDockerfileCmd.Flags().BoolVar(&includeEnvInDockerfile, "include-env", false, "Incorporate environment variables defined in runpod.toml into the generated Dockerfile.") + DeployProjectFromEndpointConfigCmd.Flags().StringVarP(&imagePrefix, "image-prefix", "i", "", "Prefix for the full docker image name in the deployed template") }