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
1 change: 1 addition & 0 deletions documentation/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

***

13 changes: 13 additions & 0 deletions runners/katacoda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions runners/katacoda/templates/dockerCompose.md
Original file line number Diff line number Diff line change
@@ -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; %>