From 28f3d7e6cb7ed5b669882b75d16ac99bd1057ed6 Mon Sep 17 00:00:00 2001 From: Michal Kunc Date: Wed, 17 Nov 2021 21:56:11 +0100 Subject: [PATCH] Add stuff for docker + captain deployer --- .dockerignore | 2 + .gitignore | 144 ++++++++++++++++++++++++++++ captain-definition-explorer | 4 + db_explorer/Dockerfile | 14 +++ db_explorer/db_explorer/__init__.py | 1 + db_explorer/db_explorer/app.py | 1 - db_explorer/pyproject.toml | 1 + 7 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 captain-definition-explorer create mode 100644 db_explorer/Dockerfile create mode 100644 db_explorer/db_explorer/__init__.py diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..77cb9f6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git/ +db-importer/ \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ddebad --- /dev/null +++ b/.gitignore @@ -0,0 +1,144 @@ +#### joe made this: http://goel.io/joe + +#### python #### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# poetry +poetry.lock diff --git a/captain-definition-explorer b/captain-definition-explorer new file mode 100644 index 0000000..a2bdd31 --- /dev/null +++ b/captain-definition-explorer @@ -0,0 +1,4 @@ +{ + "schemaVersion": 2, + "dockerfilePath": "./db_explorer/Dockerfile" +} diff --git a/db_explorer/Dockerfile b/db_explorer/Dockerfile new file mode 100644 index 0000000..d07e5e4 --- /dev/null +++ b/db_explorer/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3 + +RUN python3 -m pip install poetry + +EXPOSE 5000 +WORKDIR /app + +COPY db_explorer/ /app/ + +RUN poetry update +RUN poetry run pip install setuptools + +ENTRYPOINT [ "poetry", "run" ] +CMD [ "gunicorn", "-b=0.0.0.0:5000", "db_explorer:app" ] \ No newline at end of file diff --git a/db_explorer/db_explorer/__init__.py b/db_explorer/db_explorer/__init__.py new file mode 100644 index 0000000..170bba3 --- /dev/null +++ b/db_explorer/db_explorer/__init__.py @@ -0,0 +1 @@ +from db_explorer.app import app diff --git a/db_explorer/db_explorer/app.py b/db_explorer/db_explorer/app.py index e86e8e0..4cd9f6f 100644 --- a/db_explorer/db_explorer/app.py +++ b/db_explorer/db_explorer/app.py @@ -37,7 +37,6 @@ def list_actions(): @app.route("/action/") def show_action(name): item = mongo.db.action.find_one_or_404({"name": name}) - print(item) if item["data"]["actions"]["value"] == None: if item["data"]["actionType"]["value"] == 'passive': item['_action_icon'] = None diff --git a/db_explorer/pyproject.toml b/db_explorer/pyproject.toml index a02acba..da5a36c 100644 --- a/db_explorer/pyproject.toml +++ b/db_explorer/pyproject.toml @@ -10,6 +10,7 @@ packages = [{include = "db_explorer"}] python = "^3.8" Flask = "^2.0.2" Flask-PyMongo = "^2.3.0" +gunicorn = "^20.1.0" [build-system]