Skip to content

Commit c341586

Browse files
authored
Merge pull request #3376 from matt-cossins/topo
[TECH REVIEW CHANGES] Topo Template LP
2 parents a065dff + a4e7056 commit c341586

10 files changed

Lines changed: 191 additions & 121 deletions

File tree

content/learning-paths/cross-platform/create-your-own-topo-templates/_index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
---
2-
title: Create your own Topo Templates
2+
title: Create and deploy a custom Topo Template
33

44
draft: true
55
cascade:
66
draft: true
77

8-
description: Create a Topo Template after your project to use Topo to deploy containerized workloads to Arm-based Linux targets over SSH.
8+
description: Understand how to create and modify Topo Templates, allowing you to deploy your projects as containerized workloads to Arm-based Linux targets over SSH.
99

1010
minutes_to_complete: 30
1111

1212
who_is_this_for: This is an introductory topic for embedded, edge, and cloud software developers who want to create their own Topo Templates projects to be natively deployed with Topo.
1313

1414
learning_objectives:
1515
- Explain the purpose and structure of a Topo Template
16-
- Clone and deploy an existing Topo Template to validate the Template workflow
17-
- Add clone-time arguments to customize a Topo Template
16+
- Clone and deploy an existing Topo Template and modify it by adding new clone-time arguments
1817
- Create a new Topo Template from a Docker Compose project
1918
- Add x-topo metadata for configurable arguments, deployment guidance, and hardware requirements
19+
- Understand where to find Agent Skills, for use when creating or modifying Topo Templates
2020

