mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-08 02:36:01 +08:00
fix: Change container image building to asynchronous operation (#9462)
Refs #8463
This commit is contained in:
parent
96208c786d
commit
383bdd5f15
15 changed files with 45 additions and 5 deletions
|
|
@ -164,6 +164,8 @@ type ContainerCommit struct {
|
|||
Comment string `json:"comment"`
|
||||
Author string `json:"author"`
|
||||
Pause bool `json:"pause"`
|
||||
|
||||
TaskID string `json:"taskID"`
|
||||
}
|
||||
|
||||
type ContainerPrune struct {
|
||||
|
|
|
|||
|
|
@ -809,10 +809,23 @@ func (u *ContainerService) ContainerCommit(req dto.ContainerCommit) error {
|
|||
Pause: req.Pause,
|
||||
Config: nil,
|
||||
}
|
||||
_, err = client.ContainerCommit(ctx, req.ContainerId, options)
|
||||
|
||||
taskItem, err := task.NewTaskWithOps(req.NewImageName, task.TaskCommit, task.TaskScopeContainer, req.TaskID, 1)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to commit container, err: %v", err)
|
||||
return fmt.Errorf("new task for container commit failed, err: %v", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
taskItem.AddSubTask(i18n.GetWithName("TaskCommit", req.NewImageName), func(t *task.Task) error {
|
||||
res, err := client.ContainerCommit(ctx, req.ContainerId, options)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to commit container, err: %v", err)
|
||||
}
|
||||
taskItem.Log(res.ID)
|
||||
return nil
|
||||
}, nil)
|
||||
_ = taskItem.Execute()
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,10 +164,12 @@ func (u *ImageRepoService) Update(req dto.ImageRepoUpdate) error {
|
|||
needRestart = repo.DownloadUrl == req.DownloadUrl
|
||||
}
|
||||
if repo.Protocol == "https" && req.Protocol == "http" {
|
||||
if err := u.handleRegistries(req.DownloadUrl, "", "create"); err != nil {
|
||||
return fmt.Errorf("create registry %s failed, err: %v", req.DownloadUrl, err)
|
||||
if req.DownloadUrl != repo.DownloadUrl {
|
||||
if err := u.handleRegistries(req.DownloadUrl, repo.DownloadUrl, "update"); err != nil {
|
||||
return fmt.Errorf("update registry %s => %s failed, err: %v", repo.DownloadUrl, req.DownloadUrl, err)
|
||||
}
|
||||
needRestart = true
|
||||
}
|
||||
needRestart = true
|
||||
}
|
||||
if needRestart {
|
||||
if err := stopBeforeUpdateRepo(); err != nil {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ const (
|
|||
TaskSync = "TaskSync"
|
||||
TaskBuild = "TaskBuild"
|
||||
TaskPull = "TaskPull"
|
||||
TaskCommit = "TaskCommit"
|
||||
TaskPush = "TaskPush"
|
||||
TaskHandle = "TaskHandle"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ TaskBackup: 'Backup'
|
|||
TaskRecover: 'Recover'
|
||||
TaskRollback: 'Rollback'
|
||||
TaskPull: 'Pull'
|
||||
TaskCommit: 'Commit'
|
||||
TaskBuild: 'Build'
|
||||
TaskPush: 'Push'
|
||||
TaskHandle: 'Execute'
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ TaskBackup: 'バックアップ'
|
|||
TaskRecover: '回復'
|
||||
TaskRollback: 'ロールバック'
|
||||
TaskPull: 'プル'
|
||||
TaskCommit: 'コミット'
|
||||
TaskBuild: 'ビルド'
|
||||
TaskPush: 'プッシュ'
|
||||
TaskHandle: '実行'
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ TaskBackup: '백업'
|
|||
TaskRecover: '복구'
|
||||
TaskRollback: '롤백'
|
||||
TaskPull: '당기기'
|
||||
TaskCommit: '커밋'
|
||||
TaskBuild: '빌드'
|
||||
TaskPush: '푸시'
|
||||
TaskHandle: '실행'
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ TaskBackup: 'Sandaran'
|
|||
TaskRecover: 'Pulihkan'
|
||||
TaskRollback: 'Rollback'
|
||||
TaskPull: 'Tarik'
|
||||
TaskCommit: 'Komit'
|
||||
TaskBuild: 'Bina'
|
||||
TaskPush: 'Tolak'
|
||||
TaskHandle: 'Laksanakan'
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ Backup de Tarefa: 'Backup'
|
|||
TaskRecover: 'Recuperar'
|
||||
TaskRollback: 'Reverter'
|
||||
TaskPull: 'Puxar'
|
||||
TaskCommit: 'Commit'
|
||||
TaskBuild: 'Construir'
|
||||
TaskPush: 'Empurrar'
|
||||
TaskHandle: 'Executar'
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ TaskBackup: 'Резервное копирование'
|
|||
TaskRecover: 'Восстановить'
|
||||
TaskRollback: 'Откат'
|
||||
TaskPull: 'Вытянуть'
|
||||
TaskCommit: 'Kоммит'
|
||||
ЗадачаСборка: 'Сборка'
|
||||
TaskPush: 'Push'
|
||||
TaskHandle: 'Выполнить'
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ TaskBackup: 'Yedekle'
|
|||
TaskRecover: 'Kurtar'
|
||||
TaskRollback: 'Geri Al'
|
||||
TaskPull: 'Çek'
|
||||
TaskCommit: 'işleme'
|
||||
TaskBuild: 'Yapı'
|
||||
TaskPush: 'Gönder'
|
||||
TaskHandle: 'Yürüt'
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ TaskBackup: '備份'
|
|||
TaskRecover: '復原'
|
||||
TaskRollback: '回滾'
|
||||
TaskPull: '拉取'
|
||||
TaskCommit: '制作'
|
||||
TaskBuild: '建置'
|
||||
TaskPush: '推送'
|
||||
TaskHandle: '執行'
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ TaskBackup: "备份"
|
|||
TaskRecover: "恢复"
|
||||
TaskRollback: "回滚"
|
||||
TaskPull: "拉取"
|
||||
TaskCommit: "制作"
|
||||
TaskBuild: "构建"
|
||||
TaskPush: "推送"
|
||||
TaskHandle: "执行"
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export namespace Container {
|
|||
comment: string;
|
||||
author: string;
|
||||
pause: boolean;
|
||||
taskID: string;
|
||||
}
|
||||
export interface ContainerSearch extends ReqPage {
|
||||
name: string;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
</span>
|
||||
</template>
|
||||
</DrawerPro>
|
||||
<TaskLog ref="taskLogRef" width="70%" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
|
@ -50,7 +51,9 @@ import { ElForm } from 'element-plus';
|
|||
import { Rules } from '@/global/form-rules';
|
||||
import i18n from '@/lang';
|
||||
import { commitContainer } from '@/api/modules/container';
|
||||
import TaskLog from '@/components/log/task/index.vue';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { newUUID } from '@/utils/util';
|
||||
|
||||
const drawerVisible = ref<boolean>(false);
|
||||
const emit = defineEmits<{ (e: 'search'): void }>();
|
||||
|
|
@ -62,8 +65,11 @@ const form = reactive({
|
|||
comment: '',
|
||||
author: '',
|
||||
pause: false,
|
||||
taskID: '',
|
||||
});
|
||||
|
||||
const taskLogRef = ref();
|
||||
|
||||
interface DialogProps {
|
||||
containerID: string;
|
||||
containerName: string;
|
||||
|
|
@ -89,11 +95,13 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
|||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
||||
}).then(async () => {
|
||||
loading.value = true;
|
||||
form.taskID = newUUID();
|
||||
await commitContainer(form)
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
emit('search');
|
||||
drawerVisible.value = false;
|
||||
openTaskLog(form.taskID);
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
})
|
||||
.catch(() => {
|
||||
|
|
@ -103,6 +111,10 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
|||
});
|
||||
};
|
||||
|
||||
const openTaskLog = (taskID: string) => {
|
||||
taskLogRef.value.openWithTaskID(taskID);
|
||||
};
|
||||
|
||||
const handleClose = async () => {
|
||||
drawerVisible.value = false;
|
||||
emit('search');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue