generated from mozilla-ai/Blueprint-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable build and push of Dockerfile.
- Loading branch information
Showing
4 changed files
with
116 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Create and publish a Docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
attestations: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Generate artifact attestation | ||
uses: actions/attest-build-provenance@v1 | ||
with: | ||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | ||
subject-digest: ${{ steps.push.outputs.digest }} | ||
push-to-registry: true |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM python:3.10-slim | ||
|
||
RUN groupadd --gid 1000 appuser \ | ||
&& useradd --uid 1000 --gid 1000 -ms /bin/bash appuser | ||
|
||
RUN pip3 install --no-cache-dir --upgrade \ | ||
pip \ | ||
virtualenv | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
software-properties-common \ | ||
git | ||
|
||
USER appuser | ||
ENV VIRTUAL_ENV=/home/appuser/venv | ||
|
||
COPY . /home/appuser/document-to-podcast | ||
WORKDIR /home/appuser/document-to-podcast | ||
|
||
RUN virtualenv ${VIRTUAL_ENV} | ||
RUN . ${VIRTUAL_ENV}/bin/activate && pip install -e /home/appuser/document-to-podcast | ||
RUN . ${VIRTUAL_ENV}/bin/activate && python demo/download_models.py | ||
|
||
EXPOSE 8501 | ||
ENTRYPOINT ["./demo/run.sh"] |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from document_to_podcast.inference.model_loaders import ( | ||
load_llama_cpp_model, | ||
load_parler_tts_model_and_tokenizer, | ||
) | ||
|
||
load_llama_cpp_model( | ||
model_id="allenai/OLMoE-1B-7B-0924-Instruct-GGUF/olmoe-1b-7b-0924-instruct-q8_0.gguf" | ||
) | ||
load_parler_tts_model_and_tokenizer("parler-tts/parler-tts-mini-v1") |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
APP_PID= | ||
stopRunningProcess() { | ||
# Based on https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script | ||
if test ! "${APP_PID}" = '' && ps -p ${APP_PID} > /dev/null ; then | ||
> /proc/1/fd/1 echo "Stopping ${COMMAND_PATH} which is running with process ID ${APP_PID}" | ||
|
||
kill -TERM ${APP_PID} | ||
> /proc/1/fd/1 echo "Waiting for ${COMMAND_PATH} to process SIGTERM signal" | ||
|
||
wait ${APP_PID} | ||
> /proc/1/fd/1 echo "All processes have stopped running" | ||
else | ||
> /proc/1/fd/1 echo "${COMMAND_PATH} was not started when the signal was sent or it has already been stopped" | ||
fi | ||
} | ||
|
||
trap stopRunningProcess EXIT TERM | ||
|
||
source ${VIRTUAL_ENV}/bin/activate | ||
|
||
streamlit run ${HOME}/document-to-podcast/demo/app.py & | ||
APP_ID=${!} | ||
|
||
wait ${APP_ID} |