Skip to content

Commit fabf33a

Browse files
feat: Ensure compatibility with docker-compose commands. (#9117)
1 parent 211c956 commit fabf33a

File tree

12 files changed

+87
-10
lines changed

12 files changed

+87
-10
lines changed

agent/global/config.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package global
22

33
type ServerConfig struct {
4-
Base Base `mapstructure:"base"`
5-
RemoteURL RemoteURL `mapstructure:"remote_url"`
6-
Log LogConfig `mapstructure:"log"`
4+
Base Base `mapstructure:"base"`
5+
RemoteURL RemoteURL `mapstructure:"remote_url"`
6+
Log LogConfig `mapstructure:"log"`
7+
DockerConfig DockerConfig
78
}
89

910
type Base struct {
@@ -51,3 +52,7 @@ type LogConfig struct {
5152
LogSuffix string `mapstructure:"log_suffix"`
5253
MaxBackup int `mapstructure:"max_backup"`
5354
}
55+
56+
type DockerConfig struct {
57+
Command string
58+
}

agent/i18n/lang/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ ErrCustomApps: 'There is an installed application, please uninstall it first'
9292
ErrCustomRuntimes: 'There is an installed runtime environment, please delete it first'
9393
ErrAppVersionDeprecated: "The {{ .name }} application is not compatible with the current 1Panel version, skipped"
9494
ErrDockerFailed: "The state of Docker is abnormal, please check the service status"
95+
ErrDockerComposeCmdNotFound: "The Docker Compose command does not exist, please install this command on the host machine first"
9596

9697
#file
9798
ErrFileCanNotRead: 'This file does not support preview'

agent/i18n/lang/ja.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ ErrCustomApps: 'インストールされているアプリケーションがあ
9292
ErrCustomRuntimes: 'ランタイム環境がインストールされています。まずそれを削除してください'
9393
ErrAppVersionDeprecated: "{{ .name }} アプリケーションは現在の 1Panel バージョンと互換性がありません、スキップしました"
9494
ErrDockerFailed: "Docker の状態が異常です。サービス状態を確認してください"
95+
ErrDockerComposeCmdNotFound: "Docker Compose コマンドは存在しません。ホストマシンにこのコマンドを先にインストールしてください"
9596

9697
#file
9798
ErrFileCanNotRead: 'このファイルはプレビューをサポートしていません'

agent/i18n/lang/ko.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ ErrCustomApps: '설치된 애플리케이션이 있습니다. 먼저 제거해
9292
ErrCustomRuntimes: '설치된 런타임 환경이 있습니다. 먼저 삭제해 주세요'
9393
ErrAppVersionDeprecated: "{{ .name }} 응용 프로그램은 현재 1Panel 버전과 호환되지 않아 건너뛰었습니다"
9494
ErrDockerFailed: "Docker의 상태가 비정상입니다. 서비스 상태를 확인하세요"
95+
ErrDockerComposeCmdNotFound: "Docker Compose 명령이 없습니다. 호스트 머신에 먼저 이 명령을 설치하세요"
9596

9697
#파일
9798
ErrFileCanNotRead: '이 파일은 미리보기를 지원하지 않습니다'

agent/i18n/lang/ms.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ ErrCustomApps: 'Ada aplikasi yang dipasang, sila nyahpasangnya dahulu'
9292
ErrCustomRuntimes: 'Terdapat persekitaran masa jalan yang dipasang, sila padamkannya dahulu'
9393
ErrAppVersionDeprecated: "Aplikasi {{ .name }} tidak sesuai dengan versi 1Panel saat ini, dilewati"
9494
ErrDockerFailed: "Keadaan Docker tidak normal, sila periksa status perkhidmatan"
95+
ErrDockerComposeCmdNotFound: "Perintah Docker Compose tidak wujud, sila pasang perintah ini di mesin tuan terlebih dahulu"
9596

9697
#fail
9798
ErrFileCanNotRead: 'Fail ini tidak menyokong pratonton'

agent/i18n/lang/pt-BR.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ ErrCustomApps: 'Há um aplicativo instalado, desinstale-o primeiro'
9292
ErrCustomRuntimes: 'Há um ambiente de execução instalado, exclua-o primeiro'
9393
ErrAppVersionDeprecated: "O aplicativo {{ .name }} não é compatível com a versão atual do 1Panel, ignorado"
9494
ErrDockerFailed: "O estado do Docker está anormal, verifique o status do serviço"
95+
ErrDockerComposeCmdNotFound: "O comando Docker Compose não existe, por favor, instale este comando na máquina host primeiro"
9596

9697
#arquivo
9798
ErrFileCanNotRead: 'Este arquivo não suporta visualização'

agent/i18n/lang/ru.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ ErrCustomApps: 'Установлено приложение. Сначала уд
9292
ErrCustomRuntimes: 'Установлена среда выполнения. Сначала удалите ее'
9393
ErrAppVersionDeprecated: "Приложение {{ .name }} несовместимо с текущей версией 1Panel, пропущено"
9494
ErrDockerFailed: "Состояние Docker аномально, проверьте состояние сервиса"
95+
ErrDockerComposeCmdNotFound: "Команда Docker Compose отсутствует, пожалуйста, установите эту команду на хост-машине сначала"
9596

9697
#файл
9798
ErrFileCanNotRead: 'Этот файл не поддерживает предварительный просмотр'

agent/i18n/lang/zh-Hant.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ ErrCustomApps: '存在已安裝的應用程式,請先解除安裝'
9191
ErrCustomRuntimes: '存在已安裝的運作環境,請先刪除'
9292
ErrAppVersionDeprecated: "{{ .name }} 應用不適配目前 1Panel 版本,跳過"
9393
ErrDockerFailed: "Docker 狀態異常,請檢查服務狀態"
94+
ErrDockerComposeCmdNotFound: "Docker Compose 命令不存在,請先在宿主機安裝此命令"
9495

9596
#file
9697
ErrFileCanNotRead: '此檔案不支援預覽'

agent/i18n/lang/zh.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ ErrCustomApps: "存在已经安装的应用,请先卸载"
9191
ErrCustomRuntimes: "存在已经安装的运行环境,请先删除"
9292
ErrAppVersionDeprecated: " {{ .name }} 应用不适配当前 1Panel 版本,跳过"
9393
ErrDockerFailed: "Docker 状态异常,请检查服务状态"
94+
ErrDockerComposeCmdNotFound: "Docker Compose 命令不存在,请先在宿主机安装此命令"
9495

9596
#file
9697
ErrFileCanNotRead: "此文件不支持预览"

agent/init/business/business.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/1Panel-dev/1Panel/agent/app/service"
77
"github.com/1Panel-dev/1Panel/agent/constant"
88
"github.com/1Panel-dev/1Panel/agent/global"
9+
"github.com/1Panel-dev/1Panel/agent/utils/common"
910
)
1011

1112
func Init() {
@@ -15,6 +16,7 @@ func Init() {
1516
go syncSSL()
1617
go syncTask()
1718
go initAcmeAccount()
19+
go checkDockerCompose()
1820
}
1921

2022
func syncApp() {
@@ -71,3 +73,16 @@ func initAcmeAccount() {
7173
}
7274
}
7375
}
76+
77+
func checkDockerCompose() {
78+
dockerComposCmd := common.GetDockerComposeCommand()
79+
if dockerComposCmd == "" {
80+
global.LOG.Errorf("Docker Compose command not found, please install Docker Compose Plugin")
81+
return
82+
}
83+
global.CONF.DockerConfig.Command = dockerComposCmd
84+
if err := service.NewISettingService().Update("DockerComposeCommand", dockerComposCmd); err != nil {
85+
global.LOG.Errorf("update docker compose command error: %s", err.Error())
86+
return
87+
}
88+
}

0 commit comments

Comments
 (0)