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

Commit fc34e5f

Browse files
authored
Merge pull request #256 from Dimrok/feature/update-examples
Update outdated examples (single-file, helm, etc.)
2 parents b7527d0 + 222b27c commit fc34e5f

5 files changed

Lines changed: 115 additions & 158 deletions

File tree

examples/hello-world/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ $ ls -l
1515
-rw-r--r-- 1 hello-world.dockerapp
1616
$ cat hello-world.dockerapp
1717
# This section contains your application metadata.
18+
# Version of the application
1819
version: 0.1.0
20+
# Name of the application
1921
name: hello-world
20-
description: ""
21-
namespace: ""
22+
# A short description of the application
23+
description:
24+
# Namespace to use when pushing to a registry. This is typically your Hub username.
25+
#namespace: myHubUsername
26+
# List of application maitainers with name and email for each
2227
maintainers:
23-
- name: dimrok
24-
email: ""
28+
- name: user
29+
email:
30+
# Specify false here if your application doesn't support Swarm or Kubernetes
2531
targets:
2632
swarm: true
2733
kubernetes: true
@@ -39,7 +45,7 @@ Open `hello-world.dockerapp` with your favorite text editor.
3945

4046
### Edit metadata
4147

42-
Edit the `description` and `maintainers` fields in the metadata section.
48+
Edit the `description`, `namespace` and `maintainers` fields in the metadata section.
4349

4450
### Add variables to the compose file
4551

@@ -75,7 +81,7 @@ In the settings section, add every variables with the default value you want, e.
7581
---
7682
# This section contains the default values for your application settings.
7783
port: 8080
78-
text: hello world!
84+
text: Hello, World!
7985
```
8086
8187
### Render
@@ -86,11 +92,11 @@ Create a `render` directory and redirect the output of `docker-app render ...` t
8692

8793
```bash
8894
$ mkdir -p render
89-
$ docker-app render -s text="hello user" > render/docker-compose.yml
95+
$ docker-app render -s text="Hello user!" > render/docker-compose.yml
9096
```
9197

9298
### Deploy
9399

94-
You directly deploy your application by running `docker-app deploy --set text="hello user!"` or you can use the rendered version and run `docker stack deploy render/docker-compose.yml`.
100+
You directly deploy your application by running `docker-app deploy --set text="Hello user!"` or you can use the rendered version and run `docker stack deploy render/docker-compose.yml`.
95101

96102
`http://<ip_of_your_node>:8080` will display your message, e.g. http://127.0.0.1:8080 if you deployed locally.
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
#
2-
# Metadata.
3-
#
1+
# This section contains your application metadata.
2+
# Version of the application
43
version: 0.1.0
4+
# Name of the application
55
name: hello-world
6-
description: "Hello world!"
7-
namespace: "myhubuser"
6+
# A short description of the application
7+
description: "Hello, World!"
8+
# Namespace to use when pushing to a registry. This is typically your Hub username.
9+
namespace: myHubUsername
10+
# List of application maitainers with name and email for each
811
maintainers:
9-
- name: user
10-
email: "user@email.com"
12+
- name: user
13+
email: "user@email.com"
14+
# Specify false here if your application doesn't support Swarm or Kubernetes
1115
targets:
1216
swarm: true
1317
kubernetes: true
1418

1519
--
16-
#
17-
# Services.
18-
#
20+
# This section contains the Compose file that describes your application services.
1921
version: "3.6"
2022
services:
2123
hello:
@@ -25,8 +27,6 @@ services:
2527
- ${port}:5678
2628

2729
--
28-
#
29-
# Settings.
30-
#
30+
# This section contains the default values for your application settings.
3131
port: 8080
32-
text: hello world!
32+
text: Hello, World!

examples/voting-app/README.md

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
### Initialize project
44

