FROM python:3.11-buster

RUN curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.7.1 python3 -


ENV POETRY_NO_INTERACTION=1 \
    POETRY_VIRTUALENVS_IN_PROJECT=1 \
    POETRY_VIRTUALENVS_CREATE=1 \
    POETRY_CACHE_DIR=/tmp/poetry_cache

WORKDIR /app

COPY pyproject.toml poetry.lock /app/
COPY market_trade /app/market_trade/
COPY tools /app/tools

RUN mkdir --parents --mode 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh  --mount=type=cache,target=$POETRY_CACHE_DIR $HOME/.local/bin/poetry install --without dev

ENV VIRTUAL_ENV=/app/.venv \
    PATH="/app/.venv/bin:$PATH"