FROM python:3.11
LABEL maintainer="Amritanshu <docker@tanshu.com>"

ADD https://git.tanshu.com/api/v1/repos/tanshu/gru/tags /tags.json
RUN git clone --single-branch --depth 1 --branch latest https://git.tanshu.com/tanshu/gru.git /app

# Install Poetry
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \
    cd /usr/local/bin && \
    ln -s /opt/poetry/bin/poetry && \
    poetry config virtualenvs.create false

WORKDIR /app

# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"

ENV PYTHONPATH=/app
EXPOSE 80
VOLUME /data

CMD ["poetry", "run", "python", "-m", "gru"]
