-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
578 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,6 @@ | ||
ragna/_version.py | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class |
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,108 @@ | ||
name: docker | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- ".github/workflows/docker.yml" | ||
- ".dockerignore" | ||
- "Dockerfile" | ||
- "environment-dev.yml" | ||
- "pyproject.toml" | ||
- "ragna-docker.toml" | ||
- "requirements-docker.lock" | ||
push: | ||
branches: | ||
- release/* | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
||
env: | ||
REGISTRY: quay.io | ||
PROJECT: quansight/ragna | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -el {0} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup environment | ||
uses: ./.github/actions/setup-env | ||
with: | ||
optional-dependencies: "false" | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Set up Docker Build Cache | ||
id: cache | ||
run: | | ||
CACHE_DIR="${HOME}/.cache/docker" | ||
mkdir --parents "${CACHE_DIR}" | ||
echo "cache-dir=${CACHE_DIR}" | tee --append $GITHUB_OUTPUT | ||
- name: Restore docker cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.cache.outputs.cache-dir }} | ||
key: docker-${{ hashFiles('Dockerfile','requirements-docker.lock') }} | ||
restore-keys: docker- | ||
|
||
- name: Setup metadata | ||
id: metadata | ||
run: | | ||
IMAGE_NAME="${{ env.REGISTRY }}/${{ env.PROJECT }}" | ||
echo "image-name=${IMAGE_NAME}" | tee --append $GITHUB_OUTPUT | ||
VERSION=$(python -m setuptools_scm) | ||
echo "version=${VERSION}" | tee --append $GITHUB_OUTPUT | ||
TAG=$(echo "${VERSION}" | sed 's/+/-/g') | ||
echo "tag=${TAG}" | tee --append $GITHUB_OUTPUT | ||
TAGGED_IMAGE_NAME="${IMAGE_NAME}:${TAG}" | ||
echo "tagged-image-name=${TAGGED_IMAGE_NAME}" | tee --append $GITHUB_OUTPUT | ||
- name: Login to Quay.io | ||
if: ${{ github.event_name == 'workflow_dispatch' }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} | ||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | ||
|
||
- name: Build and push on workflow dispatch | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
cache-from: type=local,src=${{ steps.cache.outputs.cache-dir }} | ||
cache-to: type=local,dest=${{ steps.cache.outputs.cache-dir }} | ||
tags: ${{ steps.metadata.outputs.tagged-image-name }} | ||
build-args: | | ||
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RAGNA=${{ steps.metadata.outputs.version }} | ||
# Unfortunately, there currently seems to be no way to build a multiplatform | ||
# image and access a single one for the host platform afterwards. Thus, we | ||
# only build a multiplatform image when we also want to push to the registry. | ||
# https://github.com/docker/buildx/issues/166 | ||
# https://github.com/moby/buildkit/issues/1555 | ||
# prettier-ignore | ||
platforms: | ||
${{ github.event_name == 'workflow_dispatch' && 'linux/amd64,linux/arm64' || 'linux/amd64' }} | ||
load: ${{ github.event_name != 'workflow_dispatch' }} | ||
push: ${{ github.event_name == 'workflow_dispatch' }} | ||
|
||
- name: Smoke test | ||
run: docker run ${{ steps.metadata.outputs.tagged-image-name }} --version |
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,30 @@ | ||
FROM python:3.11 | ||
|
||
WORKDIR /opt/ragna | ||
|
||
COPY requirements-docker.lock . | ||
RUN pip install --progress-bar=off --no-deps --no-cache --requirement requirements-docker.lock | ||
|
||
# Pre-download the default embedding model | ||
RUN python -c "from chromadb.utils.embedding_functions import ONNXMiniLM_L6_V2; ONNXMiniLM_L6_V2()._download_model_if_not_exists()" | ||
|
||
COPY ragna ./ragna | ||
COPY pyproject.toml . | ||
# Since we don't copy the .git folder, but still use setuptools-scm as build-backend | ||
# we need to make two manual changes: | ||
# 1. With setuptools-scm all files that are tracked by git are automatically included in | ||
# the built wheel. Since we have corresponding .dockerignore file to our .gitignore, | ||
# the ragna folder only includes files that we are tracking. Thus, we just include | ||
# everything manually. | ||
# 2. We need to pass the version expliclitly as | ||
# --build-arg SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RAGNA=..., | ||
# since setuptools-scm cannot infer the version | ||
RUN echo '[tool.setuptools.package-data]\n"*" = ["*"]' >> pyproject.toml | ||
ARG SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RAGNA | ||
RUN pip install --progress-bar=off --no-deps . | ||
|
||
WORKDIR /var/ragna | ||
COPY ragna-docker.toml ragna.toml | ||
|
||
ENTRYPOINT ["ragna"] | ||
CMD ["ui"] |
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
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,22 @@ | ||
local_cache_root = "/var/ragna" | ||
document = "ragna.core.LocalDocument" | ||
authentication = "ragna.deploy.RagnaDemoAuthentication" | ||
|
||
[components] | ||
source_storages = [ | ||
"ragna.source_storages.Chroma", | ||
"ragna.source_storages.RagnaDemoSourceStorage", | ||
"ragna.source_storages.LanceDB" | ||
] | ||
assistants = [ | ||
"ragna.assistants.RagnaDemoAssistant" | ||
] | ||
|
||
[api] | ||
url = "http://0.0.0.0:31476" | ||
origins = ["http://localhost:31477"] | ||
database_url = "sqlite:////var/ragna/ragna.db" | ||
|
||
[ui] | ||
url = "http://0.0.0.0:31477" | ||
origins = ["http://localhost:31477"] |
Oops, something went wrong.