diff --git a/documentation/Functions.md b/documentation/Functions.md index 87a18bd3..b96850d6 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -214,3 +214,4 @@ content: Plain text to be displayed in the katacoda step. image: Path to an image to be displayed in the katacoda step. *** + diff --git a/runners/katacoda/index.ts b/runners/katacoda/index.ts index 050273fe..683a3b03 100644 --- a/runners/katacoda/index.ts +++ b/runners/katacoda/index.ts @@ -338,6 +338,19 @@ export class Katacoda extends Runner { return null; } + runDockerCompose(step: Step, command: Command) : RunResult { + let terminal = this.getTerminal('runDockerCompose'); + let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.workspaceDirectory), command.parameters[0]), terminal.terminalId, terminal.isRunning); + + this.steps.push({ + "title": "Execute Docker Compose", + "text": "step" +this.stepsCount + ".md" + }); + + this.renderTemplate("dockerCompose.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, terminalId: terminal.terminalId, interrupt: terminal.isRunning, port: command.parameters[1].port}); + return null; + } + private renderTemplate(name: string, targetPath: string, variables) { let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", name), 'utf8'); let result = ejs.render(template, variables); diff --git a/runners/katacoda/templates/dockerCompose.md b/runners/katacoda/templates/dockerCompose.md new file mode 100644 index 00000000..092cf38f --- /dev/null +++ b/runners/katacoda/templates/dockerCompose.md @@ -0,0 +1,20 @@ +<%= text; %> + +<%= cdCommand; %> + +<% if(!interrupt){ %> +Now run docker-compose. +<% } else { %> +The docker container is already running. +Usually you would type "Ctrl + C" and rerun the same command in this terminal to rebuild the app, but for now click on the command to stop and relaunch it automatically. +<% } %> + +`docker-compose up`{{execute T<%= terminalId; %> <% if (interrupt) { %>interrupt<% } %>}} + +This will take some time. + +<% if(port){ %> +Then you can open the following link to use the app. +https://[[HOST_SUBDOMAIN]]-<%= port %>-[[KATACODA_HOST]].environments.katacoda.com/ +<% } %> +<%= textAfter; %> \ No newline at end of file