Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions agent/app/dto/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,14 @@ type ComposeContainer struct {
Ports []string `json:"ports"`
}
type ComposeCreate struct {
TaskID string `json:"taskID"`
Name string `json:"name"`
From string `json:"from" validate:"required,oneof=edit path template"`
File string `json:"file"`
Path string `json:"path"`
Template uint `json:"template"`
Env string `json:"env"`
TaskID string `json:"taskID"`
Name string `json:"name"`
From string `json:"from" validate:"required,oneof=edit path template"`
File string `json:"file"`
Path string `json:"path"`
Template uint `json:"template"`
Env string `json:"env"`
PullImage *bool `json:"pullImage,omitempty"`
}
type ComposeOperation struct {
Name string `json:"name" validate:"required"`
Expand Down
6 changes: 5 additions & 1 deletion agent/app/service/container_compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,13 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) error {
if err := newComposeEnv(req.Path, req.Env); err != nil {
return err
}
pullImages := true
if req.PullImage != nil {
pullImages = *req.PullImage
}
go func() {
taskItem.AddSubTask(i18n.GetMsgByKey("ComposeCreate"), func(t *task.Task) error {
err := compose.UpWithTask(req.Path, t)
err := compose.UpWithTask(req.Path, t, pullImages)
t.LogWithStatus(i18n.GetMsgByKey("ComposeCreate"), err)
if err != nil {
_, _ = compose.Down(req.Path)
Expand Down
5 changes: 4 additions & 1 deletion agent/utils/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ func Up(filePath string) (string, error) {
return cmd.NewCommandMgr(cmd.WithTimeout(20*time.Minute)).RunWithStdoutBashCf("%s %s up -d", global.CONF.DockerConfig.Command, loadFiles(filePath))
}

func UpWithTask(filePath string, task *task.Task) error {
func UpWithTask(filePath string, task *task.Task, pullImages bool) error {
if !pullImages {
return cmd.NewCommandMgr(cmd.WithTask(*task)).RunBashCf("%s %s up -d", global.CONF.DockerConfig.Command, loadFiles(filePath))
}
content, err := os.ReadFile(filePath)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/api/interface/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ export namespace Container {
file: string;
path: string;
template: number;
env: string;
pullImage?: boolean;
}
export interface ComposeOperation {
name: string;
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/views/container/compose/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@
</el-form-item>
<span class="envTitle">{{ $t('container.env') }}</span>
<el-input placeholder="key=value" type="textarea" :rows="3" v-model="form.env" />
<span class="envTitle">{{ $t('commons.button.set') }}</span>
<el-form-item>
<el-checkbox v-model="form.pullImage" :label="$t('app.pullImage')" />
<span class="input-help">{{ $t('app.pullImageHelper') }}</span>
</el-form-item>
</el-form>

<el-button type="primary" class="mt-2" @click="onSubmit(formRef)">
Expand Down Expand Up @@ -426,6 +431,7 @@ const form = reactive({
file: '',
template: null as number,
env: '',
pullImage: true,
});
const rules = reactive({
name: [Rules.requiredInput, Rules.composeName],
Expand Down Expand Up @@ -555,6 +561,7 @@ const onOpenDialog = async () => {
form.file = '';
form.template = null;
form.env = '';
form.pullImage = true;
loadPath();
loadTemplates();
};
Expand Down
Loading