2022-09-22 16:16:04 +08:00
|
|
|
package compose
|
|
|
|
|
2022-10-11 16:27:58 +08:00
|
|
|
import (
|
2023-02-14 14:19:26 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
2022-10-11 16:27:58 +08:00
|
|
|
)
|
2022-09-22 16:16:04 +08:00
|
|
|
|
2023-07-06 16:30:22 +08:00
|
|
|
func Pull(filePath string) (string, error) {
|
|
|
|
stdout, err := cmd.Execf("docker-compose -f %s pull", filePath)
|
|
|
|
return stdout, err
|
|
|
|
}
|
|
|
|
|
2022-09-22 16:16:04 +08:00
|
|
|
func Up(filePath string) (string, error) {
|
2023-06-25 22:00:14 +08:00
|
|
|
stdout, err := cmd.Execf("docker-compose -f %s up -d", filePath)
|
2023-02-27 17:22:14 +08:00
|
|
|
return stdout, err
|
2022-09-22 16:16:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func Down(filePath string) (string, error) {
|
2023-06-25 22:00:14 +08:00
|
|
|
stdout, err := cmd.Execf("docker-compose -f %s down --remove-orphans", filePath)
|
2023-02-27 17:22:14 +08:00
|
|
|
return stdout, err
|
2022-12-06 15:59:25 +08:00
|
|
|
}
|
|
|
|
|
2023-03-01 11:51:49 +08:00
|
|
|
func Start(filePath string) (string, error) {
|
2023-06-25 22:00:14 +08:00
|
|
|
stdout, err := cmd.Execf("docker-compose -f %s start", filePath)
|
2023-03-01 11:51:49 +08:00
|
|
|
return stdout, err
|
|
|
|
}
|
|
|
|
|
2022-12-06 15:59:25 +08:00
|
|
|
func Stop(filePath string) (string, error) {
|
2023-06-25 22:00:14 +08:00
|
|
|
stdout, err := cmd.Execf("docker-compose -f %s stop", filePath)
|
2023-02-27 17:22:14 +08:00
|
|
|
return stdout, err
|
2022-09-22 16:16:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func Restart(filePath string) (string, error) {
|
2023-06-25 22:00:14 +08:00
|
|
|
stdout, err := cmd.Execf("docker-compose -f %s restart", filePath)
|
2023-02-27 17:22:14 +08:00
|
|
|
return stdout, err
|
2022-09-22 16:16:04 +08:00
|
|
|
}
|
2022-09-26 22:54:38 +08:00
|
|
|
|
2022-12-06 15:05:13 +08:00
|
|
|
func Operate(filePath, operation string) (string, error) {
|
2023-06-25 22:00:14 +08:00
|
|
|
stdout, err := cmd.Execf("docker-compose -f %s %s", filePath, operation)
|
2023-02-27 17:22:14 +08:00
|
|
|
return stdout, err
|
2022-09-26 22:54:38 +08:00
|
|
|
}
|