diff --git a/backend/Dockerfile b/backend/Dockerfile index d422a88..4f19c09 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,10 +1,22 @@ FROM python:3.8-slim-buster WORKDIR /app -COPY requirements.txt /app/requirements.txt -RUN pip3 install -r requirements.txt +ENV PYTHONFAULTHANDLER=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONHASHSEED=random \ + PIP_NO_CACHE_DIR=off \ + PIP_DISABLE_PIP_VERSION_CHECK=on \ + PIP_DEFAULT_TIMEOUT=100 \ + POETRY_VERSION=1.1.6 \ + GUNICORN_VERSION=20.1.0 -RUN pip3 install gunicorn +RUN pip install poetry==$POETRY_VERSION gunicorn==$GUNICORN_VERSION + +# copy requirements first for caching +COPY poetry.lock pyproject.toml /app/ + +RUN poetry config virtualenvs.create false \ + && poetry install --no-dev --no-interaction --no-ansi COPY . /app/backend CMD ["gunicorn", "--bind=0.0.0.0:5000", "backend.wsgi:app"] diff --git a/backend/README.md b/backend/README.md index 74bc2e9..40b0406 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,10 +1,15 @@ # Backend service ## Setup dev environment +Requirements: + - Python > 3.8 is installed + - Poetry is installed (https://python-poetry.org/docs/) + ``` pip3 install virtualenv virtualenv venv -pip3 install -r requirements.txt +source venv/bin/activate +poetry install ``` ## Startup in development diff --git a/backend/pyproject.toml b/backend/pyproject.toml new file mode 100644 index 0000000..b920fd0 --- /dev/null +++ b/backend/pyproject.toml @@ -0,0 +1,21 @@ +[tool.poetry] +name = "openenergize-backend" +version = "0.1.0" +description = "" +authors = ["Jan Bucher "] + +[tool.poetry.dependencies] +python = "^3.8" +Flask = "^1.1.4" +flask-restx = "^0.4.0" +requests = "^2.25.1" +PyYAML = "^5.4.1" +pymodbus = "^2.5.2" +cachetools = "^4.2.2" + +[tool.poetry.dev-dependencies] +pytest = "^6.2.4" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/backend/requirements.txt b/backend/requirements.txt deleted file mode 100644 index 6e31308..0000000 --- a/backend/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -flask -flask_restx -requests -pyyaml -pymodbus -cachetools