Dockerfile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Dockerfile from https://github.com/python-poetry/poetry/discussions/1879
  2. # `python-base` sets up all our shared environment variables
  3. FROM python:3.9.5-slim as python-base
  4. ENV PYTHONUNBUFFERED=1 \
  5. # prevents python creating .pyc as files
  6. PYTHONDONTWRITEBYTECODE=1 \
  7. \
  8. # pip
  9. PIP_NO_CACHE_DIR=off \
  10. PIP_DISABLE_PIP_VERSION_CHECK=on \
  11. PIP_DEFAULT_TIMEOUT=100 \
  12. \
  13. # poetry
  14. # https://python-poetry.org/docs/configuration/#using-environment-variables
  15. POETRY_VERSION=1.6.1 \
  16. # make poetry install to this location
  17. POETRY_HOME="/opt/poetry" \
  18. # make poetry create the virtual environment in the project's root
  19. # it gets named `.venv`
  20. POETRY_VIRTUALENVS_IN_PROJECT=true \
  21. # do not ask any interactive question
  22. POETRY_NO_INTERACTION=1 \
  23. \
  24. # paths
  25. # this is where our requirements + virtual environment will live
  26. PYSETUP_PATH="/opt/pysetup" \
  27. VENV_PATH="/opt/pysetup/.venv" \
  28. # Hikka
  29. DOCKER=true \
  30. GIT_PYTHON_REFRESH=quiet
  31. # prepend poetry and venv to path
  32. ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
  33. # `builder-base` stage is used to build deps + create our virtual environment
  34. FROM python-base as builder-base
  35. RUN apt-get update && apt-get install --no-install-recommends -y \
  36. # deps for installing poetry
  37. curl \
  38. # deps for building python deps
  39. build-essential
  40. # install poetry - respects $POETRY_VERSION & $POETRY_HOME
  41. RUN curl -sSL https://install.python-poetry.org | python -
  42. # copy project requirement files here to ensure they will be cached.
  43. WORKDIR $PYSETUP_PATH
  44. COPY poetry.lock pyproject.toml ./
  45. # install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
  46. RUN poetry install --no-dev
  47. # `production` image used for runtime
  48. FROM python-base as production
  49. COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
  50. WORKDIR /data/Hikka
  51. COPY . /data/Hikka
  52. EXPOSE 8080
  53. CMD python -m hikka