Guest User

Untitled

a guest
Jul 10th, 2024
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. # Dockerfile
  2.  
  3. FROM python:3.12-slim-bullseye as python-base
  4.  
  5. ENV PYTHONUNBUFFERED=1 \
  6. PIP_DISABLE_PIP_VERSION_CHECK=on \
  7. PIP_DEFAULT_TIMEOUT=100 \
  8. POETRY_VERSION=1.8.2 \
  9. POETRY_HOME="/opt/poetry" \
  10. POETRY_CACHE_DIR="/root/.cache/pypoetry" \
  11. POETRY_VIRTUALENVS_IN_PROJECT=1 \
  12. POETRY_NO_INTERACTION=1 \
  13. VENV_PATH="/.venv"
  14.  
  15. ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
  16.  
  17. RUN apt-get update \
  18. && apt-get install --no-install-recommends -y \
  19. curl \
  20. build-essential
  21.  
  22. RUN --mount=type=cache,target="/root/.cache" \
  23. curl -sSL https://install.python-poetry.org | python -
  24.  
  25. COPY pyproject.toml poetry.lock ./
  26. COPY src/test_poetry/ src/test_poetry
  27.  
  28. RUN --mount=type=cache,target=$POETRY_CACHE_DIR \
  29. poetry install --only-root
  30.  
  31. CMD ["python", "src/test_poetry/main.py"]
  32.  
  33.  
  34. # pyproject.toml
  35.  
  36. [tool.poetry]
  37. name = "test-poetry"
  38. version = "0.1.0"
  39. description = ""
  40. authors = ["Kyrylo <[email protected]>"]
  41. readme = "README.md"
  42. packages = [{include = "test_poetry", from = "src"}]
  43.  
  44. [tool.poetry.dependencies]
  45. python = "^3.12"
  46.  
  47.  
  48. [build-system]
  49. requires = ["poetry-core"]
  50. build-backend = "poetry.core.masonry.api"
  51.  
  52.  
  53. # main.py
  54.  
  55. import sys
  56. print(sys.path)
  57.  
  58. # Error happens here when run in docker
  59. from test_poetry.views import test
Advertisement
Add Comment
Please, Sign In to add comment