Skip to content
Open
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
1 change: 1 addition & 0 deletions common/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ declare global {

interface IGlobalInstanceDockerConfig {
containerName?: string;
pullPolicy?: boolean;
image?: string;
memory?: number;
ports?: string[];
Expand Down
34 changes: 19 additions & 15 deletions daemon/src/entity/commands/docker/docker_pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,32 @@ export default class DockerPullCommand extends InstanceCommand {

async exec(instance: Instance) {
const imageName = instance.config.docker.image;
const pullPolicy = instance.config.docker.pullPolicy;
if (!imageName) throw new Error(t("TXT_CODE_17be5f70"));
const cachedStartCount = instance.startCount;
// If the image exists, there is no need to pull again.
if (await checkImage(imageName)) return;
if(pullPolicy === false ) {
if (await checkImage(imageName)) return;
} else {

try {
const docker = new DefaultDocker();
instance.println("CONTAINER", t("TXT_CODE_2fa46b8c") + imageName);
instance.asynchronousTask = this;
try {
const docker = new DefaultDocker();
instance.println("CONTAINER", t("TXT_CODE_2fa46b8c") + imageName);
instance.asynchronousTask = this;

await docker.pull(imageName, {});
await docker.pull(imageName, {});

await this.awaitImageDone(instance, imageName);
if (cachedStartCount !== instance.startCount) return;
instance.println("CONTAINER", t("TXT_CODE_c68b0bef"));
} catch (err: any) {
if (cachedStartCount !== instance.startCount) return;
throw new Error([t("TXT_CODE_db37b7f9"), err?.message].join("\n"));
} finally {
this.stopped(instance);
}
await this.awaitImageDone(instance, imageName);
if (cachedStartCount !== instance.startCount) return;
instance.println("CONTAINER", t("TXT_CODE_c68b0bef"));
} catch (err: any) {
if (cachedStartCount !== instance.startCount) return;
throw new Error([t("TXT_CODE_db37b7f9"), err?.message].join("\n"));
} finally {
this.stopped(instance);
}
}
}

async stop(instance: Instance): Promise<void> {
this.stopped(instance);
Expand Down
1 change: 1 addition & 0 deletions daemon/src/entity/instance/Instance_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class InstanceConfig implements IGlobalInstanceConfig {
public docker: IGlobalInstanceDockerConfig = {
containerName: "",
image: "",
pullPolicy: false,
ports: [],
extraVolumes: [],
memory: 0,
Expand Down
1 change: 1 addition & 0 deletions daemon/src/entity/instance/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export default class Instance extends EventEmitter {

if (cfg.docker) {
configureEntityParams(this.config.docker, cfg.docker, "containerName", String);
configureEntityParams(this.config.docker, cfg.docker, "pullPolicy", Boolean);
configureEntityParams(this.config.docker, cfg.docker, "image", String);
configureEntityParams(this.config.docker, cfg.docker, "memory", Number);
configureEntityParams(this.config.docker, cfg.docker, "ports");
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/widgets/instance/dialogs/InstanceDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,29 @@ defineExpose({
</a-form-item>
</a-col>

<a-col :xs="24" :lg="8" :offset="0">
<a-form-item name="pullPolicy">
<a-typography-title :level="5" :class="{ 'require-field': isDockerMode }">
Always pull image
</a-typography-title>
<a-typography-paragraph>
<a-typography-text type="secondary" :class="!isPhone && 'two-line-height'">
Always pull Docker image
</a-typography-text>
</a-typography-paragraph>
<a-switch
v-model:checked="options.config.docker.pullPolicy"
:disabled="isGlobalTerminal"
:checked-value=true
:un-checked-value=false
>
<template #checkedChildren><check-outlined /></template>
<template #unCheckedChildren><close-outlined /></template>
</a-switch>
</a-form-item>
</a-col>


<a-col :xs="24" :lg="8" :offset="0">
<a-form-item>
<a-typography-title :level="5">{{ t("TXT_CODE_10194e6a") }}</a-typography-title>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/widgets/setupApp/CreateInstanceForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const formData = reactive<NewInstanceForm>({
docker: {
containerName: "",
image: "",
pullPolicy: false,
ports: [],
extraVolumes: [],
networkMode: "bridge",
Expand Down
167 changes: 139 additions & 28 deletions panel/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.