From f8df077a08047335dcbb28e8902a07031791273f Mon Sep 17 00:00:00 2001 From: "Lorenzo (Mec-iS)" Date: Fri, 16 Oct 2020 16:07:07 +0100 Subject: [PATCH 1/4] Move Docker to Poetry --- .travis.yml | 6 ++-- Dockerfile | 42 +++++++++++++++------- README.md | 2 +- docker-entrypoint.sh | 9 +++++ poetry.lock | 84 ++++++++++++++++++++++++-------------------- pyproject.toml | 2 +- requirements.txt | 37 ------------------- setup.py | 25 ------------- 8 files changed, 87 insertions(+), 120 deletions(-) create mode 100644 docker-entrypoint.sh delete mode 100644 requirements.txt diff --git a/.travis.yml b/.travis.yml index 5b696766..6a8c98d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,9 @@ language: python python: - - "3.6" - - "3.6-dev" # 3.6 development branch - "3.7" - "3.7-dev" # 3.7 development branch install: - - pip install -r requirements.txt --no-cache -script: pytest + - pip install poetry && poetry install --no-interaction --no-ansi +script: .venv/bin/pytest env: - API_NAME=api PORT=8000 diff --git a/Dockerfile b/Dockerfile index e35b5b4e..64d2e732 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,35 @@ -FROM tiangolo/uwsgi-nginx-flask:python3.7 -# maybe we want to move to: -# FROM tiangolo/meinheld-gunicorn-flask:python3.6 +FROM python:3.7.6-alpine3.11 as base -MAINTAINER Akshay Dahiya +ENV PYTHONFAULTHANDLER=1 \ + PYTHONHASHSEED=random \ + PYTHONUNBUFFERED=1 -COPY ./requirements.txt requirements.txt -# install certificates which were not installed in the base image -RUN apt-get update && apt-get install -y ca-certificates -RUN pip install -U pip && pip install --upgrade pip setuptools \ - && pip install -r requirements.txt && rm -rf * +FROM base as builder -COPY . /app +ENV PIP_DEFAULT_TIMEOUT=100 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PIP_NO_CACHE_DIR=1 \ + POETRY_VERSION=1.0.5 \ + PATH=/root/.local/bin:$PATH -ENV PYTHONPATH $PYTHONPATH:/app:/app/hydrus +RUN apk add --no-cache gcc libffi-dev musl-dev \ + py3-virtualenv git postgresql-dev \ + libxml2 libxml2-dev libxslt-dev -RUN mv /app/hydrus/uwsgi.ini /app/uwsgi.ini +COPY . ./app +WORKDIR /app -ENV MESSAGE "Hail Hydra" +RUN pip install --user "poetry==$POETRY_VERSION" +RUN pwd +RUN virtualenv -p $(which python) .venv + +RUN pwd + +RUN poetry build && .venv/bin/pip install dist/*.whl + +FROM base as final + +RUN apk add --no-cache libffi libpq +COPY --from=builder /app/.venv /.venv +COPY docker-entrypoint.sh ./ +CMD ["./docker-entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 0fc8a7d5..1c1b346f 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ git checkout -b develop origin/develop Install hydrus using: ```bash -pip3 install -r requirements.txt +poetry install python3 setup.py install ``` diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 00000000..fe1c44f7 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +. /.venv/bin/activate + +# exec uwsgi --http :8080 --wsgi-file hydrus/app.py + +exec uwsgi --http :8080 hydrus/uwsgi.ini \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 513d25f1..d29ccac5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -125,7 +125,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "colorama" -version = "0.4.3" +version = "0.4.4" description = "Cross-platform colored terminal text." category = "main" optional = false @@ -141,7 +141,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "flake8" -version = "3.8.3" +version = "3.8.4" description = "the modular source code checker: pep8 pyflakes and co" category = "main" optional = false @@ -765,7 +765,7 @@ test = ["pytest"] [[package]] name = "sqlalchemy" -version = "1.3.19" +version = "1.3.20" description = "Database Abstraction Library" category = "main" optional = false @@ -928,16 +928,16 @@ click = [ {file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"}, ] colorama = [ - {file = "colorama-0.4.3-py2.py3-none-any.whl", hash = "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff"}, - {file = "colorama-0.4.3.tar.gz", hash = "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"}, + {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, + {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, ] docutils = [ {file = "docutils-0.16-py2.py3-none-any.whl", hash = "sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af"}, {file = "docutils-0.16.tar.gz", hash = "sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc"}, ] flake8 = [ - {file = "flake8-3.8.3-py2.py3-none-any.whl", hash = "sha256:15e351d19611c887e482fb960eae4d44845013cc142d42896e9862f775d8cf5c"}, - {file = "flake8-3.8.3.tar.gz", hash = "sha256:f04b9fcbac03b0a3e58c0ab3a0ecc462e023a9faf046d57794184028123aa208"}, + {file = "flake8-3.8.4-py2.py3-none-any.whl", hash = "sha256:749dbbd6bfd0cf1318af27bf97a14e28e5ff548ef8e5b1566ccfb25a11e7c839"}, + {file = "flake8-3.8.4.tar.gz", hash = "sha256:aadae8761ec651813c24be05c6f7b4680857ef6afaae4651a4eccaef97ce6c3b"}, ] flask = [ {file = "Flask-1.1.2-py2.py3-none-any.whl", hash = "sha256:8a4fdd8936eba2512e9c85df320a37e694c93945b33ef33c89946a340a238557"}, @@ -1271,38 +1271,44 @@ sphinxcontrib-serializinghtml = [ {file = "sphinxcontrib_serializinghtml-1.1.4-py2.py3-none-any.whl", hash = "sha256:f242a81d423f59617a8e5cf16f5d4d74e28ee9a66f9e5b637a18082991db5a9a"}, ] sqlalchemy = [ - {file = "SQLAlchemy-1.3.19-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:f2e8a9c0c8813a468aa659a01af6592f71cd30237ec27c4cc0683f089f90dcfc"}, - {file = "SQLAlchemy-1.3.19-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:33d29ae8f1dc7c75b191bb6833f55a19c932514b9b5ce8c3ab9bc3047da5db36"}, - {file = "SQLAlchemy-1.3.19-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:3292a28344922415f939ee7f4fc0c186f3d5a0bf02192ceabd4f1129d71b08de"}, - {file = "SQLAlchemy-1.3.19-cp27-cp27m-win32.whl", hash = "sha256:883c9fb62cebd1e7126dd683222b3b919657590c3e2db33bdc50ebbad53e0338"}, - {file = "SQLAlchemy-1.3.19-cp27-cp27m-win_amd64.whl", hash = "sha256:860d0fe234922fd5552b7f807fbb039e3e7ca58c18c8d38aa0d0a95ddf4f6c23"}, - {file = "SQLAlchemy-1.3.19-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:73a40d4fcd35fdedce07b5885905753d5d4edf413fbe53544dd871f27d48bd4f"}, - {file = "SQLAlchemy-1.3.19-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:5a49e8473b1ab1228302ed27365ea0fadd4bf44bc0f9e73fe38e10fdd3d6b4fc"}, - {file = "SQLAlchemy-1.3.19-cp35-cp35m-macosx_10_14_x86_64.whl", hash = "sha256:6547b27698b5b3bbfc5210233bd9523de849b2bb8a0329cd754c9308fc8a05ce"}, - {file = "SQLAlchemy-1.3.19-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:107d4af989831d7b091e382d192955679ec07a9209996bf8090f1f539ffc5804"}, - {file = "SQLAlchemy-1.3.19-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:eb1d71643e4154398b02e88a42fc8b29db8c44ce4134cf0f4474bfc5cb5d4dac"}, - {file = "SQLAlchemy-1.3.19-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:b6ff91356354b7ff3bd208adcf875056d3d886ed7cef90c571aef2ab8a554b12"}, - {file = "SQLAlchemy-1.3.19-cp35-cp35m-win32.whl", hash = "sha256:96f51489ac187f4bab588cf51f9ff2d40b6d170ac9a4270ffaed535c8404256b"}, - {file = "SQLAlchemy-1.3.19-cp35-cp35m-win_amd64.whl", hash = "sha256:618db68745682f64cedc96ca93707805d1f3a031747b5a0d8e150cfd5055ae4d"}, - {file = "SQLAlchemy-1.3.19-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:6557af9e0d23f46b8cd56f8af08eaac72d2e3c632ac8d5cf4e20215a8dca7cea"}, - {file = "SQLAlchemy-1.3.19-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:8280f9dae4adb5889ce0bb3ec6a541bf05434db5f9ab7673078c00713d148365"}, - {file = "SQLAlchemy-1.3.19-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:b595e71c51657f9ee3235db8b53d0b57c09eee74dfb5b77edff0e46d2218dc02"}, - {file = "SQLAlchemy-1.3.19-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:51064ee7938526bab92acd049d41a1dc797422256086b39c08bafeffb9d304c6"}, - {file = "SQLAlchemy-1.3.19-cp36-cp36m-win32.whl", hash = "sha256:8afcb6f4064d234a43fea108859942d9795c4060ed0fbd9082b0f280181a15c1"}, - {file = "SQLAlchemy-1.3.19-cp36-cp36m-win_amd64.whl", hash = "sha256:e49947d583fe4d29af528677e4f0aa21f5e535ca2ae69c48270ebebd0d8843c0"}, - {file = "SQLAlchemy-1.3.19-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:9e865835e36dfbb1873b65e722ea627c096c11b05f796831e3a9b542926e979e"}, - {file = "SQLAlchemy-1.3.19-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:276936d41111a501cf4a1a0543e25449108d87e9f8c94714f7660eaea89ae5fe"}, - {file = "SQLAlchemy-1.3.19-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:c7adb1f69a80573698c2def5ead584138ca00fff4ad9785a4b0b2bf927ba308d"}, - {file = "SQLAlchemy-1.3.19-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:465c999ef30b1c7525f81330184121521418a67189053bcf585824d833c05b66"}, - {file = "SQLAlchemy-1.3.19-cp37-cp37m-win32.whl", hash = "sha256:aa0554495fe06172b550098909be8db79b5accdf6ffb59611900bea345df5eba"}, - {file = "SQLAlchemy-1.3.19-cp37-cp37m-win_amd64.whl", hash = "sha256:15c0bcd3c14f4086701c33a9e87e2c7ceb3bcb4a246cd88ec54a49cf2a5bd1a6"}, - {file = "SQLAlchemy-1.3.19-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:fe7fe11019fc3e6600819775a7d55abc5446dda07e9795f5954fdbf8a49e1c37"}, - {file = "SQLAlchemy-1.3.19-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:c898b3ebcc9eae7b36bd0b4bbbafce2d8076680f6868bcbacee2d39a7a9726a7"}, - {file = "SQLAlchemy-1.3.19-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:072766c3bd09294d716b2d114d46ffc5ccf8ea0b714a4e1c48253014b771c6bb"}, - {file = "SQLAlchemy-1.3.19-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:26c5ca9d09f0e21b8671a32f7d83caad5be1f6ff45eef5ec2f6fd0db85fc5dc0"}, - {file = "SQLAlchemy-1.3.19-cp38-cp38-win32.whl", hash = "sha256:b70bad2f1a5bd3460746c3fb3ab69e4e0eb5f59d977a23f9b66e5bdc74d97b86"}, - {file = "SQLAlchemy-1.3.19-cp38-cp38-win_amd64.whl", hash = "sha256:83469ad15262402b0e0974e612546bc0b05f379b5aa9072ebf66d0f8fef16bea"}, - {file = "SQLAlchemy-1.3.19.tar.gz", hash = "sha256:3bba2e9fbedb0511769780fe1d63007081008c5c2d7d715e91858c94dbaa260e"}, + {file = "SQLAlchemy-1.3.20-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:bad73f9888d30f9e1d57ac8829f8a12091bdee4949b91db279569774a866a18e"}, + {file = "SQLAlchemy-1.3.20-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:e32e3455db14602b6117f0f422f46bc297a3853ae2c322ecd1e2c4c04daf6ed5"}, + {file = "SQLAlchemy-1.3.20-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:5cdfe54c1e37279dc70d92815464b77cd8ee30725adc9350f06074f91dbfeed2"}, + {file = "SQLAlchemy-1.3.20-cp27-cp27m-win32.whl", hash = "sha256:2e9bd5b23bba8ae8ce4219c9333974ff5e103c857d9ff0e4b73dc4cb244c7d86"}, + {file = "SQLAlchemy-1.3.20-cp27-cp27m-win_amd64.whl", hash = "sha256:5d92c18458a4aa27497a986038d5d797b5279268a2de303cd00910658e8d149c"}, + {file = "SQLAlchemy-1.3.20-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:53fd857c6c8ffc0aa6a5a3a2619f6a74247e42ec9e46b836a8ffa4abe7aab327"}, + {file = "SQLAlchemy-1.3.20-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:0a92745bb1ebbcb3985ed7bda379b94627f0edbc6c82e9e4bac4fb5647ae609a"}, + {file = "SQLAlchemy-1.3.20-cp35-cp35m-macosx_10_14_x86_64.whl", hash = "sha256:b6f036ecc017ec2e2cc2a40615b41850dc7aaaea6a932628c0afc73ab98ba3fb"}, + {file = "SQLAlchemy-1.3.20-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:3aa6d45e149a16aa1f0c46816397e12313d5e37f22205c26e06975e150ffcf2a"}, + {file = "SQLAlchemy-1.3.20-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:ed53209b5f0f383acb49a927179fa51a6e2259878e164273ebc6815f3a752465"}, + {file = "SQLAlchemy-1.3.20-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:d3b709d64b5cf064972b3763b47139e4a0dc4ae28a36437757f7663f67b99710"}, + {file = "SQLAlchemy-1.3.20-cp35-cp35m-win32.whl", hash = "sha256:950f0e17ffba7a7ceb0dd056567bc5ade22a11a75920b0e8298865dc28c0eff6"}, + {file = "SQLAlchemy-1.3.20-cp35-cp35m-win_amd64.whl", hash = "sha256:8dcbf377529a9af167cbfc5b8acec0fadd7c2357fc282a1494c222d3abfc9629"}, + {file = "SQLAlchemy-1.3.20-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:0157c269701d88f5faf1fa0e4560e4d814f210c01a5b55df3cab95e9346a8bcc"}, + {file = "SQLAlchemy-1.3.20-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:7cd40cb4bc50d9e87b3540b23df6e6b24821ba7e1f305c1492b0806c33dbdbec"}, + {file = "SQLAlchemy-1.3.20-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:c092fe282de83d48e64d306b4bce03114859cdbfe19bf8a978a78a0d44ddadb1"}, + {file = "SQLAlchemy-1.3.20-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:166917a729b9226decff29416f212c516227c2eb8a9c9f920d69ced24e30109f"}, + {file = "SQLAlchemy-1.3.20-cp36-cp36m-win32.whl", hash = "sha256:632b32183c0cb0053194a4085c304bc2320e5299f77e3024556fa2aa395c2a8b"}, + {file = "SQLAlchemy-1.3.20-cp36-cp36m-win_amd64.whl", hash = "sha256:bbc58fca72ce45a64bb02b87f73df58e29848b693869e58bd890b2ddbb42d83b"}, + {file = "SQLAlchemy-1.3.20-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:b15002b9788ffe84e42baffc334739d3b68008a973d65fad0a410ca5d0531980"}, + {file = "SQLAlchemy-1.3.20-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:9e379674728f43a0cd95c423ac0e95262500f9bfd81d33b999daa8ea1756d162"}, + {file = "SQLAlchemy-1.3.20-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:2b5dafed97f778e9901b79cc01b88d39c605e0545b4541f2551a2fd785adc15b"}, + {file = "SQLAlchemy-1.3.20-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:fcdb3755a7c355bc29df1b5e6fb8226d5c8b90551d202d69d0076a8a5649d68b"}, + {file = "SQLAlchemy-1.3.20-cp37-cp37m-win32.whl", hash = "sha256:bca4d367a725694dae3dfdc86cf1d1622b9f414e70bd19651f5ac4fb3aa96d61"}, + {file = "SQLAlchemy-1.3.20-cp37-cp37m-win_amd64.whl", hash = "sha256:f605f348f4e6a2ba00acb3399c71d213b92f27f2383fc4abebf7a37368c12142"}, + {file = "SQLAlchemy-1.3.20-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:84f0ac4a09971536b38cc5d515d6add7926a7e13baa25135a1dbb6afa351a376"}, + {file = "SQLAlchemy-1.3.20-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:2909dffe5c9a615b7e6c92d1ac2d31e3026dc436440a4f750f4749d114d88ceb"}, + {file = "SQLAlchemy-1.3.20-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:c3ab23ee9674336654bf9cac30eb75ac6acb9150dc4b1391bec533a7a4126471"}, + {file = "SQLAlchemy-1.3.20-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:009e8388d4d551a2107632921320886650b46332f61dc935e70c8bcf37d8e0d6"}, + {file = "SQLAlchemy-1.3.20-cp38-cp38-win32.whl", hash = "sha256:bf53d8dddfc3e53a5bda65f7f4aa40fae306843641e3e8e701c18a5609471edf"}, + {file = "SQLAlchemy-1.3.20-cp38-cp38-win_amd64.whl", hash = "sha256:7c735c7a6db8ee9554a3935e741cf288f7dcbe8706320251eb38c412e6a4281d"}, + {file = "SQLAlchemy-1.3.20-cp39-cp39-macosx_10_14_x86_64.whl", hash = "sha256:4bdbdb8ca577c6c366d15791747c1de6ab14529115a2eb52774240c412a7b403"}, + {file = "SQLAlchemy-1.3.20-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:ce64a44c867d128ab8e675f587aae7f61bd2db836a3c4ba522d884cd7c298a77"}, + {file = "SQLAlchemy-1.3.20-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:be41d5de7a8e241864189b7530ca4aaf56a5204332caa70555c2d96379e18079"}, + {file = "SQLAlchemy-1.3.20-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:1f5f369202912be72fdf9a8f25067a5ece31a2b38507bb869306f173336348da"}, + {file = "SQLAlchemy-1.3.20-cp39-cp39-win32.whl", hash = "sha256:0cca1844ba870e81c03633a99aa3dc62256fb96323431a5dec7d4e503c26372d"}, + {file = "SQLAlchemy-1.3.20-cp39-cp39-win_amd64.whl", hash = "sha256:d05cef4a164b44ffda58200efcb22355350979e000828479971ebca49b82ddb1"}, + {file = "SQLAlchemy-1.3.20.tar.gz", hash = "sha256:d2f25c7f410338d31666d7ddedfa67570900e248b940d186b48461bd4e5569a1"}, ] thespian = [ {file = "thespian-3.9.11.zip", hash = "sha256:84887f0437ec144f7266ae22678bc5dc5d2a9e60a89f1f7c1707cbea5e03022a"}, diff --git a/pyproject.toml b/pyproject.toml index 7007dfbf..58658f66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,5 +48,5 @@ flake8 = "~3.8.3" [tool.poetry.dev-dependencies] [build-system] -requires = ["poetry-core>=1.0.0"] +requires = ["poetry-core>=1.0.5"] build-backend = "poetry.core.masonry.api" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e8ab8819..00000000 --- a/requirements.txt +++ /dev/null @@ -1,37 +0,0 @@ -alembic==1.0.10 -aniso8601==3.0.2 -appdirs==1.4.3 -blinker==1.4 -click==7.1.2 -certifi==2019.11.28 -Flask==1.1.1 -Flask-Cors==3.0.8 -Flask-RESTful==0.3.7 -Flask-SocketIO==4.2.1 -gevent==1.3.5 -gevent-websocket==0.10.1 -greenlet==0.4.13 -git+https://github.com/HTTP-APIs/hydra-python-core@master#egg=hydra_python_core -git+https://github.com/HTTP-APIs/hydra-openapi-parser@0.1.1#egg=hydra_openapi_parser -itsdangerous==1.1.0 -Jinja2==2.10.3 -lifter==0.4.1 -psycopg2==2.7.5 -pytest==5.4.1 -Mako==1.1.0 -MarkupSafe==1.1.1 -packaging==19.2 -pep8==1.7.1 -persisting-theory==0.2.1 -pyparsing==2.4.6 -python-dateutil==2.8.1 -python-editor==1.0.4 -python-engineio==3.11.2 -python-socketio==4.4.0 -pytz==2019.3 -PyYAML==5.2 -six==1.13.0 -SQLAlchemy==1.3.12 -thespian==3.9.11 -Werkzeug==0.16.0 -flake8 \ No newline at end of file diff --git a/setup.py b/setup.py index f27d31c9..c7eb301f 100644 --- a/setup.py +++ b/setup.py @@ -3,30 +3,6 @@ from setuptools import setup, find_packages -try: - # pip >=20 - from pip._internal.network.session import PipSession - from pip._internal.req import parse_requirements - - install_requires = parse_requirements("requirements.txt", session=PipSession()) - dependencies = [str(package.requirement) for package in install_requires] -except ImportError: - try: - # 10.0.0 <= pip <= 19.3.1 - from pip._internal.download import PipSession - from pip._internal.req import parse_requirements - except ImportError: - # pip <= 9.0.3 - from pip.download import PipSession - from pip.req import parse_requirements - - install_requires = parse_requirements("requirements.txt", session=PipSession()) - dependencies = [str(package.req) for package in install_requires] - -for package_index in range(len(dependencies)): - if dependencies[package_index].startswith("git+"): - dependencies[package_index] = dependencies[package_index].split("=")[1] - setup( name="hydrus", include_package_data=True, @@ -39,7 +15,6 @@ url="https://github.com/HTTP-APIs/hydrus", py_modules=["cli"], python_requires=">=3.5.2", - install_requires=dependencies, packages=find_packages(exclude=["contrib", "docs", "tests*", "hydrus.egg-info"]), package_dir={"hydrus": "hydrus"}, entry_points=""" From fa31bb7666a57d59e3e2f148e7ae0c1d66ade8da Mon Sep 17 00:00:00 2001 From: "Lorenzo (Mec-iS)" Date: Fri, 16 Oct 2020 17:23:49 +0100 Subject: [PATCH 2/4] Fix Dockerfile --- Dockerfile | 19 +++++++++++-------- README.md | 4 +++- docker-compose.yml | 2 ++ docker-entrypoint.sh | 9 --------- 4 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 64d2e732..0b5faee7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,9 @@ ENV PYTHONFAULTHANDLER=1 \ PYTHONHASHSEED=random \ PYTHONUNBUFFERED=1 +# +# building stage +# FROM base as builder ENV PIP_DEFAULT_TIMEOUT=100 \ @@ -18,18 +21,18 @@ RUN apk add --no-cache gcc libffi-dev musl-dev \ COPY . ./app WORKDIR /app - +# Poetry requires a virtualenv RUN pip install --user "poetry==$POETRY_VERSION" -RUN pwd RUN virtualenv -p $(which python) .venv - -RUN pwd - +# Build wheels with Poetry RUN poetry build && .venv/bin/pip install dist/*.whl +# +# running stage +# FROM base as final - RUN apk add --no-cache libffi libpq +# copy virtualenv and application COPY --from=builder /app/.venv /.venv -COPY docker-entrypoint.sh ./ -CMD ["./docker-entrypoint.sh"] \ No newline at end of file +COPY . ./app +CMD ["/.venv/bin/uwsgi --http :8080 /app/hydrus/uwsgi.ini"] diff --git a/README.md b/README.md index 1c1b346f..3b1d62a3 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ and run the server using: hydrus serve ``` -The demo should be up and running on `http://localhost:8080/serverapi/`. +The demo should be up and running on `http://localhost:8080/api/`. Usage @@ -87,6 +87,8 @@ For more info, head to the [Usage](http://www.hydraecosystem.org/01-Usage.html) Development ------------- +The suggested way of running `hydrus` is via Docker-Compose: `docker-compose up --build`. + From the `hydrus` directory: * To run formatter: `pip install black && black *.py` * To test for formatting: `flake8 *.py` diff --git a/docker-compose.yml b/docker-compose.yml index 45588cee..78158d22 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,8 @@ services: build: ./ ports: - "8080:8080" + # command: + # - /.venv/bin/uwsgi --http :8080 /app/hydrus/uwsgi.ini environment: # - HYDRUS_SERVER_URL=http://192.168.99.100:8081/ ## For windows 10 # - HYDRUS_SERVER_URL=http://54.169.232.177:8080/ diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index fe1c44f7..00000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e - -. /.venv/bin/activate - -# exec uwsgi --http :8080 --wsgi-file hydrus/app.py - -exec uwsgi --http :8080 hydrus/uwsgi.ini \ No newline at end of file From feff8cd5674e186328844282bb44df323c137c1b Mon Sep 17 00:00:00 2001 From: "Lorenzo (Mec-iS)" Date: Fri, 16 Oct 2020 17:31:03 +0100 Subject: [PATCH 3/4] Fix command --- .travis.yml | 2 +- Dockerfile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a8c98d8..ef9e8444 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,6 @@ python: - "3.7-dev" # 3.7 development branch install: - pip install poetry && poetry install --no-interaction --no-ansi -script: .venv/bin/pytest +script: pytest env: - API_NAME=api PORT=8000 diff --git a/Dockerfile b/Dockerfile index 0b5faee7..9dcb0b29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,4 +35,5 @@ RUN apk add --no-cache libffi libpq # copy virtualenv and application COPY --from=builder /app/.venv /.venv COPY . ./app -CMD ["/.venv/bin/uwsgi --http :8080 /app/hydrus/uwsgi.ini"] +WORKDIR /app +CMD ["/.venv/bin/gunicorn --bind 0.0.0.0:8080 --forwarded-allow-ips='*' hydrus:app"] From 53ab0b1b846eb30d6d331661c26ee8b5bf6b7285 Mon Sep 17 00:00:00 2001 From: "Lorenzo (Mec-iS)" Date: Fri, 16 Oct 2020 17:42:02 +0100 Subject: [PATCH 4/4] Amend travis install --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ef9e8444..6b81d3e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,8 @@ python: - "3.7" - "3.7-dev" # 3.7 development branch install: - - pip install poetry && poetry install --no-interaction --no-ansi + - pip install poetry + - poetry install --no-interaction --no-ansi script: pytest env: - API_NAME=api PORT=8000