Skip to content

Commit 4fcbd6b

Browse files
Merge pull request #77 from MarcelDiessner/feature/katacodaDockerCompose
WIP: feature/katacodaDockerCompose
2 parents f76f7e9 + a849a93 commit 4fcbd6b

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

documentation/Functions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,4 @@ content: Plain text to be displayed in the katacoda step.
230230
image: Path to an image to be displayed in the katacoda step.
231231

232232
***
233+

runners/katacoda/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,19 @@ export class Katacoda extends Runner {
343343
return null;
344344
}
345345

346+
runDockerCompose(step: Step, command: Command) : RunResult {
347+
let terminal = this.getTerminal('runDockerCompose');
348+
let cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.workspaceDirectory), command.parameters[0]), terminal.terminalId, terminal.isRunning);
349+
350+
this.steps.push({
351+
"title": "Execute Docker Compose",
352+
"text": "step" +this.stepsCount + ".md"
353+
});
354+
355+
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});
356+
return null;
357+
}
358+
346359
private renderTemplate(name: string, targetPath: string, variables) {
347360
let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", name), 'utf8');
348361
let result = ejs.render(template, variables);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<%= text; %>
2+
3+
<%= cdCommand; %>
4+
5+
<% if(!interrupt){ %>
6+
Now run docker-compose.
7+
<% } else { %>
8+
The docker container is already running.
9+
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.
10+
<% } %>
11+
12+
`docker-compose up`{{execute T<%= terminalId; %> <% if (interrupt) { %>interrupt<% } %>}}
13+
14+
This will take some time.
15+
16+
<% if(port){ %>
17+
Then you can open the following link to use the app.
18+
https://[[HOST_SUBDOMAIN]]-<%= port %>-[[KATACODA_HOST]].environments.katacoda.com/
19+
<% } %>
20+
<%= textAfter; %>

0 commit comments

Comments
 (0)