You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: examples/hello-world/README.md
+58-10Lines changed: 58 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,40 +4,86 @@
4
4
5
5
In this example, we will create a single service application that deploys a web page displaying a message.
6
6
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.
8
44
9
45
### Edit metadata
10
46
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.
14
48
15
49
### Add variables to the compose file
16
50
17
-
Open `docker-compose.yml` and add a service `hello`.
51
+
Add a service `hello` to the `services` section.
18
52
19
53
```
54
+
[...]
55
+
---
56
+
#
57
+
# Services.
58
+
#
20
59
services:
21
60
hello:
22
61
image: hashicorp/http-echo
23
62
command: ["-text", "${text}"]
24
63
ports:
25
64
- ${port}:5678
65
+
66
+
---
67
+
[...]
26
68
```
27
69
28
70
### Give variables their default value
29
71
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.:
31
73
32
74
```
33
-
$ cat settings.yml
75
+
[...]
76
+
---
77
+
#
78
+
# Settings.
79
+
#
34
80
port: 8080
35
-
text: world
81
+
text: hello world!
36
82
```
37
83
38
84
### Render
39
85
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!"`.
41
87
42
88
Create a `render` directory and redirect the output of `docker-app render ...` to `render/docker-compose.yml`.
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.
0 commit comments