-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a `Dockerfile.local` image to build * Add a build & publish workflow * fix workflow * Add support for local mongoDB * Fix problem with POST requests * use slim image * Set mistral to be the default model in .env * Fix entrypoint * Revert change regarding config folder * replace env variable by build arg for DB and update work * old mention of `conf` folder in readme * env to .env * Revert readme changes * lint
- Loading branch information
Showing
9 changed files
with
191 additions
and
35 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 |
---|---|---|
|
@@ -6,3 +6,5 @@ LICENSE | |
README.md | ||
node_modules/ | ||
.svelte-kit/ | ||
.env* | ||
!.env |
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
File renamed without changes.
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,103 @@ | ||
name: Buid and Publish Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
branches: | ||
- "*" | ||
paths: | ||
- "Dockerfile.local" | ||
- "entrypoint.sh" | ||
workflow_dispatch: | ||
release: | ||
types: [published, edited] | ||
|
||
jobs: | ||
build-and-publish-image-with-db: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ghcr.io/huggingface/chat-ui-db | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and Publish Docker Image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: Dockerfile.local | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: | | ||
- INCLUDE_DB=true | ||
build-and-publish-image-nodb: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ghcr.io/huggingface/chat-ui | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and Publish Docker Image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: Dockerfile.local | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: | | ||
- INCLUDE_DB=false |
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
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,28 @@ | ||
ARG INCLUDE_DB=false | ||
FROM mongo:latest as mongo | ||
|
||
FROM node:20-slim as local_db_false | ||
|
||
FROM node:20-slim as local_db_true | ||
|
||
RUN apt-get update | ||
RUN apt-get install gnupg curl -y | ||
|
||
COPY --from=mongo /usr/bin/mongo* /usr/bin/ | ||
|
||
FROM local_db_${INCLUDE_DB} as final | ||
ARG INCLUDE_DB=false | ||
ENV INCLUDE_DB=${INCLUDE_DB} | ||
|
||
WORKDIR /app | ||
|
||
COPY --link --chown=1000 package-lock.json package.json ./ | ||
RUN --mount=type=cache,target=/app/.npm \ | ||
npm set cache /app/.npm && \ | ||
npm ci | ||
|
||
# copy the rest of the files, run regardless of | ||
COPY --chown=1000 --link . . | ||
RUN chmod +x /app/entrypoint.sh | ||
|
||
CMD ["/bin/bash", "-c", "/app/entrypoint.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
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,23 @@ | ||
if test -z "${DOTENV_LOCAL}" ; then | ||
if ! test -f "/app/.env.local" ; then | ||
echo "DOTENV_LOCAL was not found in the ENV variables and .env.local is not set using a bind volume. We are using the default .env config." | ||
fi; | ||
else | ||
echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file." | ||
cat <<< "$DOTENV_LOCAL" > /app/.env.local | ||
fi; | ||
|
||
if [ "$INCLUDE_DB" = "true" ] ; then | ||
echo "INCLUDE_DB is set to true. Appending MONGODB_URL" | ||
|
||
touch /app/.env.local | ||
echo -e "\nMONGODB_URL=mongodb://localhost:27017" >> /app/.env.local | ||
|
||
mkdir -p /data/db | ||
mongod & | ||
echo "Starting local MongoDB instance" | ||
|
||
fi; | ||
|
||
npm run build | ||
npm run preview -- --host 0.0.0.0 --port 3000 |