Skip to content

Commit 4c96249

Browse files
authored
Merge pull request #913 from infosiftr/stack
Convert "wordpress" to use "docker stack deploy" as an initial "stack" foray
2 parents 858d786 + 0cb43ce commit 4c96249

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

.template-helpers/stack.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
... via [`docker stack deploy`](https://docs.docker.com/engine/reference/commandline/stack_deploy/) or [`docker-compose`](https://github.com/docker/compose)
2+
3+
Example `stack.yml` for `%%REPO%%`:
4+
5+
%%STACK-YML%%
6+
7+
[![Try in PWD](https://github.com/play-with-docker/stacks/raw/cff22438cb4195ace27f9b15784bbb497047afa7/assets/images/button.png)](http://play-with-docker.com?stack=%%STACK-URL%%)

update.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ for image in "${images[@]}"; do
5959
fi
6060
fi
6161

62+
stack=
63+
stackYml=
64+
stackUrl=
65+
if [ -f "$repo/stack.yml" ]; then
66+
stack="$(cat "$repo/stack.md" 2>/dev/null || cat "$helperDir/stack.md")"
67+
stackYml=$'```yaml\n'"$(cat "$repo/stack.yml")"$'\n```'
68+
stackCommit="$(git log -1 --format='format:%H' -- "$repo/stack.yml" 2>/dev/null || true)"
69+
[ "$stackCommit" ] || stackCommit='master'
70+
stackUrl="https://raw.githubusercontent.com/docker-library/docs/$stackCommit/$repo/stack.yml"
71+
fi
72+
6273
compose=
6374
composeYml=
6475
if [ -f "$repo/docker-compose.yml" ]; then
@@ -97,9 +108,15 @@ for image in "${images[@]}"; do
97108
echo " LOGO => $logo"
98109
replace_field "$targetFile" 'LOGO' "$logo" '\s*'
99110

111+
echo ' STACK => '"$repo"'/stack.md'
112+
replace_field "$targetFile" 'STACK' "$stack"
113+
echo ' STACK-YML => '"$repo"'/docker-stack.yml'
114+
replace_field "$targetFile" 'STACK-YML' "$stackYml"
115+
echo ' STACK-URL => '"$repo"'/docker-stack.yml'
116+
replace_field "$targetFile" 'STACK-URL' "$stackUrl"
117+
100118
echo ' COMPOSE => '"$repo"'/compose.md'
101119
replace_field "$targetFile" 'COMPOSE' "$compose"
102-
103120
echo ' COMPOSE-YML => '"$repo"'/docker-compose.yml'
104121
replace_field "$targetFile" 'COMPOSE-YML' "$composeYml"
105122

wordpress/content.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ $ docker run --name some-%%REPO%% -e WORDPRESS_DB_HOST=10.1.2.3:3306 \
3838
-e WORDPRESS_DB_USER=... -e WORDPRESS_DB_PASSWORD=... -d %%REPO%%
3939
```
4040

41-
## %%COMPOSE%%
41+
## %%STACK%%
4242

43-
Run `docker-compose up`, wait for it to initialize completely, and visit `http://localhost:8080` or `http://host-ip:8080`.
43+
Run `docker stack deploy -c stack.yml %%REPO%%` (or `docker-compose -f stack.yml up`), wait for it to initialize completely, and visit `http://swarm-ip:8080`, `http://localhost:8080` or `http://host-ip:8080` (as appropriate).
4444

4545
## Adding additional libraries / extensions
4646

wordpress/docker-compose.yml renamed to wordpress/stack.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2'
1+
version: '3.1'
22

33
services:
44

@@ -10,6 +10,6 @@ services:
1010
WORDPRESS_DB_PASSWORD: example
1111

1212
mysql:
13-
image: mariadb
13+
image: mysql:5.7
1414
environment:
1515
MYSQL_ROOT_PASSWORD: example

0 commit comments

Comments
 (0)