Support compose.y[a]ml and docker-compose.y[a]ml

This commit is contained in:
broetchenrackete36 2023-11-16 11:00:38 +01:00
parent d1732af529
commit ac9408d3eb
2 changed files with 14 additions and 3 deletions

View file

@ -24,6 +24,7 @@ export class Stack {
protected _status: number = UNKNOWN;
protected _composeYAML?: string;
protected _configFilePath?: string;
protected _composeFileName: string = "compose.yaml";
protected server: DockgeServer;
protected combinedTerminal? : Terminal;
@ -34,6 +35,15 @@ export class Stack {
this.name = name;
this.server = server;
this._composeYAML = composeYAML;
// Check if compose file name is different from compose.yaml
if (fs.existsSync(path.join(this.path, "compose.yml"))){
this._composeFileName = "compose.yml";
} else if (fs.existsSync(path.join(this.path, "docker-compose.yml"))){
this._composeFileName = "docker-compose.yml";
} else if (fs.existsSync(path.join(this.path, "docker-compose.yaml"))){
this._composeFileName = "docker-compose.yaml";
}
}
toJSON() : object {
@ -50,6 +60,7 @@ export class Stack {
status: this._status,
tags: [],
isManagedByDockge: this.isManagedByDockge,
composeFileName: this._composeFileName,
};
}
@ -84,7 +95,7 @@ export class Stack {
get composeYAML() : string {
if (this._composeYAML === undefined) {
try {
this._composeYAML = fs.readFileSync(path.join(this.path, "compose.yaml"), "utf-8");
this._composeYAML = fs.readFileSync(path.join(this.path, this._composeFileName), "utf-8");
} catch (e) {
this._composeYAML = "";
}
@ -135,7 +146,7 @@ export class Stack {
}
// Write or overwrite the compose.yaml
fs.writeFileSync(path.join(dir, "compose.yaml"), this.composeYAML);
fs.writeFileSync(path.join(dir, this._composeFileName), this.composeYAML);
}
async deploy(socket? : DockgeSocket) : Promise<number> {

View file

@ -118,7 +118,7 @@
</div>
</div>
<div class="col-lg-6">
<h4 class="mb-3">compose.yaml</h4>
<h4 class="mb-3">{{ stack.composeFileName }}</h4>
<!-- YAML editor -->
<div class="shadow-box mb-3 editor-box" :class="{'edit-mode' : isEditMode}">