Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 621fc8a

Browse files
author
Antony MECHIN
committed
Examples: Make hello-world a single file application.
Signed-off-by: Antony MECHIN <[email protected]>
1 parent 8d4120d commit 621fc8a

File tree

5 files changed

+89
-28
lines changed

5 files changed

+89
-28
lines changed

examples/hello-world/README.md

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,86 @@
44

55
In this example, we will create a single service application that deploys a web page displaying a message.
66

7-
Initialize the project using `docker-app init hello-world`.
7+
Initialize the single file project using `docker-app init -s hello-world`. A single file application contains the three sections, `metadata` corresponding `metadata.yml`, `settings` corresponding `settings.yml` and `services` corresponding `docker-compose.yml`.
8+
9+
```
10+
$ ls -l
11+
-rw-r--r-- 1 README.md
12+
$ docker-app init -s hello-world
13+
$ ls -l
14+
-rw-r--r-- 1 README.md
15+
-rw-r--r-- 1 hello-world.dockerapp
16+
$ cat hello-world.dockerapp
17+
#
18+
# Metadata.
19+
#
20+
version: 0.1.0
21+
name: hello-world
22+
description: ""
23+
maintainers:
24+
- name: dimrok
25+
email: ""
26+
targets:
27+
swarm: true
28+
kubernetes: true
29+
30+
--
31+
#
32+
# Services.
33+
#
34+
version: "3.6"
35+
services: {}
36+
37+
--
38+
#
39+
# Settings.
40+
#
41+
```
42+
43+
Open `hello-world.dockerapp` with your favorite text editor.
844

945
### Edit metadata
1046

11-
Go to `hello-world.dockerapp/` and open `metadata.yml` and fill the following fields:
12-
- description
13-
- maintainers
47+
Edit the `description` and `maintainers` fields in the metadata section.
1448

1549
### Add variables to the compose file
1650

17-
Open `docker-compose.yml` and add a service `hello`.
51+
Add a service `hello` to the `services` section.
1852

1953
```
54+
[...]
55+
---
56+
#
57+
# Services.
58+
#
2059
services:
2160
hello:
2261
image: hashicorp/http-echo
2362
command: ["-text", "${text}"]
2463
ports:
2564
- ${port}:5678
65+
66+
---
67+
[...]
2668
```
2769

2870
### Give variables their default value
2971

30-
Open `settings.yml` and add every variables with the default value you want, e.g.:
72+
In the settings section, add every variables with the default value you want, e.g.:
3173

3274
```
33-
$ cat settings.yml
75+
[...]
76+
---
77+
#
78+
# Settings.
79+
#
3480
port: 8080
35-
text: world
81+
text: hello world!
3682
```
3783

3884
### Render
3985

40-
You can now render your application by running `docker-app render` or even personalize the rendered compose file by running `docker-app render -s text="hello user"`.
86+
You can now render your application by running `docker-app render` or even personalize the rendered compose file by running `docker-app render -s text="hello user!"`.
4187

4288
Create a `render` directory and redirect the output of `docker-app render ...` to `render/docker-compose.yml`.
4389

@@ -48,4 +94,6 @@ docker-app render -s text="hello user" > render/docker-compose.yml
4894

4995
### Deploy
5096

51-
Deploy your application by running `docker-app deploy -c render/docker-compose.yml`. http://<ip_of_your_node>:8080 will display your message, e.g. http://127.0.0.1:8080 if you deployed locally.
97+
You directly deploy your application by running `docker-app deploy -s text="hello user!"` or you can use the rendered version and run `docker stack deploy render/docker-compose.yml`.
98+
99+
`http://<ip_of_your_node>:8080` will display your message, e.g. http://127.0.0.1:8080 if you deployed locally.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Metadata.
3+
#
4+
version: 0.1.0
5+
name: hello-world
6+
description: "Hello world!"
7+
maintainers:
8+
- name: user
9+
10+
targets:
11+
swarm: true
12+
kubernetes: true
13+
14+
--
15+
#
16+
# Services.
17+
#
18+
version: "3.6"
19+
services:
20+
hello:
21+
image: hashicorp/http-echo
22+
command: ["-text", "${text}"]
23+
ports:
24+
- ${port}:5678
25+
26+
--
27+
#
28+
# Settings.
29+
#
30+
port: 8080
31+
text: hello world!

examples/hello-world/hello-world.dockerapp/docker-compose.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/hello-world/hello-world.dockerapp/metadata.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/hello-world/hello-world.dockerapp/settings.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)