5-
In this example, we will create an app from the existing Docker sample `example-voting-app`. First download the project [here](https://github.com/dockersamples/example-voting-app).
5+
In this example, we will create an app from the existing Docker sample `example-voting-app`. First download the `docker-stack.yml` [here](https://github.com/dockersamples/example-voting-app) ([direct link](https://raw.githubusercontent.com/dockersamples/example-voting-app/master/docker-stack.yml)
66

7-
Initialize the project using `docker-app init voting-app --compose-file example-voting-app/docker-stack.yml`.
7+
Initialize the project using `docker-app init voting-app --compose-file docker-stack.yml`.
88

99
### Edit metadata
1010

1111
Go to `voting-app.dockerapp/` and open `metadata.yml` and fill the following fields:
1212
- description
1313
- maintainers
14+
- namespace
1415

1516
### Add variables to the compose file
1617

@@ -37,7 +38,7 @@ Change default replicas, from:
3738
[voting-app.dockerapp/docker-compose.yml](voting-app.dockerapp/docker-compose.yml):
3839
```yml
3940
[...]
40-
vote:
41+
vote:
4142
image: ${vote.image.name}:${vote.image.tag}
4243
ports:
4344
- ${vote.port}:80
@@ -174,79 +175,4 @@ result:
174175

175176
### Wrap everything in a Makefile
176177

177-
Add a Makefile to simplify rendering, deploying and killing your app.
178-
179-
---
180-
181-
[voting-app.dockerapp/Makefile](voting-app.dockerapp/Makefile):
182-
```Makefile
183-
# Input.
184-
SETTINGS_DIR ?= settings
185-
APP_NAME := voting-app
186-
187-
# Output.
188-
DEVELOPMENT_DIR := build/development
189-
PRODUCTION_DIR := build/production
190-
PACK := $(APP_NAME).pack
191-
192-
#
193-
# Cleanup.
194-
#
195-
cleanup/production:
196-
@rm -rf $(PRODUCTION_DIR)
197-
198-
cleanup/development:
199-
@rm -rf $(DEVELOPMENT_DIR)
200-
201-
cleanup: cleanup/production cleanup/development
202-
203-
#
204-
# Render.
205-
#
206-
render/production: cleanup/production
207-
@mkdir -p $(PRODUCTION_DIR)
208-
docker-app render --settings-files $(SETTINGS_DIR)/production.yml > $(PRODUCTION_DIR)/docker-compose.yml
209-
210-
render/development: cleanup/development
211-
@mkdir -p $(DEVELOPMENT_DIR)
212-
docker-app render --settings-files $(SETTINGS_DIR)/development.yml > $(DEVELOPMENT_DIR)/docker-compose.yml
213-
214-
render: render/production render/development
215-
216-
#
217-
# Stop.
218-
#
219-
stop/production:
220-
docker stack rm ${APP_NAME}
221-
222-
stop/development:
223-
docker stack rm ${APP_NAME}-dev
224-
225-
stop: stop/production stop/development
226-
227-
#
228-
# Deploy.
229-
#
230-
deploy/production: render/production stop/production
231-
docker-app deploy --settings-files $(SETTINGS_DIR)/production.yml
232-
233-
deploy/development: render/development stop/development
234-
docker-app deploy --settings-files $(SETTINGS_DIR)/development.yml
235-
236-
#
237-
# Pack.
238-
#
239-
pack:
240-
docker-app pack -o $(PACK)
241-
242-
#
243-
# Helm.
244-
#
245-
helm/production:
246-
docker-app helm --settings-files $(SETTINGS_DIR)/production.yml
247-
248-
helm/development:
249-
docker-app helm --settings-files $(SETTINGS_DIR)/development.yml
250-
```
251-
252-
You can add more commands, depending on your needs.
178+
Add a Makefile to simplify rendering, deploying and killing your app, see [voting-app.dockerapp/Makefile](voting-app.dockerapp/Makefile).
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
# Version of the application
12
version: 0.1.0
3+
# Name of the application
24
name: voting-app
5+
# A short description of the application
36
description: "Dogs or cats?"
7+
# Namespace to use when pushing to a registry. This is typically your Hub username.
8+
namespace: myHubUsername
9+
# List of application maitainers with name and email for each
410
maintainers:
5-
- name: dimrok
6-
email: "antony.mechin@docker.com"
11+
- name: user
12+
email: user@email.com
13+
# Specify false here if your application doesn't support Swarm or Kubernetes
714
targets:
815
swarm: true
916
kubernetes: true

0 commit comments

Comments
 (0)