FROM debian:stable-slim AS builder

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=off

COPY . /sili_cli/
COPY entrypoint.sh /usr/local/bin/entrypoint

WORKDIR /sili_cli

RUN apt-get update && \
    apt-get install -y gosu python3 python-is-python3 pipx python3-pip && \
    apt-get remove --purge --auto-remove -y && \
    rm -rf /var/lib/apt/lists/*

RUN addgroup --gid 1001 --system gvm && \
    adduser --no-create-home --shell /bin/false --disabled-password --uid 1001 --system --group gvm

RUN ./install_requirements.sh
RUN mkdir -p /tmp/gvm/gvmd
RUN chmod -R 777 /tmp/gvm

RUN chown -R gvm:gvm /sili_cli && \
    chmod 755 /usr/local/bin/entrypoint

ENTRYPOINT [ "/usr/local/bin/entrypoint" ]

CMD ["tail -f /dev/null"]
