Skip to content

Commit 2811448

Browse files
authored
Merge pull request #3365 from tgonzalezorlandoarm/main
Change file format for the template creation
2 parents 619388c + e461a29 commit 2811448

1 file changed

Lines changed: 5 additions & 39 deletions

File tree

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

Lines changed: 5 additions & 39 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 -p ~/topo-template-work/topo-message-card/src
26-
cd ~/topo-template-work/topo-message-card
25+
mkdir 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.
@@ -34,7 +34,6 @@ The directory you create in this section will have the following structure:
3434
topo-message-card/
3535
├── compose.yaml
3636
├── Dockerfile
37-
├── README.md
3837
└── src/
3938
└── index.html
4039
```
@@ -43,8 +42,7 @@ topo-message-card/
4342

4443
Create the application HTML file:
4544

46-
```bash
47-
cat > src/index.html <<'EOF'
45+
```html
4846
<!doctype html>
4947
<html lang="en">
5048
<head>
@@ -89,7 +87,6 @@ cat > src/index.html <<'EOF'
8987
</main>
9088
</body>
9189
</html>
92-
EOF
9390
```
9491

9592
The values wrapped in double braces are placeholders. The `Dockerfile` replaces them with values supplied by Topo.
@@ -98,8 +95,7 @@ The values wrapped in double braces are placeholders. The `Dockerfile` replaces
9895

9996
Create a `Dockerfile`:
10097

101-
```bash
102-
cat > Dockerfile <<'EOF'
98+
```Dockerfile
10399
FROM nginx:alpine
104100

105101
COPY src/index.html /usr/share/nginx/html/index.html
@@ -111,7 +107,6 @@ ARG ACCENT_COLOR="#0091bd"
111107
RUN sed -i "s|{{CARD_TITLE}}|${CARD_TITLE}|g" /usr/share/nginx/html/index.html
112108
RUN sed -i "s|{{CARD_MESSAGE}}|${CARD_MESSAGE}|g" /usr/share/nginx/html/index.html
113109
RUN sed -i "s|{{ACCENT_COLOR}}|${ACCENT_COLOR}|g" /usr/share/nginx/html/index.html
114-
EOF
115110
```
116111

117112
Topo passes configuration values to templates through Docker build arguments. The `ARG` lines define the values consumed during the image build.
@@ -120,8 +115,7 @@ Topo passes configuration values to templates through Docker build arguments. Th
120115

121116
Create `compose.yaml`:
122117

123-
```bash
124-
cat > compose.yaml <<'EOF'
118+
```yaml
125119
# yaml-language-server: $schema=https://raw.githubusercontent.com/arm/topo-template-format/refs/heads/main/schema/topo-template-format.json
126120
services:
127121
message-card:
@@ -158,7 +152,6 @@ x-topo:
158152
required: false
159153
default: "#0091bd"
160154
example: "#00a3a3"
161-
EOF
162155
```
163156
164157
This file is both a Compose file and a Topo Template definition.
@@ -175,31 +168,6 @@ The `x-topo` section is the Topo metadata block:
175168

176169
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.
177170

178-
### Add a README
179-
180-
Create a short `README.md`:
181-
182-
````bash
183-
cat > README.md <<'EOF'
184-
# Message Card
185-
186-
This project is a Topo Template. It builds a small Nginx web application for
187-
Arm Linux targets.
188-
189-
## Usage
190-
191-
```bash
192-
topo clone dir:/path/to/topo-message-card
193-
cd topo-message-card
194-
topo deploy --target localhost
195-
```
196-
197-
Open `http://localhost:8088/` in your browser after deployment.
198-
EOF
199-
````
200-
201-
The README is not required by the Template format, but it is useful when you share the Template with other users.
202-
203171
### Clone the local Template
204172

205173
Move to the parent directory and clone your local Template with Topo:
@@ -218,8 +186,6 @@ You can also omit the argument values and answer the interactive prompts:
218186
topo clone dir:./topo-message-card ./message-card-demo
219187
```
220188

221-
If `./message-card-demo` already exists, remove it or choose a different output directory before cloning again.
222-
223189
After cloning, inspect the generated project:
224190

225191
```bash

0 commit comments

Comments
 (0)