Commit 01171764 authored by duanjinfei's avatar duanjinfei

add replace docker url condition

parent b7e9d883
...@@ -19,6 +19,7 @@ type Config struct { ...@@ -19,6 +19,7 @@ type Config struct {
ExternalIp string ExternalIp string
SignPublicAddress common.Address SignPublicAddress common.Address
SignPrivateKey *ecdsa.PrivateKey SignPrivateKey *ecdsa.PrivateKey
IsReplaceDockerUrl string `json:"is_replace_docker_url"`
NmSeed string `json:"nm_seed" mapstructure:"nm_seed"` NmSeed string `json:"nm_seed" mapstructure:"nm_seed"`
HeartRespTimeSecond int64 `json:"heart_response" mapstructure:"heart_response"` HeartRespTimeSecond int64 `json:"heart_response" mapstructure:"heart_response"`
NodeManagerNum int64 `json:"node_manager_num" mapstructure:"node_manager_num"` NodeManagerNum int64 `json:"node_manager_num" mapstructure:"node_manager_num"`
......
{ {
"nm_seed": "43.198.29.144:10001", "nm_seed": "39.99.245.15:10001",
"api_url": "https://aigic.ai/admin/api/task/taskheat", "api_url": "https://aigic.ai/admin/api/task/taskheat",
"node_manager_num": 1, "node_manager_num": 1,
"heart_response": 60, "heart_response": 60,
...@@ -11,5 +11,5 @@ ...@@ -11,5 +11,5 @@
"op_sys": "linux", "op_sys": "linux",
"replicate_image_name_suffix": "docker.aigic.ai/ai", "replicate_image_name_suffix": "docker.aigic.ai/ai",
"is_stop_last_container": true, "is_stop_last_container": true,
"is_replace_url": "docker.aigic.17xuexi.com" "is_replace_docker_url": "docker.ai.17xuexi.com"
} }
\ No newline at end of file
...@@ -17,6 +17,7 @@ import ( ...@@ -17,6 +17,7 @@ import (
"io" "io"
"net/http" "net/http"
"strconv" "strconv"
"strings"
"time" "time"
) )
...@@ -297,6 +298,14 @@ func (d *DockerOp) PsImageNameMap() (map[string]bool, error) { ...@@ -297,6 +298,14 @@ func (d *DockerOp) PsImageNameMap() (map[string]bool, error) {
} }
func (d *DockerOp) PullImage(info *models.ModelInfo) { func (d *DockerOp) PullImage(info *models.ModelInfo) {
if conf.GetConfig().IsReplaceDockerUrl != "" {
split := strings.Split(info.ImageName, "/")
if len(split) > 2 {
info.ImageName = fmt.Sprintf("%s/%s/%s", conf.GetConfig().IsReplaceDockerUrl, split[1], split[2])
} else {
info.ImageName = fmt.Sprintf("%s/%s/%s", conf.GetConfig().IsReplaceDockerUrl, split[0], split[1])
}
}
response, err := d.dockerClient.ImagePull(context.Background(), info.ImageName, types.ImagePullOptions{}) response, err := d.dockerClient.ImagePull(context.Background(), info.ImageName, types.ImagePullOptions{})
if err != nil { if err != nil {
log.Errorf("Error pulling image from %s: %v", info.ImageName, err) log.Errorf("Error pulling image from %s: %v", info.ImageName, err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment