From c16dd1e6000c968fae5a17f59e7866a52eafbc42 Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Tue, 17 Oct 2023 14:42:09 +0800 Subject: [PATCH] portainer --- docker/deployment/Dockerfile | 2 +- docker/deployment/init_portainer.go | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/docker/deployment/Dockerfile b/docker/deployment/Dockerfile index 17f24ca7..d8480a3c 100644 --- a/docker/deployment/Dockerfile +++ b/docker/deployment/Dockerfile @@ -6,7 +6,7 @@ RUN go build -o init_portainer /init_portainer.go RUN chmod +x /init_portainer # step2: copy build go program to portainer -# Dockerfile refer to: https://github.com/portainer/portainer/blob/develop/build/linux/Dockerfile +# Dockerfile refer to: https://github.com/portainer/portainer/blob/develop/build/linux/Dockerfile FROM portainer/portainer-ce:2.19.0 LABEL maintainer="websoft9" LABEL version="2.19.0" diff --git a/docker/deployment/init_portainer.go b/docker/deployment/init_portainer.go index fb625b32..e2d57d12 100644 --- a/docker/deployment/init_portainer.go +++ b/docker/deployment/init_portainer.go @@ -23,28 +23,22 @@ func main() { fmt.Println("write file error:", err) return } + // call portainer + cmd := exec.Command("./portainer", "--admin-password-file", filePath) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + err = cmd.Run() + if err != nil { + fmt.Println("error running compiled_program:", err) + return + } }else{ fmt.Println("credential is exist, skip it.") cmd := exec.Command("./portainer") cmd.Run() } - content, err := ioutil.ReadFile(filePath) - if err != nil { - fmt.Println("read file error:", err) - return - } - - // call portainer - cmd := exec.Command("./portainer", "--admin-password-file", filePath) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - err = cmd.Run() - if err != nil { - fmt.Println("error running compiled_program:", err) - return - } } func generatePassword(length int) string {