mirror of
https://github.com/louislam/dockge.git
synced 2024-11-23 19:34:04 +00:00
Support compose.y[a]ml and docker-compose.y[a]ml (#55)
* Support compose.y[a]ml and docker-compose.y[a]ml * using for-loop to iterate over supported compose filenames * Fix lint --------- Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This commit is contained in:
parent
a488518f6e
commit
5ce6b90546
2 changed files with 14 additions and 3 deletions
|
@ -24,6 +24,7 @@ export class Stack {
|
||||||
protected _status: number = UNKNOWN;
|
protected _status: number = UNKNOWN;
|
||||||
protected _composeYAML?: string;
|
protected _composeYAML?: string;
|
||||||
protected _configFilePath?: string;
|
protected _configFilePath?: string;
|
||||||
|
protected _composeFileName: string = "compose.yaml";
|
||||||
protected server: DockgeServer;
|
protected server: DockgeServer;
|
||||||
|
|
||||||
protected combinedTerminal? : Terminal;
|
protected combinedTerminal? : Terminal;
|
||||||
|
@ -34,6 +35,15 @@ export class Stack {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this._composeYAML = composeYAML;
|
this._composeYAML = composeYAML;
|
||||||
|
|
||||||
|
// Check if compose file name is different from compose.yaml
|
||||||
|
const supportedFileNames = [ "compose.yaml", "compose.yml", "docker-compose.yml", "docker-compose.yaml" ];
|
||||||
|
for (const filename of supportedFileNames) {
|
||||||
|
if (fs.existsSync(path.join(this.path, filename))) {
|
||||||
|
this._composeFileName = filename;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() : object {
|
toJSON() : object {
|
||||||
|
@ -50,6 +60,7 @@ export class Stack {
|
||||||
status: this._status,
|
status: this._status,
|
||||||
tags: [],
|
tags: [],
|
||||||
isManagedByDockge: this.isManagedByDockge,
|
isManagedByDockge: this.isManagedByDockge,
|
||||||
|
composeFileName: this._composeFileName,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +95,7 @@ export class Stack {
|
||||||
get composeYAML() : string {
|
get composeYAML() : string {
|
||||||
if (this._composeYAML === undefined) {
|
if (this._composeYAML === undefined) {
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
this._composeYAML = "";
|
this._composeYAML = "";
|
||||||
}
|
}
|
||||||
|
@ -135,7 +146,7 @@ export class Stack {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write or overwrite the compose.yaml
|
// 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> {
|
async deploy(socket? : DockgeSocket) : Promise<number> {
|
||||||
|
|
|
@ -118,7 +118,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<h4 class="mb-3">compose.yaml</h4>
|
<h4 class="mb-3">{{ stack.composeFileName }}</h4>
|
||||||
|
|
||||||
<!-- YAML editor -->
|
<!-- YAML editor -->
|
||||||
<div class="shadow-box mb-3 editor-box" :class="{'edit-mode' : isEditMode}">
|
<div class="shadow-box mb-3 editor-box" :class="{'edit-mode' : isEditMode}">
|
||||||
|
|
Loading…
Reference in a new issue