-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] Upgrade yt-whisper bot to use serverless pinecone client
- Loading branch information
Showing
5 changed files
with
72 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,53 @@ | ||
FROM python:3.11-bullseye | ||
# syntax=docker/dockerfile:1 | ||
|
||
WORKDIR /usr/src/app | ||
# Comments are provided throughout this file to help you get started. | ||
# If you need more help, visit the Dockerfile reference guide at | ||
# https://docs.docker.com/go/dockerfile-reference/ | ||
|
||
COPY yt_whisper /usr/src/app/yt_whisper | ||
COPY pyproject.toml /usr/src/app/pyproject.toml | ||
COPY README.md /usr/src/app/README.md | ||
ARG PYTHON_VERSION=3.11 | ||
FROM python:${PYTHON_VERSION}-slim as base | ||
|
||
RUN pip install -e . | ||
# Prevents Python from writing pyc files. | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# Keeps Python from buffering stdout and stderr to avoid situations where | ||
# the application crashes without emitting any logs due to buffering. | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /app | ||
|
||
# Create a non-privileged user that the app will run under. | ||
# See https://docs.docker.com/go/dockerfile-user-best-practices/ | ||
ARG UID=10001 | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
appuser | ||
|
||
# Download dependencies as a separate step to take advantage of Docker's caching. | ||
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. | ||
# Leverage a bind mount to requirements.txt to avoid having to copy them into | ||
# into this layer. | ||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
--mount=type=bind,source=poetry.lock,target=poetry.lock \ | ||
--mount=type=bind,source=yt_whisper,target=yt_whisper \ | ||
--mount=type=bind,source=README.md,target=README.md \ | ||
python -m pip install . | ||
|
||
# Switch to the non-privileged user to run the application. | ||
USER appuser | ||
|
||
# Copy the source code into the container. | ||
COPY . . | ||
|
||
# Expose the port that the application listens on. | ||
EXPOSE 8503 | ||
|
||
HEALTHCHECK CMD curl --fail http://localhost:8503/_stcore/health | ||
|
||
ENTRYPOINT ["streamlit", "run", "yt_whisper/app.py", "--server.port=8503", "--server.address=0.0.0.0"] | ||
# Run the application. | ||
CMD streamlit run yt_whisper/app.py --server.port=8503 --server.address=0.0.0.0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,12 @@ authors = ["David Cardozo <[email protected]>"] | |
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.11" | ||
python = ">=3.11,<3.13" | ||
streamlit = "^1.29.0" | ||
python-dotenv = "^1.0.0" | ||
pytube = "^15.0.0" | ||
openai = "^1.7.0" | ||
pinecone-client = "^2.2.4" | ||
pinecone-client = "^3.0.2" | ||
|
||
|
||
[tool.poetry.group.dev.dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/bin/bash | ||
set -euf -o pipefail | ||
docker run -p 8503:8503 --env-file .env demo | ||
declare -r docker_image_name="yt-whisper:demo" | ||
docker build -t ${docker_image_name} . | ||
docker run -it --rm -p 8503:8503 --env-file .env ${docker_image_name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters