From ca8353c980b446e34f7f3b8b3befc2a9d19a0a74 Mon Sep 17 00:00:00 2001 From: Bernardo Henrique Date: Thu, 13 Sep 2018 23:10:55 -0300 Subject: [PATCH] Initial Commit Contains receipts service's project base already dockerided --- .dockerignore | 4 ++++ .gitignore | 3 +++ Dockerfile-dev | 15 +++++++++++++++ README.md | 21 +++++++++++++++++++++ docker-compose-dev.yml | 14 ++++++++++++++ manage.py | 7 +++++++ project/__init__.py | 15 +++++++++++++++ project/api/__init__.py | 0 project/config.py | 15 +++++++++++++++ project/tests/__init__.py | 0 requirements.txt | 1 + 11 files changed, 95 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile-dev create mode 100644 README.md create mode 100644 docker-compose-dev.yml create mode 100644 manage.py create mode 100644 project/__init__.py create mode 100644 project/api/__init__.py create mode 100644 project/config.py create mode 100644 project/tests/__init__.py create mode 100644 requirements.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9039563 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +env +.dockerignore +Dockerfile-dev +Dockerfile-prod \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc15f85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__ +env +.vscode/ \ No newline at end of file diff --git a/Dockerfile-dev b/Dockerfile-dev new file mode 100644 index 0000000..24594e4 --- /dev/null +++ b/Dockerfile-dev @@ -0,0 +1,15 @@ +# Base Image +FROM python:3.6.5-alpine + +# Setting working directory +WORKDIR /usr/src/app + +# Dealing with requirements +COPY ./requirements.txt /usr/src/app/requirements.txt +RUN pip install -r requirements.txt + +# Coping project +COPY . /usr/src/app + +# Running server +CMD python manage.py run -h 0.0.0.0 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..0c131a4 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Configurando o ambiente +Para instruções de como instalar o Docker e o Docker-compose clique [aqui](https://github.com/Kalkuli/2018.2-Kalkuli_Front-End/blob/master/README.md). + + +
+ +## Colocando no ar +Com o Docker e Docker-Compose instalados, basta apenas utilizar os comandos: + +```docker-compose -f docker-compose-dev.yml build``` + +e + +```docker-compose -f docker-compose-dev.yml up``` + +Acesse o servidor local no endereço apresentado abaixo: + +http://localhost:5006/ + + +Agora você já pode começar a contribuir! \ No newline at end of file diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml new file mode 100644 index 0000000..8017ebe --- /dev/null +++ b/docker-compose-dev.yml @@ -0,0 +1,14 @@ +version: '3.6' +services: + users: + build: + context: . + dockerfile: Dockerfile-dev + volumes: + - '.:/usr/src/app' + ports: + - 5006:5000 + environment: + - FLASK_APP=project/__init__.py + - FLASK_ENV=development + - APP_SETTINGS=project.config.DevelopmentConfig \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..afded0f --- /dev/null +++ b/manage.py @@ -0,0 +1,7 @@ +from flask.cli import FlaskGroup +from project import app + +cli = FlaskGroup(app) + +if __name__ == '__main__': + cli() \ No newline at end of file diff --git a/project/__init__.py b/project/__init__.py new file mode 100644 index 0000000..129b3c9 --- /dev/null +++ b/project/__init__.py @@ -0,0 +1,15 @@ +import os +from flask import Flask, jsonify + +# Instantiate the app +app = Flask(__name__) + +# Set Configuration +app_settings = os.getenv('APP_SETTINGS') +app.config.from_object(app_settings) + +@app.route('/', methods=['GET']) +def ping_pong(): + return jsonify({ + 'data': 'Welcome to Kalkuli Receipts Service' + }) \ No newline at end of file diff --git a/project/api/__init__.py b/project/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/project/config.py b/project/config.py new file mode 100644 index 0000000..b888c53 --- /dev/null +++ b/project/config.py @@ -0,0 +1,15 @@ +class BaseConfig: + """Base configuration""" + TESTING = False + +class DevelopmentConfig(BaseConfig): + """Development configuration""" + pass + +class TestingConfig(BaseConfig): + """Testing configuration""" + TESTING = True + +class ProductionConfig(BaseConfig): + """Production configuration""" + pass \ No newline at end of file diff --git a/project/tests/__init__.py b/project/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ae09db0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Flask==1.0.2 \ No newline at end of file