Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions composetest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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
EXPOSE 5000
COPY . .
CMD [ "flask", "run" ]
Binary file added composetest/__pycache__/app.cpython-37.pyc
Binary file not shown.
23 changes: 23 additions & 0 deletions composetest/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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 LX01! saya sudah terlihat sebanyak {} kali .\n'.format(count)
12 changes: 12 additions & 0 deletions composetest/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
web:
build: .
ports:
- "8000:5000"
volumes:
- .:/code
environment:
FLASK_DEBUG: "true"
redis:
image: "redis:alpine"

2 changes: 2 additions & 0 deletions composetest/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flask
redis