move template to ./template;
added global README.md;
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
|
||||
|
||||
## Add any files that are not relevant for docker to build your image
|
||||
|
||||
**/.venv
|
||||
@@ -0,0 +1 @@
|
||||
.venv
|
||||
@@ -0,0 +1,10 @@
|
||||
FROM python:3.7.4-slim
|
||||
# Alpine isn't used here intentionally because especially with python there are often major issues when compiling dependencies
|
||||
WORKDIR /app
|
||||
RUN apt-get update && apt-get install -y build-essential
|
||||
COPY ./requirements.txt ./
|
||||
RUN pip install -r /app/requirements.txt
|
||||
COPY . .
|
||||
EXPOSE 4000
|
||||
# The -u flag is important if you want to observe the logs, otherwise python buffers the output
|
||||
ENTRYPOINT [ "python", "-u", "main.py" ]
|
||||
@@ -0,0 +1,4 @@
|
||||
# Color-Service
|
||||
|
||||
**Important**: This is not meant to be extended and only serves as an example to show how to call another service orchestrated by Docker Compose
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
from aiohttp import web
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
|
||||
|
||||
async def handle(request):
|
||||
name = request.match_info.get('name', "Anonymous")
|
||||
text = "Hello, " + name
|
||||
return web.Response(text=text)
|
||||
|
||||
|
||||
async def handle_color(request):
|
||||
""" returns a random color """
|
||||
colors = color_data["colors"]
|
||||
color = random.choice(colors)
|
||||
return web.json_response(data=color)
|
||||
|
||||
|
||||
def load_colors(path: str):
|
||||
""" loads color data from path """
|
||||
with open(path) as f:
|
||||
data = f.read()
|
||||
return json.loads(data)
|
||||
|
||||
|
||||
app = web.Application()
|
||||
app.add_routes([
|
||||
web.get('/color', handle_color),
|
||||
web.get('/hello/{name}', handle)])
|
||||
|
||||
color_data = load_colors("/app/data.json")
|
||||
|
||||
if __name__ == '__main__':
|
||||
port = os.environ.get("HTTP_PORT", "4000")
|
||||
print("Starting server on port ", port)
|
||||
web.run_app(app, port=int(port))
|
||||
@@ -0,0 +1,16 @@
|
||||
aiodns==2.0.0
|
||||
aiohttp==3.6.1
|
||||
async-timeout==3.0.1
|
||||
attrs==19.2.0
|
||||
brotlipy==0.7.0
|
||||
cchardet==2.1.4
|
||||
cffi==1.12.3
|
||||
chardet==3.0.4
|
||||
idna==2.8
|
||||
idna-ssl==1.1.0
|
||||
multidict==4.5.2
|
||||
pycares==3.0.0
|
||||
pycparser==2.19
|
||||
typing==3.7.4.1
|
||||
typing-extensions==3.7.4
|
||||
yarl==1.3.0
|
||||
Reference in New Issue
Block a user