diff --git a/Dockerfile b/Dockerfile index 8eef8de6..311ba2f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,16 @@ FROM python:3.9-slim # Set pip to have cleaner logs and no saved cache +# Set poetry to not make virtualenvs +# set pipx to use the same folder that pip puts scripts in ENV PIP_NO_CACHE_DIR=false \ - POETRY_VIRTUALENVS_CREATE=false + POETRY_VIRTUALENVS_IN_PROJECT=true \ + POETRY_INSTALLER_PARALLEL=false \ + PIPX_BIN_DIR=/usr/local/bin -# Install poetry -RUN pip install -U poetry +# install poetry +# this is pinned because sometimes versions have bugs, and this version is reliable enough to use +RUN pip install poetry==1.1.7 # See https://github.com/python-poetry/poetry/issues/3336 RUN poetry config experimental.new-installer false @@ -13,10 +18,19 @@ RUN poetry config experimental.new-installer false # Create the working directory WORKDIR /modmail +# copy the required files to install the dependencies. +COPY ./pyproject.toml . +COPY ./poetry.lock . + + +# Install project dependencies +RUN poetry install --no-dev --no-root + # Copy the source code in last to optimize rebuilding the image COPY . . -# Install project dependencies +# install the package itself. +# this is required for importlib.metadata to work RUN poetry install --no-dev -CMD ["python", "-m", "modmail"] +CMD ["poetry","run","python", "-m", "modmail"] diff --git a/pyproject.toml b/pyproject.toml index 66e844ae..eee4e5ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,21 +76,9 @@ line-length = 110 target-version = ['py38'] include = '\.pyi?$' -[tool.taskipy.tasks.export] -cmd = """ -echo 'Exporting installed packages to requirements.txt.\n\ -This task automatically relocks the lock file using "poetry lock --no-update"' && \ -poetry lock --no-update && \ -echo '# Do not manually edit.\n# Generate with "poetry run task export"\n' > requirements.txt && \ -echo "Exporting..." && \ -poetry export --without-hashes >> requirements.txt && \ -echo "Done exporting." -""" -help = "Export installed packages in requirements.txt format" - [tool.taskipy.tasks] # Documentation -docs = { cmd = "mkdocs serve", help = "Run the docs on a local automatically reloading server"} +docs = { cmd = "mkdocs serve", help = "Run the docs on a local automatically reloading server" } # Bot start = { cmd = "python -m modmail", help = "Run bot" } @@ -103,7 +91,7 @@ lint = { cmd = "pre-commit run --all-files", help = "Checks all files for CI err # Testing codecov-validate = { cmd = "curl --data-binary @.codecov.yml https://codecov.io/validate", help = "Validate `.codecov.yml` with their api." } -cov-server = { cmd = "coverage html", help = "Start an http.server for viewing coverage data."} +cov-server = { cmd = "coverage html", help = "Start an http.server for viewing coverage data." } post-cov-server = "python -m http.server 8012 --bind 127.0.0.1 --directory htmlcov" report = { cmd = "coverage report", help = "Show coverage report from previously run tests." } test = { cmd = "pytest -n auto --dist loadfile", help = "Runs tests and save results to a coverage report" } diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 6ed382e0..00000000 --- a/requirements.txt +++ /dev/null @@ -1,28 +0,0 @@ -# Do not manually edit. -# Generate with "poetry run task export" - -aiodns==3.0.0; python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0" -aiohttp==3.7.4.post0; python_version >= "3.6" -arrow==1.1.1; python_version >= "3.6" -async-timeout==3.0.1; python_full_version >= "3.5.3" and python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0" -attrs==21.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0" -brotlipy==0.7.0; python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0" -cchardet==2.1.7; python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0" -cffi==1.14.6; python_version >= "3.6" -chardet==4.0.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" or python_version >= "3.6" and python_full_version >= "3.8.0" -colorama==0.4.4; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -coloredlogs==15.0.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -discord.py @ https://github.com/Rapptz/discord.py/archive/master.zip ; python_full_version >= "3.8.0" -humanfriendly==9.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" -idna==3.2; python_version >= "3.6" -multidict==5.1.0; python_version >= "3.6" and python_full_version >= "3.8.0" or python_version >= "3.6" -pycares==4.0.0; python_version >= "3.6" -pycparser==2.20; python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.4.0" -pydantic==1.8.2; python_full_version >= "3.6.1" -pyreadline==2.1; python_version >= "2.7" and python_full_version < "3.0.0" and sys_platform == "win32" or python_full_version >= "3.5.0" and sys_platform == "win32" -python-dateutil==2.8.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6" -python-dotenv==0.19.0; python_full_version >= "3.6.1" and python_version >= "3.5" -six==1.16.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6" -toml==0.10.2; (python_version >= "2.6" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0") -typing-extensions==3.10.0.0; python_version >= "3.6" or python_full_version >= "3.6.1" or python_version >= "3.6" and python_full_version >= "3.8.0" -yarl==1.6.3; python_version >= "3.6" and python_full_version >= "3.8.0" or python_version >= "3.6"