Skip to content

Commit 371cd44

Browse files
authored
Merge pull request #2 from jakewright/docker-deployment
Add Docker Deployment tutorial code
2 parents 11a0d56 + 6858d3a commit 371cd44

File tree

7 files changed

+80
-0
lines changed

7 files changed

+80
-0
lines changed

docker/03-deployment/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Deploy Docker Containers with Docker Cloud
2+
3+
Docker Cloud is a service that automates the deployment of Docker images.
4+
In this tutorial, I show how to use Docker Cloud to easily deploy Docker containers based on Dockerfiles in a GitHub or BitBucket repository.
5+
6+
[Deploy Docker Containers with Docker Cloud](https://youtu.be/F82K07NmRpk)
7+
8+
# Getting started
9+
10+
This directory contains the source code from the tutorial. It is exactly the same as the code in `02-docker-compose` but with the addition of a Dockerfile in the `website` directory.
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"]

docker/03-deployment/product/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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM php:apache
2+
COPY . /var/www/html
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)