2121
prerequisites:
2222
- This learning path builds on [Deploy containerized workloads to Arm-based Linux targets with Topo](/learning-paths/cross-platform/deploy-containerized-workloads-with-topo/).
2323
- A host machine (x86 or Arm) with Linux, macOS, or Windows
24-
- (Optional) An Arm-based Linux target accessible over SSH, for example an Arm-based Linux VM, Raspberry Pi, DGX Spark, or NXP i.MX 93
24+
- An Arm-based Linux target accessible over SSH, for example an Arm-based Linux VM, Raspberry Pi, DGX Spark, or NXP i.MX 93
2525
- Docker installed on the host and target. For installation steps, see [Install Docker](/install-guides/docker/).
2626
- Basic familiarity with containers and CLI tools
2727

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Use agent skills for Topo Templates
3+
weight: 6
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Skills for authoring Templates
10+
11+
If you already have a Docker Compose project and want to convert it to a Topo Template, or you want to create your own Topo Template from scratch, you can do so with an Agent Skill.
12+
13+
These skills are optional authoring aids. The Template you created in this Learning Path works with Topo without them.
14+
15+
Visit [Topo Skills](https://github.com/arm/topo-template-format#authoring-skills) for the most up-to-date list of the available Topo Template skills and instructions on how to install them.
16+
17+
At the time of writing, the [Topo Template Format Specification](https://github.com/arm/topo-template-format) provides the following skills:
18+
19+
1. `topo-template-context`: provides Topo and Topo Template reference context for questions about x-topo metadata, schema, docs, and CLI Template behavior.
20+
2. `topo-template-bootstrap`: converts a repository into a Topo Template by adding or improving `compose.yaml` and `x-topo` metadata.
21+
3. `topo-template-lint`: reviews an existing Topo Template for correctness, consistency, and authoring best practices.
22+
23+
## Install the skills
24+
25+
Install the Topo Template skills with [npx skills](https://github.com/vercel-labs/skills):
26+
27+
```bash
28+
npx skills add arm/topo-template-format --all --yes
29+
```
30+
31+
Restart your agent after installing or updating skills.
32+
33+
## Use the skills
34+
35+
You can then prompt your agent to use the skill to create a Topo Template from an existing project:
36+
37+
```text
38+
Use the topo-template-bootstrap skill to convert this repository into a Topo Template.
39+
```

content/learning-paths/cross-platform/create-your-own-topo-templates/creating-a-new-template.md

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ The Template you create serves a small web page with configurable text and color
2222
Create a new directory for the Template:
2323

2424
```bash
25-
mkdir topo-message-card
26-
cd topo-message-card
25+
mkdir -p ~/topo-message-card
26+
cd ~/topo-message-card
2727
```
2828

2929
A Topo Template is a normal project directory. At minimum, it must contain a `compose.yaml` file. Most Templates also include a `Dockerfile` and application source code.
@@ -48,7 +48,7 @@ Create the application HTML file:
4848
<head>
4949
<meta charset="utf-8">
5050
<meta name="viewport" content="width=device-width, initial-scale=1">
51-
<title>{{CARD_TITLE}}</title>
51+
<title>__CARD_TITLE__</title>
5252
<style>
5353
body {
5454
margin: 0;
@@ -62,7 +62,7 @@ Create the application HTML file:
6262
6363
main {
6464
width: min(720px, calc(100vw - 40px));
65-
border-top: 8px solid {{ACCENT_COLOR}};
65+
border-top: 8px solid __ACCENT_COLOR__;
6666
background: white;
6767
padding: 40px;
6868
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
@@ -82,14 +82,14 @@ Create the application HTML file:
8282
</head>
8383
<body>
8484
<main>
85-
<h1>{{CARD_TITLE}}</h1>
86-
<p>{{CARD_MESSAGE}}</p>
85+
<h1>__CARD_TITLE__</h1>
86+
<p>__CARD_MESSAGE__</p>
8787
</main>
8888
</body>
8989
</html>
9090
```
9191

92-
The values wrapped in double braces are placeholders. The `Dockerfile` replaces them with values supplied by Topo.
92+
The values wrapped in double underscores are placeholders. The `Dockerfile` replaces them with values supplied by Topo.
9393

9494
### Create the Dockerfile
9595

@@ -104,13 +104,15 @@ ARG CARD_TITLE="Hello from Topo"
104104
ARG CARD_MESSAGE="This page was created from a Topo Template."
105105
ARG ACCENT_COLOR="#0091bd"
106106

107-
RUN sed -i "s|{{CARD_TITLE}}|${CARD_TITLE}|g" /usr/share/nginx/html/index.html
108-
RUN sed -i "s|{{CARD_MESSAGE}}|${CARD_MESSAGE}|g" /usr/share/nginx/html/index.html
109-
RUN sed -i "s|{{ACCENT_COLOR}}|${ACCENT_COLOR}|g" /usr/share/nginx/html/index.html
107+
RUN sed -i "s|__CARD_TITLE__|${CARD_TITLE}|g" /usr/share/nginx/html/index.html
108+
RUN sed -i "s|__CARD_MESSAGE__|${CARD_MESSAGE}|g" /usr/share/nginx/html/index.html
109+
RUN sed -i "s|__ACCENT_COLOR__|${ACCENT_COLOR}|g" /usr/share/nginx/html/index.html
110110
```
111111

112112
Topo passes configuration values to Templates through Docker build arguments. The `ARG` lines define the values consumed during the image build.
113113

114+
`sed` is a command-line text replacement tool. The `sed` commands replace placeholder text in `index.html` during the image build, so each cloned project can customize the web page without manually editing the source file.
115+
114116
### Create the compose file
115117

116118
Create `compose.yaml`:
@@ -136,7 +138,7 @@ x-topo:
136138
message, and accent color.
137139
type: "application"
138140
deploy_success_message: |
139-
Message Card is running. Open http://localhost:8088/ in your browser.
141+
Message Card is running on port 8088.
140142
args:
141143
CARD_TITLE:
142144
description: "The title to show on the message card"
@@ -168,32 +170,33 @@ The `x-topo` section is the Topo metadata block:
168170

169171
The argument names in `x-topo.args` match the keys under `services.message-card.build.args`. When Topo resolves the arguments, it writes the selected values into the build arguments.
170172

173+
The same argument name appears in three places: `x-topo.args` defines what Topo asks for, `build.args` passes the value to Docker, and the Dockerfile `ARG` consumes it.
174+
171175
### Clone the local Template
172176

173-
Move to the parent directory and clone your local Template with Topo:
177+
Clone your local Template into a new project directory. You can choose to answer interactive prompts for the arguments (using the first command below), or you can opt to include the arguments in the command (using the second command).
174178

179+
Interactive argument prompts:
175180
```bash
176-
cd ..
177-
topo clone dir:./topo-message-card ./message-card-demo \
178-
CARD_TITLE="Hello from Arm" \
179-
CARD_MESSAGE="Created from a new Topo Template" \
180-
ACCENT_COLOR="#00a3a3"
181+
topo clone dir:$HOME/topo-message-card $HOME/message-card-demo
181182
```
182183

183-
You can also omit the argument values and answer the interactive prompts:
184-
184+
Arguments included in command:
185185
```bash
186-
topo clone dir:./topo-message-card ./message-card-demo
186+
topo clone dir:$HOME/topo-message-card $HOME/message-card-demo \
187+
CARD_TITLE="Hello from Arm" \
188+
CARD_MESSAGE="Created from a new Topo Template" \
189+
ACCENT_COLOR="#00a3a3"
187190
```
188191

189192
After cloning, inspect the generated project:
190193

191194
```bash
192-
cd message-card-demo
195+
cd ~/message-card-demo
193196
sed -n '1,80p' compose.yaml
194197
```
195198

196-
The `build.args` values should contain the values you provided:
199+
The `build.args` should contain the values you provided:
197200

198201
```yaml
199202
services:
@@ -209,25 +212,39 @@ services:
209212

210213
### Deploy the new project
211214

212-
Deploy the cloned project to the host machine:
215+
Check that your target is ready:
216+
217+
```bash
218+
topo health --target user@my-target
219+
```
220+
221+
Deploy the cloned project to your target:
222+
223+
```bash
224+
topo deploy --target user@my-target
225+
```
226+
227+
When deployment completes, open `http://<target-ip-address>:8088/` in your browser. You can also forward the port over SSH:
213228

214229
```bash
215-
topo deploy --target localhost
230+
ssh -L 8088:localhost:8088 user@my-target
216231
```
217232

218-
When deployment completes, open `http://localhost:8088/` in your browser.
233+
Then open `http://localhost:8088/` in your browser.
234+
235+
![Screenshot of the new Topo Template - a simple web page. This confirms successful deployment and provides a visual reference for the expected result.#center](new_template.png "Hello from Arm web page")
219236

220237
Confirm that the container is running:
221238

222239
```bash
223-
topo ps --target localhost
240+
topo ps --target user@my-target
224241
```
225242

226243
The output should include the `message-card` service and port `8088`.
227244

228-
### Add hardware requirements
245+
### Adding hardware requirements
229246

230-
Only add `features` when your Template needs specific Arm hardware features. For example, a SIMD benchmark that requires SVE can declare:
247+
Only add `features` when your Template needs specific Arm hardware features. For example, a SIMD benchmark that requires SVE can declare that it needs SVE:
231248

232249
```yaml
233250
x-topo:
@@ -257,4 +274,8 @@ If the Template is intended to be reusable by the wider Topo community, include:
257274
- A license file
258275
- Clear `x-topo` metadata and argument descriptions
259276

260-
You now have a complete Topo Template created from scratch.
277+
## What you've accomplished and what's next
278+
279+
You have now created a complete Topo Template from scratch. You created the web page HTML, added a Compose file, described the Template with `x-topo` metadata, supplied clone-time arguments, and deployed the generated project to an Arm-based Linux target.
280+
281+
Next, you will learn where to find Agent Skills that can help you create, modify, and review Topo Templates.

0 commit comments

Comments
 (0)