From f60249e3e6e6c3810f5c7ab623e56fc80bbdd680 Mon Sep 17 00:00:00 2001 From: cdinuta Date: Thu, 30 May 2019 18:18:27 +0300 Subject: [PATCH 01/13] adding flask playing ground --- Dockerfile | 3 ++- flask/app.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 flask/app.py diff --git a/Dockerfile b/Dockerfile index 5c6c466..f37ac3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,8 @@ RUN pip3 install \ urllib3 \ simplejson \ Jinja2 \ - jinja2-cli + jinja2-cli \ + flask ## Cleanup diff --git a/flask/app.py b/flask/app.py new file mode 100644 index 0000000..9664370 --- /dev/null +++ b/flask/app.py @@ -0,0 +1,16 @@ +from flask import Flask, jsonify, request + +app = Flask(__name__) + + +@app.route('/') +def hello(): + return "Hello" + + +@app.route('/rend', methods=['GET']) +def get_content(): + return "tbd", 200 + + +app.run() From 8390a4410beb70298afc118d3882921dea94cb56 Mon Sep 17 00:00:00 2001 From: cdinuta Date: Fri, 31 May 2019 00:19:07 +0300 Subject: [PATCH 02/13] added 2 endpoints. --- Dockerfile | 3 ++- docker-compose.yml | 10 ++++++++-- flask/app.py | 16 ---------------- render_flask_app.py | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 19 deletions(-) delete mode 100644 flask/app.py create mode 100644 render_flask_app.py diff --git a/Dockerfile b/Dockerfile index f37ac3c..5bd8211 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,8 @@ RUN pip3 install \ simplejson \ Jinja2 \ jinja2-cli \ - flask + flask \ + jsonify ## Cleanup diff --git a/docker-compose.yml b/docker-compose.yml index cd29928..3d191c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,19 @@ version: "3" + services: jinja2docker: container_name: jinja2docker image: dinutac/jinja2docker:latest hostname: jinja2docker - entrypoint: tail -f /etc/alpine-release #keep the container up to use exec command from docker + entrypoint: python3 /home/dev/bin/render_flask_app.py environment: limit: 'sky' #example env var inserted. you can read it with environ('limit') volumes: - ./templates:/data - ./variables:/variables - - ./:/out + - ./:/home/dev/bin/ + ports: + - "5000:5000" + + expose: + - "5000" diff --git a/flask/app.py b/flask/app.py deleted file mode 100644 index 9664370..0000000 --- a/flask/app.py +++ /dev/null @@ -1,16 +0,0 @@ -from flask import Flask, jsonify, request - -app = Flask(__name__) - - -@app.route('/') -def hello(): - return "Hello" - - -@app.route('/rend', methods=['GET']) -def get_content(): - return "tbd", 200 - - -app.run() diff --git a/render_flask_app.py b/render_flask_app.py new file mode 100644 index 0000000..90c36ae --- /dev/null +++ b/render_flask_app.py @@ -0,0 +1,34 @@ +import os + +from flask import Flask, jsonify + +from render import Render + +app = Flask(__name__) + +env_vars = { + "TEMPLATES_DIR": os.environ.get('TEMPLATES_DIR'), + "VARS_DIR": os.environ.get('VARS_DIR'), + "TEMPLATE": os.environ.get('TEMPLATE'), + "VARIABLES": os.environ.get('VARIABLES'), + "TEMPLATES_DIR_FILES": os.listdir(os.environ.get('TEMPLATES_DIR')), + "VARS_DIR_FILES": os.listdir(os.environ.get('VARS_DIR')) +} + + +@app.route('/') +def get_vars(): + return jsonify(env_vars), 200 + + +@app.route('/rend/