Skip to content

Commit fb3ce0d

Browse files
committed
Ejemplos para el curso de "Docker para Desarrolladores" de Openwebinars
1 parent 7e4e74d commit fb3ce0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+367
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# docker-for-devs
2+
23
Ejemplos para el curso de docker de openwebinars

auto-build/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:2.7
2+
3+
WORKDIR /app
4+
5+
EXPOSE 5000
6+
7+
ENV NAME World
8+
9+
CMD ["python", "app.py"]
10+
11+
ADD requirements.txt /app/requirements.txt
12+
RUN pip install -r requirements.txt
13+
14+
ADD app.py /app/app.py

auto-build/app.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from flask import Flask
2+
from redis import Redis, RedisError
3+
import socket
4+
5+
6+
app = Flask(__name__)
7+
redis = Redis(host="redis")
8+
9+
10+
@app.route("/")
11+
def hello():
12+
try:
13+
visits = redis.incr('counter')
14+
except RedisError:
15+
visits = "<i>counter disabled. Cannot connect to Redis.</i>"
16+
17+
html = "<h3>Hola Openwebinars!</h3>" \
18+
"<b>Hostname:</b> {hostname}<br/>" \
19+
"<b>Visits:</b> {visits}<br/>" \
20+
"<br/>"
21+
22+
return html.format(hostname=socket.gethostname(), visits=visits)
23+
24+
if __name__ == "__main__":
25+
app.run(host="0.0.0.0", port=5000)

auto-build/docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "3.2"
2+
services:
3+
web:
4+
image: pchico83/ci
5+
build: .
6+
depends_on:
7+
- redis
8+
ports:
9+
- 5000:5000
10+
redis:
11+
image: redis

auto-build/hooks/build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
docker-compose build

auto-build/hooks/push

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
docker-compose push

auto-build/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask
2+
Redis

auto-cache-from/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:2.7
2+
3+
WORKDIR /app
4+
5+
EXPOSE 5000
6+
7+
ENV NAME World
8+
9+
CMD ["python", "app.py"]
10+
11+
ADD requirements.txt /app/requirements.txt
12+
RUN pip install -r requirements.txt
13+
14+
ADD app.py /app/app.py

auto-cache-from/app.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from flask import Flask
2+
from redis import Redis, RedisError
3+
import socket
4+
5+
6+
app = Flask(__name__)
7+
redis = Redis(host="redis")
8+
9+
10+
@app.route("/")
11+
def hello():
12+
try:
13+
visits = redis.incr('counter')
14+
except RedisError:
15+
visits = "<i>counter disabled. Cannot connect to Redis.</i>"
16+
17+
html = "<h3>Hola Openwebinars!</h3>" \
18+
"<b>Hostname:</b> {hostname}<br/>" \
19+
"<b>Visits:</b> {visits}<br/>" \
20+
"<br/>"
21+
22+
return html.format(hostname=socket.gethostname(), visits=visits)
23+
24+
if __name__ == "__main__":
25+
app.run(host="0.0.0.0", port=5000)

auto-cache-from/docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: "3.2"
2+
services:
3+
web:
4+
image: pchico83/ci
5+
build:
6+
cache_from:
7+
- pchico83/ci
8+
context: .
9+
depends_on:
10+
- redis
11+
ports:
12+
- 5000:5000
13+
redis:
14+
image: redis

0 commit comments

Comments
 (0)