Skip to content

Commit 6aa86f6

Browse files
committed
Merge pull request dockersamples#3 from bfirsh/compose-file-2
Convert app to use Compose file 2
2 parents 4f9d03c + bb24708 commit 6aa86f6

File tree

19 files changed

+63
-33
lines changed

19 files changed

+63
-33
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Example Voting App
22
==================
33

4-
This is an example Docker app with multiple services. It is run with Docker Compose and uses Docker Networking to connect containers together.
4+
This is an example Docker app with multiple services. It is run with Docker Compose and uses Docker Networking to connect containers together. You will need Docker Compose 1.6 or later.
55

66
More info at https://blog.docker.com/2015/11/docker-toolbox-compose/
77

@@ -17,10 +17,9 @@ Architecture
1717
Running
1818
-------
1919

20-
Since this app makes use of Compose's experimental networking support, it must be started with:
20+
Run in this directory:
2121

22-
$ cd vote-apps/
23-
$ docker-compose --x-networking up -d
22+
$ docker-compose up -d
2423

2524
The app will be running on port 5000 on your Docker host, and the results will be on port 5001.
2625

docker-compose.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
version: "2"
2+
3+
services:
4+
voting-app:
5+
build: ./voting-app/.
6+
volumes:
7+
- ./voting-app:/app
8+
ports:
9+
- "5000:80"
10+
links:
11+
- redis
12+
networks:
13+
- front-tier
14+
- back-tier
15+
16+
result-app:
17+
build: ./result-app/.
18+
volumes:
19+
- ./result-app:/app
20+
ports:
21+
- "5001:80"
22+
links:
23+
- db
24+
networks:
25+
- front-tier
26+
- back-tier
27+
28+
worker:
29+
build: ./worker
30+
links:
31+
- db
32+
- redis
33+
networks:
34+
- back-tier
35+
36+
redis:
37+
image: redis
38+
ports: ["6379"]
39+
networks:
40+
- back-tier
41+
42+
db:
43+
image: postgres:9.4
44+
volumes:
45+
- "db-data:/var/lib/postgresql/data"
46+
networks:
47+
- back-tier
48+
49+
volumes:
50+
db-data:
51+
52+
networks:
53+
front-tier:
54+
back-tier:
55+
56+
File renamed without changes.
File renamed without changes.

vote-apps/result-app/server.js renamed to result-app/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ io.sockets.on('connection', function (socket) {
2424
async.retry(
2525
{times: 1000, interval: 1000},
2626
function(callback) {
27-
pg.connect('postgres://postgres@voteapps_db_1/postgres', function(err, client, done) {
27+
pg.connect('postgres://postgres@db/postgres', function(err, client, done) {
2828
if (err) {
2929
console.error("Failed to connect to db");
3030
}
File renamed without changes.
File renamed without changes.

vote-apps/docker-compose.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.
File renamed without changes.

vote-apps/voting-app/app.py renamed to voting-app/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
option_b = os.getenv('OPTION_B', "Dogs")
1313
hostname = socket.gethostname()
1414

15-
redis = connect_to_redis("voteapps_redis_1")
15+
redis = connect_to_redis("redis")
1616
app = Flask(__name__)
1717

1818

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

vote-apps/worker/src/main/java/worker/Worker.java renamed to worker/src/main/java/worker/Worker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
class Worker {
99
public static void main(String[] args) {
1010
try {
11-
Jedis redis = connectToRedis("voteapps_redis_1");
12-
Connection dbConn = connectToDB("voteapps_db_1");
11+
Jedis redis = connectToRedis("redis");
12+
Connection dbConn = connectToDB("db");
1313

1414
System.err.println("Watching vote queue");
1515

0 commit comments

Comments
 (0)