Use Debian Slim for base images, Fixes to CI actions (#221)

* Use slim variant for Docker, CI fixes

* Config must be added after installation

* Use Python3.9, updates to CI

* Change min required version of Python
This commit is contained in:
Juan Calderon-Perez 2023-04-25 03:21:19 -04:00 committed by GitHub
parent 95ed087435
commit 330c5a8818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 29 deletions

View File

@ -50,7 +50,7 @@ jobs:
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
if: ${{ contains(fromJSON('["nsarrazin","gaby"]'), github.actor) }}
if: ${{ contains(fromJSON('["nsarrazin","gaby"]'), github.event.pull_request.user.login) }}
uses: docker/login-action@v2
with:
registry: ghcr.io
@ -61,7 +61,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
push: ${{ contains(fromJSON('["nsarrazin","gaby"]'), github.actor) }}
push: ${{ contains(fromJSON('["nsarrazin","gaby"]'), github.event.pull_request.user.login) }}
target: release
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@ -6,13 +6,19 @@ on:
jobs:
purge-pr-tagged-image:
name: Delete pr tagged image from ghcr.io
if: ${{ contains(fromJSON('["nsarrazin","gaby"]'), github.actor) == true }}
name: Delete container images from PR's
if: ${{ contains(fromJSON('["nsarrazin","gaby"]'), github.event.pull_request.user.login) }}
continue-on-error: true
runs-on: ubuntu-latest
steps:
- uses: chipkent/action-cleanup-package@v1.0.3
- uses: castlabs/get-package-version-id-action@v2.1
id: version
with:
version: "pr-${{ github.event.pull_request.number }}"
- uses: actions/delete-package-versions@v4
if: ${{ steps.version.outputs.ids != '' }}
with:
package-name: ${{ github.event.repository.name }}
tag: pr-${{ github.event.pull_request.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
min-versions-to-keep: 0
package-version-ids: "${{ steps.version.outputs.ids }}"

View File

@ -16,7 +16,9 @@ jobs:
name: Delete untagged images from ghcr.io
runs-on: ubuntu-latest
steps:
- uses: CerebralXor/action-cleanup-package@v1.0.1
with:
- uses: actions/delete-package-versions@v4
with:
package-name: ${{ github.event.repository.name }}
github-token: ${{ secrets.GH_ACCESS_TOKEN }}
package-type: container
min-versions-to-keep: 10
delete-only-untagged-versions: true

View File

@ -1,31 +1,28 @@
# ---------------------------------------
# Base image for node
FROM node:19 as node_base
FROM node:19-slim as node_base
WORKDIR /usr/src/app
# ---------------------------------------
# Base image for runtime
FROM python:3.11 as base
FROM python:3.9-slim as base
ENV TZ=Etc/UTC
WORKDIR /usr/src/app
# Install Redis
RUN apt-get update && apt-get install -y curl wget gnupg python3-pip cmake lsb-release
RUN apt-get update \
&& apt-get install -y curl wget gnupg cmake lsb-release \
&& curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list \
&& apt-get update \
&& apt-get install -y redis \
&& mkdir -p /etc/redis /var/redis \
&& pip install --upgrade pip
RUN curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list
RUN apt-get update && \
apt-get install -y redis
RUN mkdir -p /etc/redis && mkdir -p /var/redis
COPY ./redis.conf /etc/redis/redis.conf
# clone the python bindings for llama.cpp
RUN pip install --upgrade pip
# Add redis config
COPY ./config/redis.conf /etc/redis/redis.conf
# ---------------------------------------
# Dev environment

View File

@ -6,7 +6,7 @@
A chat interface based on [llama.cpp](https://github.com/ggerganov/llama.cpp) for running Alpaca models. Entirely self-hosted, no API keys needed. Fits on 4GB of RAM and runs on the CPU.
- **SvelteKit** frontend
- **MongoDB** for storing chat history & parameters
- **Redis** for storing chat history & parameters
- **FastAPI + beanie** for the API, wrapping calls to [llama.cpp](https://github.com/ggerganov/llama.cpp)
[demo.webm](https://user-images.githubusercontent.com/25119303/226897188-914a6662-8c26-472c-96bd-f51fc020abf6.webm)

2
api/poetry.lock generated
View File

@ -426,7 +426,7 @@ files = [
[package.extras]
docs = ["furo (>=2023.3.27)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"]
testing = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"]
testing = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.9)", "pytest-timeout (>=2.1)"]
[[package]]
name = "frozenlist"

View File

@ -21,7 +21,7 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.dependencies]
python=">=3.10,<4.0"
python=">=3.9,<4.0"
asyncio = "^3.4.3"
packaging = "^23.1"
pydantic = "^1.10.7"

View File

@ -1,2 +1,2 @@
appendonly yes
appendonly yes
dir /data/db/