From e9c846dd684ef68f0ccfa4c0bc4dcba5adc6af17 Mon Sep 17 00:00:00 2001 From: MrPandir Date: Tue, 21 May 2024 16:50:43 +0200 Subject: [PATCH] style: improve Dockerfile readability --- docker/Dockerfile | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f4d3ee3..8c40991 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,20 +1,12 @@ -FROM python:3.11-slim-bookworm as base -LABEL org.opencontainers.image.authors="MrPandir " -LABEL org.opencontainers.image.source="https://github.com/twirapp/silero-tts-api-server" -LABEL org.opencontainers.image.licenses="MIT" -LABEL org.opencontainers.image.title="Silero TTS API server" -LABEL org.opencontainers.image.description="This is a simple server that uses Silero models to convert text to audio files over HTTP" -LABEL org.opencontainers.image.vendor="TwirApp" +FROM python:3.11-slim-bookworm AS python-and-curl +RUN apt-get update && apt-get -y --no-install-recommends install curl # Install all dependencies from pyproject.toml # NOTE: Rye is used because you need to determine which version of torch to use +cpu or not # NOTE: The problem with uv is that it does not read the rye.excluded-dependencies metadata -FROM base as dependencies-installer +FROM python-and-curl AS dependencies-installer WORKDIR /app RUN <&2 +# Final State # Distroless is a small image with only python, providing a non-root user FROM gcr.io/distroless/python3-debian12:nonroot +LABEL org.opencontainers.image.authors="MrPandir " +LABEL org.opencontainers.image.source="https://github.com/twirapp/silero-tts-api-server" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.title="Silero TTS API server" +LABEL org.opencontainers.image.description="This is a simple server that uses Silero models to convert text to audio files over HTTP" +LABEL org.opencontainers.image.vendor="TwirApp" + WORKDIR /app ENV PATH=/app/.venv/bin:$PATH -# This is necessary for Python to understand where to look for libraries. +# This is necessary for python to understand where to look for libraries ENV PYTHONPATH="/app/.venv/lib/python3.11/site-packages/:$PYTHONPATH" USER nonroot COPY --from=models-installer /models models