diff --git a/scripts/discard-dev-files.sh b/scripts/discard-dev-files.sh index b516cee4b4..21d444ec1a 100644 --- a/scripts/discard-dev-files.sh +++ b/scripts/discard-dev-files.sh @@ -1,5 +1,5 @@ rm -rf \{\{cookiecutter.project_slug\}\}/.git -rm -rf \{\{cookiecutter.project_slug\}\}/backend/app/Pipfile.lock +rm -rf \{\{cookiecutter.project_slug\}\}/backend/app/poetry.lock rm -rf \{\{cookiecutter.project_slug\}\}/frontend/node_modules rm -rf \{\{cookiecutter.project_slug\}\}/frontend/dist git checkout \{\{cookiecutter.project_slug\}\}/README.md diff --git a/{{cookiecutter.project_slug}}/backend/.gitignore b/{{cookiecutter.project_slug}}/backend/.gitignore index bee8a64b79..529e8d581f 100644 --- a/{{cookiecutter.project_slug}}/backend/.gitignore +++ b/{{cookiecutter.project_slug}}/backend/.gitignore @@ -1 +1,2 @@ __pycache__ +app.egg-info diff --git a/{{cookiecutter.project_slug}}/backend/app/Pipfile b/{{cookiecutter.project_slug}}/backend/app/Pipfile deleted file mode 100644 index 23090edabf..0000000000 --- a/{{cookiecutter.project_slug}}/backend/app/Pipfile +++ /dev/null @@ -1,39 +0,0 @@ -[[source]] -name = "pypi" -url = "https://pypi.org/simple" -verify_ssl = true - -[dev-packages] -mypy = "*" -black = "*" -jupyter = "*" -isort = "*" -autoflake = "*" -flake8 = "*" -pytest = "*" -vulture = "*" - -[packages] -fastapi = "*" -uvicorn = "*" -pyjwt = "*" -python-multipart = "*" -email-validator = "*" -requests = "*" -celery = "*" -passlib = {extras = ["bcrypt"],version = "*"} -tenacity = "*" -pydantic = "*" -emails = "*" -raven = "*" -gunicorn = "*" -jinja2 = "*" -psycopg2-binary = "*" -alembic = "*" -sqlalchemy = "*" - -[requires] -python_version = "3.6" - -[pipenv] -allow_prereleases = true diff --git a/{{cookiecutter.project_slug}}/backend/app/pyproject.toml b/{{cookiecutter.project_slug}}/backend/app/pyproject.toml new file mode 100644 index 0000000000..33c46fbf94 --- /dev/null +++ b/{{cookiecutter.project_slug}}/backend/app/pyproject.toml @@ -0,0 +1,40 @@ +[tool.poetry] +name = "app" +version = "0.1.0" +description = "" +authors = ["Admin "] + +[tool.poetry.dependencies] +python = "^3.7" +uvicorn = "^0.11.3" +fastapi = "^0.54.1" +pyjwt = "^1.7.1" +python-multipart = "^0.0.5" +email-validator = "^1.0.5" +requests = "^2.23.0" +celery = "^4.4.2" +passlib = {extras = ["bcrypt"], version = "^1.7.2"} +tenacity = "^6.1.0" +pydantic = "^1.4" +emails = "^0.5.15" +raven = "^6.10.0" +gunicorn = "^20.0.4" +jinja2 = "^2.11.2" +psycopg2-binary = "^2.8.5" +alembic = "^1.4.2" +sqlalchemy = "^1.3.16" +pytest = "^5.4.1" + +[tool.poetry.dev-dependencies] +mypy = "^0.770" +black = "^19.10b0" +isort = "^4.3.21" +autoflake = "^1.3.1" +flake8 = "^3.7.9" +pytest = "^5.4.1" +jupyter = "^1.0.0" +vulture = "^1.4" + +[build-system] +requires = ["poetry>=0.12"] +build-backend = "poetry.masonry.api" diff --git a/{{cookiecutter.project_slug}}/backend/backend.dockerfile b/{{cookiecutter.project_slug}}/backend/backend.dockerfile index 5c93fd1425..6108868ead 100644 --- a/{{cookiecutter.project_slug}}/backend/backend.dockerfile +++ b/{{cookiecutter.project_slug}}/backend/backend.dockerfile @@ -1,6 +1,16 @@ FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7 -RUN pip install celery~=4.3 passlib[bcrypt] tenacity requests emails "fastapi>=0.47.0" "uvicorn>=0.11.1" gunicorn pyjwt python-multipart email-validator jinja2 psycopg2-binary alembic SQLAlchemy +WORKDIR /app/ + +# Install Poetry +RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ + cd /usr/local/bin && \ + ln -s /opt/poetry/bin/poetry && \ + poetry config virtualenvs.create false + +# Copy poetry.lock* in case it doesn't exist in the repo +COPY ./app/pyproject.toml ./app/poetry.lock* /app/ +RUN poetry install --no-dev --no-root # For development, Jupyter remote kernel, Hydrogen # Using inside the container: @@ -10,7 +20,6 @@ RUN bash -c "if [ $env == 'dev' ] ; then pip install jupyterlab ; fi" EXPOSE 8888 COPY ./app /app -WORKDIR /app/ ENV PYTHONPATH=/app diff --git a/{{cookiecutter.project_slug}}/backend/celeryworker.dockerfile b/{{cookiecutter.project_slug}}/backend/celeryworker.dockerfile index 11f2851692..6de9b7e908 100644 --- a/{{cookiecutter.project_slug}}/backend/celeryworker.dockerfile +++ b/{{cookiecutter.project_slug}}/backend/celeryworker.dockerfile @@ -1,6 +1,16 @@ FROM python:3.7 -RUN pip install raven celery~=4.3 passlib[bcrypt] tenacity requests "fastapi>=0.47.0" emails pyjwt email-validator jinja2 psycopg2-binary alembic SQLAlchemy +WORKDIR /app/ + +# Install Poetry +RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ + cd /usr/local/bin && \ + ln -s /opt/poetry/bin/poetry && \ + poetry config virtualenvs.create false + +# Copy poetry.lock* in case it doesn't exist in the repo +COPY ./app/pyproject.toml ./app/poetry.lock* /app/ +RUN poetry install --no-dev --no-root # For development, Jupyter remote kernel, Hydrogen # Using inside the container: diff --git a/{{cookiecutter.project_slug}}/backend/tests.dockerfile b/{{cookiecutter.project_slug}}/backend/tests.dockerfile index d6e264a3cd..46c6661cd0 100644 --- a/{{cookiecutter.project_slug}}/backend/tests.dockerfile +++ b/{{cookiecutter.project_slug}}/backend/tests.dockerfile @@ -1,6 +1,16 @@ FROM python:3.7 -RUN pip install requests pytest tenacity passlib[bcrypt] "fastapi>=0.47.0" email-validator psycopg2-binary SQLAlchemy +WORKDIR /app/ + +# Install Poetry +RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ + cd /usr/local/bin && \ + ln -s /opt/poetry/bin/poetry && \ + poetry config virtualenvs.create false + +# Copy poetry.lock* in case it doesn't exist in the repo +COPY ./app/pyproject.toml ./app/poetry.lock* /app/ +RUN poetry install --no-dev --no-root # For development, Jupyter remote kernel, Hydrogen # Using inside the container: diff --git a/{{cookiecutter.project_slug}}/docker-compose.shared.env.yml b/{{cookiecutter.project_slug}}/docker-compose.shared.env.yml index ca5d475aa4..41d6de94a4 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.shared.env.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.shared.env.yml @@ -17,4 +17,5 @@ services: - env-postgres.env - env-backend.env environment: + - SERVER_NAME=${DOMAIN} - SERVER_HOST=https://${DOMAIN}