Skip to content

Commit

Permalink
feat: working on M1 Mac Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
danielclough committed Oct 9, 2024
1 parent 85695c6 commit 3b34ffa
Show file tree
Hide file tree
Showing 16 changed files with 7,859 additions and 1,213 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ endif
cargo install cargo-watch; \
fi

# Install tauri-cli if not available
@if ! command -v tauri-cli &> /dev/null; then \
cargo install tauri-cli --version "^2.0.0-rc"; \
fi


.PHONY: docker
docker:
Expand Down Expand Up @@ -73,9 +78,7 @@ fmt:
@cd frontend && leptosfmt ./**/**/**/**/**/**/**/*.rs

build-all:
@sed -i 's|"targets": \["deb", "app", "dmg"\],|"targets": "all",|' tauri/tauri.conf.json
@export CUDA_COMPUTE_CAP=75 && cargo tauri build
@sed -i 's|"targets": "all",|"targets": \["deb", "app", "dmg"\],|' tauri/tauri.conf.json
@export CUDA_COMPUTE_CAP=75 && cargo tauri build -- --verbose

kill:
@kill -9 $$(ps aux | grep -v "grep" | grep "frontend" | xargs | cut -d ' ' -f 2) 2&1> /dev/null
Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This project is designed for single and multi-user chat with many Large Language
### Features

- Local or Remote Inference Backend
- Local SQLite Database
- Local or Remote SQLite Database


## Setup / Operation
Expand Down Expand Up @@ -53,17 +53,11 @@ role:
If `load_context: true` then you can add (small) in `<Config Directory>/fireside-chat/context/`.
Large files may cause Out Of Memory errors.

### Linux
### Directories

`Config Directory` is `$XDG_CONFIG_HOME` or `$HOME/.config`
`Config Directory` is `$HOME/.config/fireside-chat`

### macOS

`Config Directory` is `$HOME/Library/Application Support`

### Windows

`Config Directory` is `{FOLDERID_RoamingAppData}`
`Config Directory` is `$HOME/.cache/hugging-face`

## Development

Expand All @@ -78,4 +72,4 @@ export FIRESIDE_BACKEND_URL=192.168.1.6 && trunk serve

## Limitations

- I am not testing in Mac or Windows environments, so while everything may work fine I could use some help in order to ensure correctness on those systems.
- I am not testing in Windows environments.
13 changes: 13 additions & 0 deletions docker/Dockerfile.arm64_backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM --platform=${BUILDPLATFORM:-linux/arm64} danielclough/fireside-chat-base as build

ARG CACHEBUST=1

FROM debian:bookworm-slim

COPY --from=build /usr/local/bin/backend /usr/local/bin/backend
COPY --from=build /backend/lib /lib
COPY --from=build /backend/lib64 /lib64

CMD backend

EXPOSE 16981 16981
62 changes: 62 additions & 0 deletions docker/Dockerfile.arm64_base
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM --platform=${BUILDPLATFORM:-linux/arm64} rust:1.76 as build

ARG CACHEBUST=1
ARG FIRESIDE_BACKEND_URL=chat-backend.danielc.us
ARG FIRESIDE_DATABASE_URL=chat-database.danielc.us

WORKDIR /app

