|
| 1 | +## Simple wordpress + mysql app |
| 2 | + |
| 3 | +### Visualize app configuration |
| 4 | + |
| 5 | +```yaml |
| 6 | +# docker-app render simple |
| 7 | +version: "3.6" |
| 8 | +services: |
| 9 | + mysql: |
| 10 | + deploy: |
| 11 | + mode: replicated |
| 12 | + replicas: 1 |
| 13 | + environment: |
| 14 | + MYSQL_DATABASE: wordpressdata |
| 15 | + MYSQL_PASSWORD: wordpress |
| 16 | + MYSQL_ROOT_PASSWORD: axx[<^cz3d.fPb |
| 17 | + MYSQL_USER: wordpress |
| 18 | + image: mysql:8 |
| 19 | + volumes: |
| 20 | + - type: volume |
| 21 | + source: db_data |
| 22 | + target: /var/lib/mysql |
| 23 | + wordpress: |
| 24 | + deploy: |
| 25 | + mode: global |
| 26 | + replicas: 0 |
| 27 | + environment: |
| 28 | + WORDPRESS_DB_HOST: mysql |
| 29 | + WORDPRESS_DB_NAME: wordpressdata |
| 30 | + WORDPRESS_DB_PASSWORD: wordpress |
| 31 | + WORDPRESS_DB_USER: wordpress |
| 32 | + WORDPRESS_DEBUG: "true" |
| 33 | + image: wordpress |
| 34 | +networks: {} |
| 35 | +volumes: |
| 36 | + db_data: |
| 37 | + name: db_data |
| 38 | +secrets: {} |
| 39 | +configs: {} |
| 40 | +``` |
| 41 | +
|
| 42 | +**Merge with override Compose file**. This example replaces cleartext DB passwords to use secrets instead. |
| 43 | +
|
| 44 | +```yaml |
| 45 | +# docker-app render simple -c with-secrets.yml |
| 46 | +version: "3.6" |
| 47 | +services: |
| 48 | + mysql: |
| 49 | + deploy: |
| 50 | + mode: replicated |
| 51 | + replicas: 1 |
| 52 | + environment: |
| 53 | + MYSQL_DATABASE: wordpressdata |
| 54 | + MYSQL_PASSWORD: "" |
| 55 | + MYSQL_PASSWORD_FILE: /run/secrets/simple_app_userpass |
| 56 | + MYSQL_ROOT_PASSWORD: "" |
| 57 | + MYSQL_ROOT_PASSWORD_FILE: /run/secrets/simple_app_rootpass |
| 58 | + MYSQL_USER: wordpress |
| 59 | + image: mysql:8 |
| 60 | + secrets: |
| 61 | + - source: mysql_rootpass |
| 62 | + - source: mysql_userpass |
| 63 | + volumes: |
| 64 | + - type: volume |
| 65 | + source: db_data |
| 66 | + target: /var/lib/mysql |
| 67 | + wordpress: |
| 68 | + deploy: |
| 69 | + mode: global |
| 70 | + replicas: 0 |
| 71 | + environment: |
| 72 | + WORDPRESS_DB_HOST: mysql |
| 73 | + WORDPRESS_DB_NAME: wordpressdata |
| 74 | + WORDPRESS_DB_PASSWORD: "" |
| 75 | + WORDPRESS_DB_PASSWORD_FILE: /run/secrets/sumple_app_userpass |
| 76 | + WORDPRESS_DB_USER: wordpress |
| 77 | + WORDPRESS_DEBUG: "true" |
| 78 | + image: wordpress |
| 79 | + secrets: |
| 80 | + - source: mysql_userpass |
| 81 | +networks: {} |
| 82 | +volumes: |
| 83 | + db_data: |
| 84 | + name: db_data |
| 85 | +secrets: |
| 86 | + mysql_rootpass: |
| 87 | + name: simple_app_rootpass |
| 88 | + external: true |
| 89 | + mysql_userpass: |
| 90 | + name: simple_app_userpass |
| 91 | + external: true |
| 92 | +configs: {} |
| 93 | +``` |
| 94 | +
|
| 95 | +**Override default settings**. This example sets `debug` to false. |
| 96 | + |
| 97 | +```yaml |
| 98 | +# docker-app render simple -s prod-settings.yml |
| 99 | +version: "3.6" |
| 100 | +[...] |
| 101 | + environment: |
| 102 | + WORDPRESS_DB_HOST: mysql |
| 103 | + WORDPRESS_DB_NAME: wordpressdata |
| 104 | + WORDPRESS_DB_PASSWORD: wordpress |
| 105 | + WORDPRESS_DB_USER: wordpress |
| 106 | + WORDPRESS_DEBUG: "false" |
| 107 | +[...] |
| 108 | +``` |
| 109 | + |
| 110 | +**Override from the command line**. This example sets `debug` to false and the database user to a |
| 111 | +different value. |
| 112 | +```yaml |
| 113 | +# docker-app render simple -e debug=true -e mysql.user.name=mollydock |
| 114 | +version: "3.6" |
| 115 | +services: |
| 116 | + mysql: |
| 117 | +[...] |
| 118 | + environment: |
| 119 | + MYSQL_DATABASE: wordpressdata |
| 120 | + MYSQL_PASSWORD: wordpress |
| 121 | + MYSQL_ROOT_PASSWORD: axx[<^cz3d.fPb |
| 122 | + MYSQL_USER: mollydock |
| 123 | +[...] |
| 124 | + wordpress: |
| 125 | +[...] |
| 126 | + environment: |
| 127 | + WORDPRESS_DB_HOST: mysql |
| 128 | + WORDPRESS_DB_NAME: wordpressdata |
| 129 | + WORDPRESS_DB_PASSWORD: wordpress |
| 130 | + WORDPRESS_DB_USER: mollydock |
| 131 | + WORDPRESS_DEBUG: "false" |
| 132 | +[...] |
| 133 | +``` |
| 134 | + |
| 135 | +### View app metadata |
| 136 | + |
| 137 | +```yaml |
| 138 | +# docker-app inspect simple |
| 139 | +version: 0.0.1 |
| 140 | +application: |
| 141 | + name: simple |
| 142 | + description: "" |
| 143 | + tag: "" |
| 144 | + labels: |
| 145 | + - alpha |
| 146 | + author: sakuya.izayoi |
| 147 | +targets: |
| 148 | + swarm: true |
| 149 | + kubernetes: true |
| 150 | +``` |
| 151 | + |
| 152 | +### Generate helm package |
| 153 | + |
| 154 | +`docker-app helm simple` will output a Helm package in the `./simple.helm` folder. `-c`, `-e` and `-s` flags apply the same way they do for the `render` subcommand. |
| 155 | + |
| 156 | +``` |
| 157 | +$ docker-app helm simple -c with-secrets.yml -s prod-settings.yml -e mysql.user.name=mollydock |
| 158 | +$ tree simple.helm |
| 159 | +simple.helm/ |
| 160 | +├── Chart.yaml |
| 161 | +└── templates |
| 162 | + └── stack.yaml |
| 163 | + |
| 164 | +1 directory, 2 files |
| 165 | +$ cat simple.helm/templates/stack.yaml |
| 166 | +typemeta: |
| 167 | + kind: stacks.compose.docker.com |
| 168 | + apiversion: v1beta2 |
| 169 | +objectmeta: |
| 170 | +[...] |
| 171 | +``` |
| 172 | +
|
| 173 | +### Generate distributable app package |
| 174 | +
|
| 175 | +`docker-app save simple` creates a Docker image packaging the relevant configuration files: |
| 176 | +
|
| 177 | +``` |
| 178 | +$ docker-app save simple |
| 179 | +$ docker images simple.docker-app |
| 180 | +REPOSITORY TAG IMAGE ID CREATED SIZE |
| 181 | +simple.docker-app latest 61f8cafb7762 4 minutes ago 1.2kB |
| 182 | +``` |
| 183 | +
|
| 184 | +The package can later be retrieved using `docker-app load`: |
| 185 | +
|
| 186 | +``` |
| 187 | +$ rm -rf simple.docker-app |
| 188 | +$ docker-app load simple.docker-app |
| 189 | +$ tar -tf simple.docker-app # TODO: should unpack automatically? |
| 190 | +metadata.yml |
| 191 | +services.yml |
| 192 | +settings.yml |
| 193 | +$ mv simple.docker-app simple # TODO: fix UX |
| 194 | +$ docker-app unpack simple |
| 195 | +$ tree simple.docker-app |
| 196 | +./simple.docker-app/ |
| 197 | +├── metadata.yml |
| 198 | +├── services.yml |
| 199 | +└── settings.yml |
| 200 | + |
| 201 | +0 directories, 3 files |
| 202 | +``` |
| 203 | +
|
| 204 | +### Archive app package |
| 205 | +
|
| 206 | +`docker-app pack simple` creates a tar archive containing the relevant configuration files: |
| 207 | +
|
| 208 | +``` |
| 209 | +$ docker-app pack simple -o myapp.tar |
| 210 | +$ tar -tf myapp.tar |
| 211 | +metadata.yml |
| 212 | +services.yml |
| 213 | +settings.yml |
| 214 | +``` |
| 215 | +
|
0 commit comments