|
| 1 | +FROM python:3.11-slim |
| 2 | + |
| 3 | +LABEL org.opencontainers.image.source=https://github.com/PythonistaGuild/Pythonista-API |
| 4 | +LABEL org.opencontainers.image.description="Pythonista API" |
| 5 | +LABEL org.opencontainers.image.licenses=MIT |
| 6 | + |
| 7 | +ENV PYTHONUNBUFFERED=1 \ |
| 8 | + # prevents python creating .pyc files |
| 9 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 10 | + \ |
| 11 | + # pip |
| 12 | + PIP_NO_CACHE_DIR=off \ |
| 13 | + PIP_DISABLE_PIP_VERSION_CHECK=on \ |
| 14 | + PIP_DEFAULT_TIMEOUT=100 \ |
| 15 | + \ |
| 16 | + # poetry |
| 17 | + # https://python-poetry.org/docs/configuration/#using-environment-variables |
| 18 | + # make poetry install to this location |
| 19 | + POETRY_HOME="/opt/poetry" \ |
| 20 | + # make poetry create the virtual environment in the project's root |
| 21 | + # it gets named `.venv` |
| 22 | + POETRY_VIRTUALENVS_IN_PROJECT=true \ |
| 23 | + # do not ask any interactive question |
| 24 | + POETRY_NO_INTERACTION=1 \ |
| 25 | + \ |
| 26 | + # paths |
| 27 | + # this is where our requirements + virtual environment will live |
| 28 | + PYSETUP_PATH="/opt/pysetup" \ |
| 29 | + VENV_PATH="/opt/pysetup/.venv" |
| 30 | + |
| 31 | +ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" |
| 32 | + |
| 33 | +RUN apt-get update \ |
| 34 | + && apt-get install --no-install-recommends -y \ |
| 35 | + git \ |
| 36 | + # deps for installing poetry |
| 37 | + curl \ |
| 38 | + ca-certificates \ |
| 39 | + # deps for building python deps |
| 40 | + build-essential \ |
| 41 | + libcurl4-gnutls-dev \ |
| 42 | + gnutls-dev \ |
| 43 | + gnupg \ |
| 44 | + libmagic-dev |
| 45 | + |
| 46 | +RUN curl -sSL https://install.python-poetry.org | python - |
| 47 | + |
| 48 | +# copy project requirement files here to ensure they will be cached. |
| 49 | +WORKDIR /app |
| 50 | +COPY poetry.lock pyproject.toml ./ |
| 51 | + |
| 52 | +# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally |
| 53 | +RUN poetry install --without=dev |
| 54 | + |
| 55 | +COPY . /app/ |
| 56 | +ENTRYPOINT poetry run python -O launcher.py |
0 commit comments