No root user TGI.

This commit is contained in:
Nicolas Patry 2025-03-07 11:23:02 +01:00
parent 8e92942a18
commit e2846f76fa
No known key found for this signature in database
GPG Key ID: 4242CEF24CB6DBF9
2 changed files with 12 additions and 6 deletions

View File

@ -250,9 +250,15 @@ ENTRYPOINT ["./entrypoint.sh"]
# Final image # Final image
FROM base FROM base
COPY ./tgi-entrypoint.sh /tgi-entrypoint.sh
RUN chmod +x /tgi-entrypoint.sh
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/root/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/" ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/root/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/"
ENTRYPOINT ["/tgi-entrypoint.sh"] ENV UID=1000
# CMD ["--json-output"] ENV USER=llm
RUN groupadd -g "${UID}" "${USER}" && useradd -m -u "${UID}" -g "${USER}" "${USER}"
# Give access to users to `/root/.local` where the python interpreter is located (since it was installed as root by uv).
RUN chmod 555 /root
USER ${USER}
WORKDIR /home/${USER}
RUN mkdir -p -m 0744 /home/${USER}/cache
COPY --chown=${USER}:${USER} ./tgi-entrypoint.sh tgi-entrypoint.sh
RUN chmod +x tgi-entrypoint.sh
ENTRYPOINT ["./tgi-entrypoint.sh"]

View File

@ -2,5 +2,5 @@
ldconfig 2>/dev/null || echo 'unable to refresh ld cache, not a big deal in most cases' ldconfig 2>/dev/null || echo 'unable to refresh ld cache, not a big deal in most cases'
source ./.venv/bin/activate source /usr/src/.venv/bin/activate
exec text-generation-launcher $@ exec text-generation-launcher $@