github.com/simonferquel/app@v0.6.1-0.20181012141724-68b7cccf26ac/examples/hello-world/README.md (about) 1 ## The Docker voting app 2 3 ### Initialize project 4 5 In this example, we will create a single service application that deploys a web page displaying a message. 6 7 Initialize the single file project using `docker-app init --single-file hello-world`. A single file application contains the three sections, `metadata` which corresponds to `metadata.yml`, `settings` which corresponds to `settings.yml` and `services` which corresponds to `docker-compose.yml`. 8 9 ```bash 10 $ ls -l 11 -rw-r--r-- 1 README.md 12 $ docker-app init --single-file 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 # This section contains your application metadata. 18 # Version of the application 19 version: 0.1.0 20 # Name of the application 21 name: hello-world 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 maintainers with name and email for each 27 maintainers: 28 - name: user 29 email: 30 31 --- 32 # This section contains the Compose file that describes your application services. 33 version: "3.6" 34 services: {} 35 36 --- 37 # This section contains the default values for your application settings. 38 ``` 39 40 Open `hello-world.dockerapp` with your favorite text editor. 41 42 ### Edit metadata 43 44 Edit the `description`, `namespace` and `maintainers` fields in the metadata section. 45 46 ### Add variables to the compose file 47 48 Add a service `hello` to the `services` section. 49 50 --- 51 52 [hello-world.dockerapp](hello-world.dockerapp): 53 ```yml 54 [...] 55 --- 56 # This section contains the Compose file that describes your application services. 57 services: 58 hello: 59 image: hashicorp/http-echo 60 command: ["-text", "${text}"] 61 ports: 62 - ${port}:5678 63 64 --- 65 [...] 66 ``` 67 68 ### Give variables their default value 69 70 In the settings section, add every variables with the default value you want, e.g.: 71 72 --- 73 74 [hello-world.dockerapp](hello-world.dockerapp): 75 ```yml 76 [...] 77 --- 78 # This section contains the default values for your application settings. 79 port: 8080 80 text: Hello, World! 81 ``` 82 83 ### Render 84 85 You can now render your application by running `docker-app render` or even personalize the rendered Compose file by running `docker-app render --set text="hello user!"`. 86 87 Create a `render` directory and redirect the output of `docker-app render ...` to `render/docker-compose.yml`. 88 89 ```bash 90 $ mkdir -p render 91 $ docker-app render -s text="Hello user!" > render/docker-compose.yml 92 ``` 93 94 ### Deploy 95 96 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`. 97 98 `http://<ip_of_your_node>:8080` will display your message, e.g. http://127.0.0.1:8080 if you deployed locally.