Skip to content

Commit

Permalink
need to map in dockerhub username as image prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
DireLines committed Aug 24, 2024
1 parent 7322e70 commit c09f779
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions cmd/project/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion cmd/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
setDefaultNetworkVolume bool
includeEnvInDockerfile bool
showPrefixInPodLogs bool
imagePrefix string
)

const inputPromptPrefix string = " > "
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
}

0 comments on commit c09f779

Please sign in to comment.