Skip to content

Commit 6232487

Browse files
committed
Docker Compose in 12 Minutes
0 parents  commit 6232487

File tree

8 files changed

+103
-0
lines changed

8 files changed

+103
-0
lines changed

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Jake Wright
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Tutorials
2+
3+
<img align="right" src="http://i.giphy.com/QHE5gWI0QjqF2.gif" width="260 "/>
4+
5+
This repository contains the source code from the YouTube tutorials at http://youtube.com/jaketvee.

docker/02-docker-compose/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Docker Compose in 12 Minutes
2+
3+
Docker compose is a tool for defining and running multi-container Docker applications. In this tutorial I show you the basics of Docker Compose, including how to write a `docker-compose.yml` file for a simple two-container e-commerce style website.
4+
5+
[Watch Docker Compose in 12 Minutes on YouTube](https://youtu.be/Qw9zlE3t8Ko)
6+
7+
# Getting started
8+
9+
This directory contains the source code from the tutorial. To run the application, `cd` into this directory and run `docker-compose up`. The product service and the website will start (if necessary, docker-compose will automatically build the containers).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: '3'
2+
3+
services:
4+
product-service:
5+
build: ./product
6+
volumes:
7+
- ./product:/usr/src/app
8+
ports:
9+
- 5001:80
10+
11+
website:
12+
image: php:apache
13+
volumes:
14+
- ./website:/var/www/html
15+
ports:
16+
- 5000:80
17+
depends_on:
18+
- product-service
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM python:3-onbuild
2+
COPY . /usr/src/app
3+
CMD ["python", "api.py"]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Product Service
2+
3+
# Import framework
4+
from flask import Flask
5+
from flask_restful import Resource, Api
6+
7+
# Instantiate the app
8+
app = Flask(__name__)
9+
api = Api(app)
10+
11+
class Product(Resource):
12+
def get(self):
13+
return {
14+
'products': ['Ice cream', 'Chocolate', 'Fruit', 'Eggs']
15+
}
16+
17+
# Create routes
18+
api.add_resource(Product, '/')
19+
20+
# Run the application
21+
if __name__ == '__main__':
22+
app.run(host='0.0.0.0', port=80, debug=True)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask==0.12
2+
flask-restful==0.3.5
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
<head>
3+
<title>My Shop</title>
4+
</head>
5+
6+
<body>
7+
<h1>Welcome to my shop</h1>
8+
<ul>
9+
<?php
10+
11+
$json = file_get_contents('http://product-service/');
12+
$obj = json_decode($json);
13+
14+
$products = $obj->products;
15+
16+
foreach ($products as $product) {
17+
echo "<li>$product</li>";
18+
}
19+
20+
?>
21+
</ul>
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)