diff --git a/docker/w9deployment/Dockerfile b/docker/w9deployment/Dockerfile index c87af473..d3427c12 100644 --- a/docker/w9deployment/Dockerfile +++ b/docker/w9deployment/Dockerfile @@ -9,5 +9,4 @@ RUN chmod +x /init_portainer FROM portainer/portainer-ce:2.19.0 LABEL maintainer="websoft9" LABEL version="2.19.0" - COPY --from=builder /init_portainer / \ No newline at end of file diff --git a/docker/w9deployment/init_portainer.go b/docker/w9deployment/init_portainer.go index f89b94f2..9dbbaa18 100644 --- a/docker/w9deployment/init_portainer.go +++ b/docker/w9deployment/init_portainer.go @@ -7,7 +7,6 @@ import ( "os" "os/exec" "time" - "encoding/json" ) func main() { @@ -42,7 +41,7 @@ func main() { } } - content, err := readPasswordFromFile(filePath) + content, err := ioutil.ReadFile(filePath) if err != nil { fmt.Println("read file error:", err) return @@ -75,26 +74,7 @@ func generatePassword(length int) string { return string(password) } -func readPasswordFromFile(filePath string) (string, error) { - data, err := ioutil.ReadFile(filePath) - if err != nil { - return "", err - } - var passwordMap map[string]string - err = json.Unmarshal(data, &passwordMap) - if err != nil { - return "", err - } - password := passwordMap["password"] - return password, nil -} +func writeToFile(filePath , content string) error { -func writeToFile(filePath, password string) error { - data := map[string]string{"username": "admin", "password": password} - jsonData, err := json.Marshal(data) - if err != nil { - return err - } - err = ioutil.WriteFile(filePath, jsonData, 0755) - return err + return ioutil.WriteFile(filePath , []byte(content), 0755) } \ No newline at end of file