Skip to content

Commit

Permalink
build: replace rye with uv
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPandir committed May 16, 2024
1 parent 7f4c7b6 commit d53cb90
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,32 @@ 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"

# Install all dependencies from requirements.lock
FROM base as dependencies-installer
WORKDIR /app
SHELL ["/bin/bash", "-c"]
RUN apt-get -y update && apt-get -y install curl && \
RUN <<EOF
apt-get -y update && apt-get -y install curl
apt-get autoremove && apt-get clean
# disabling uv is a temporary solution until this is fixed:
# https://github.com/astral-sh/uv/issues/1497
# And also until rye updates uv to the latest versions, at the time of writing rye is using version 0.1.0
RUN curl -sSf https://rye-up.com/get | NO_AUTO_INSTALL=1 RYE_INSTALL_OPTION="--yes" RYE_TOOLCHAIN=/usr/local/bin/python3 bash && \
bash -c "source $HOME/.rye/env && rye pin 3.12.2 && rye config --set-bool behavior.use-uv=false"
ENV PATH=/root/.rye/shims:$PATH
COPY pyproject.toml ./
RUN --mount=type=cache,target=/root/.cache rye sync --no-dev
curl -LsSf https://astral.sh/uv/install.sh | sh
ln -s /root/.cargo/bin/uv /usr/local/bin/uv
uv venv
EOF
COPY requirements.lock .
RUN --mount=type=cache,target=/root/.cache uv pip install --no-deps -r requirements.lock

# Install all silero models from the Internet or locally if available in the `models` directory
FROM base as models-installer
RUN apt-get -y update && apt-get -y install curl
COPY models models
COPY install_models.sh install_models.sh
RUN chmod -x install_models.sh && bash ./install_models.sh >&2


FROM base
WORKDIR /app
COPY --from=models-installer /models /app/models
COPY --from=models-installer /models models
COPY --from=dependencies-installer /app/.venv .venv
ENV PATH=/app/.venv/bin:$PATH
COPY /app ./app
COPY /tts ./tts
COPY ./app app
COPY ./tts tts
CMD ["litestar", "run", "--host", "0.0.0.0", "--port", "8000"]

0 comments on commit d53cb90

Please sign in to comment.