RUN apt-get update && \
apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf libssl-dev tar curl make git gcc && \
apt-get clean -y && \
git clone https://github.com/huggingface/candle.git && \
rm -fr candle/.git && \
git clone https://github.com/danielclough/fireside-chat.git && \
rm -fr fireside-chat/.git && \
sed -i 's|, features = \["cuda"\]||g' /app/fireside-chat/backend/Cargo.toml && \
rustup target add wasm32-unknown-unknown && \
echo "frontend" && \
cd /usr/local/cargo/bin/ && \
curl -L https://github.com/trunk-rs/trunk/releases/download/v0.21.0-rc.2/trunk-aarch64-unknown-linux-gnu.tar.gz | tar xvz && \
cd /app/fireside-chat/wasm-server && /usr/local/cargo/bin/cargo build --release && \
cp /app/fireside-chat/target/release/wasm-server /usr/local/bin/ && \
mkdir /wasm-server && \
cd /wasm-server && \
cp --parents /usr/local/bin/wasm-server ./ && \
for i in `ldd /usr/local/bin/wasm-server | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cd /app/fireside-chat/frontend && /usr/local/cargo/bin/trunk build --release && \
cp -r /app/fireside-chat/frontend/dist /wasm-server/assets && \
echo "backend" && \
export FIRESIDE_BACKEND_URL=0.0.0.0 && \
cd /app/fireside-chat/backend && /usr/local/cargo/bin/cargo build --release && \
cp /app/fireside-chat/target/release/backend /usr/local/bin/ && \
mkdir /backend && \
cd /backend && \
cp --parents /usr/local/bin/backend ./ && \
for i in `ldd /usr/local/bin/backend | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
echo "database" && \
export FIRESIDE_DATABASE_URL=0.0.0.0 && \
cd /app/fireside-chat/database && /usr/local/cargo/bin/cargo build --release && \
cp /app/fireside-chat/target/release/database /usr/local/bin/ && \
mkdir /database && \
cd /database && \
cp --parents /usr/local/bin/database ./ && \
for i in `ldd /usr/local/bin/database | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done

FROM debian:bookworm-slim

# Database
COPY --from=build /usr/local/bin/database /usr/local/bin/database
COPY --from=build /database/lib /database/lib
COPY --from=build /database/lib64 /database/lib64

# Backend
COPY --from=build /usr/local/bin/backend /usr/local/bin/backend
COPY --from=build /backend/lib /backend/lib
COPY --from=build /backend/lib64 /backend/lib64

# Frontend
COPY --from=build /usr/local/bin/wasm-server /usr/local/bin/wasm-server
COPY --from=build /wasm-server/lib /wasm-server/lib
COPY --from=build /wasm-server/lib64 /wasm-server/lib64
COPY --from=build /wasm-server/assets /wasm-server/assets
13 changes: 13 additions & 0 deletions docker/Dockerfile.arm64_database
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM --platform=${BUILDPLATFORM:-linux/arm64} danielclough/fireside-chat-base as build

ARG CACHEBUST=1

FROM debian:bookworm-slim

COPY --from=build /usr/local/bin/database /usr/local/bin/database
COPY --from=build /database/lib /lib
COPY --from=build /database/lib64 /lib64

CMD database

EXPOSE 16980 16980
14 changes: 14 additions & 0 deletions docker/Dockerfile.arm64_frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM --platform=${BUILDPLATFORM:-linux/arm64} danielclough/fireside-chat-base as build

ARG CACHEBUST=1

FROM debian:bookworm-slim

COPY --from=build /usr/local/bin/wasm-server /usr/local/bin/wasm-server
COPY --from=build /wasm-server/lib /lib
COPY --from=build /wasm-server/lib64 /lib64
COPY --from=build /wasm-server/assets /assets

CMD wasm-server

EXPOSE 16982 16982
23 changes: 4 additions & 19 deletions docker/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,23 @@ GITHUB_REF=main

# Create a buildkit daemon with the name "multiarch"
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx install
docker buildx create \
--use \
--name=multiarch \
--node=multiarch \
--bootstrap \
--buildkitd-flags '--allow-insecure-entitlement network.host'

# Install QEMU
docker run --rm --privileged \
multiarch/qemu-user-static --reset -p yes

# Run a build for the different platforms
docker buildx build \
podman build \
--build-arg CACHEBUST=`git rev-parse ${GITHUB_REF}` \
--build-arg FIRESIDE_BACKEND_URL="chat-backend.danielc.us" \
--build-arg FIRESIDE_DATABASE_URL="chat-database.danielc.us" \
--push --platform=linux/amd64 \
-t danielclough/fireside-chat-base - \
--network=host < ${BASE_DIR}/Dockerfile.base
docker buildx build \
podman build \
--build-arg CACHEBUST=`git rev-parse ${GITHUB_REF}` \
--push --platform=linux/amd64 \
-t danielclough/fireside-chat-backend - \
--network=host < ${BASE_DIR}/Dockerfile.backend
docker buildx build \
podman build \
--build-arg CACHEBUST=`git rev-parse ${GITHUB_REF}` \
--push --platform=linux/amd64 \
-t danielclough/fireside-chat-frontend - \
--network=host < ${BASE_DIR}/Dockerfile.frontend
docker buildx build \
podman build \
--build-arg CACHEBUST=`git rev-parse ${GITHUB_REF}` \
--push --platform=linux/amd64 \
-t danielclough/fireside-chat-database - \
--network=host < ${BASE_DIR}/Dockerfile.database
4 changes: 2 additions & 2 deletions tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ opt-level = "s"
strip = true

[build-dependencies]
tauri-build = { version = "2.0.0-beta" }
tauri-build = { version = "2.0.0-beta", features = [] }

[dependencies]
tauri = { version = "2.0.0-beta" }
tauri = { version = "2.0.0-beta", features = [] }

backend = {path = "../backend"}
database = {path = "../database"}
Expand Down
24 changes: 0 additions & 24 deletions tauri/capabilities/migrated.json

This file was deleted.

2 changes: 1 addition & 1 deletion tauri/gen/schemas/acl-manifests.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tauri/gen/schemas/capabilities.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default",{"identifier":"fs:scope","allow":["$APPDATA/fireside-chat/*"]},"shell:allow-open"]}}
{}
Loading

0 comments on commit 3b34ffa

Please sign in to comment.