move files around
This commit is contained in:
9
docker/docker-sample/Dockerfile
Normal file
9
docker/docker-sample/Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
FROM python:3.7-alpine
|
||||||
|
WORKDIR /code
|
||||||
|
ENV FLASK_APP app.py
|
||||||
|
ENV FLASK_RUN_HOST 0.0.0.0
|
||||||
|
RUN apk add --no-cache gcc musl-dev linux-headers
|
||||||
|
COPY requirements.txt requirements.txt
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
COPY . .
|
||||||
|
CMD ["flask", "run"]
|
||||||
25
docker/docker-sample/app.py
Normal file
25
docker/docker-sample/app.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
|
import redis
|
||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
cache = redis.Redis(host='redis', port=6379)
|
||||||
|
|
||||||
|
|
||||||
|
def get_hit_count():
|
||||||
|
retries = 5
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
return cache.incr('hits')
|
||||||
|
except redis.exceptions.ConnectionError as exc:
|
||||||
|
if retries == 0:
|
||||||
|
raise exc
|
||||||
|
retries -= 1
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def hello():
|
||||||
|
count = get_hit_count()
|
||||||
|
return 'Hello World! I have been seen {} times.\n'.format(count)
|
||||||
8
docker/docker-sample/docker-compose.yml
Normal file
8
docker/docker-sample/docker-compose.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "5001:5000"
|
||||||
|
redis:
|
||||||
|
image: "redis:alpine"
|
||||||
10
docker/docker-sample/pod.yaml
Normal file
10
docker/docker-sample/pod.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: demo
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: testpod
|
||||||
|
image: alpine:3.5
|
||||||
|
command: ["ping", "8.8.8.8"]
|
||||||
|
|
||||||
2
docker/docker-sample/requirements.txt
Normal file
2
docker/docker-sample/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
flask
|
||||||
|
redis
|
||||||
Reference in New Issue
Block a user