-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from ajcwebdev/docker
SQLite and Frontend Persistence
- Loading branch information
Showing
44 changed files
with
991 additions
and
409 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,18 @@ | ||
# .dockerignore | ||
|
||
# Ignore node_modules (should be installed inside the container) | ||
node_modules | ||
|
||
# Ignore content directory (will be mounted as a volume) | ||
content | ||
|
||
# Ignore whisper.cpp directory (not needed for autoshow build) | ||
whisper.cpp | ||
|
||
# Ignore git metadata | ||
.git | ||
.gitignore | ||
|
||
# Ignore logs and temporary files | ||
*.log | ||
tmp/ |
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 |
---|---|---|
@@ -1,30 +1,39 @@ | ||
# .github/whisper.cpp/Dockerfile | ||
# .github/whisper.Dockerfile | ||
|
||
FROM --platform=linux/arm64 ubuntu:22.04 AS build | ||
# Use the Ubuntu 22.04 base image for the build stage | ||
FROM ubuntu:22.04 AS build | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install build dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y build-essential libopenblas-dev pkg-config \ | ||
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* | ||
apt-get install -y build-essential libopenblas-dev pkg-config git wget && \ | ||
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* | ||
|
||
COPY .. . | ||
# Clone the whisper.cpp repository into the container | ||
RUN git clone https://github.com/ggerganov/whisper.cpp.git . | ||
|
||
ENV CFLAGS="-march=armv8-a" | ||
ENV CXXFLAGS="-march=armv8-a" | ||
# Build the whisper.cpp project with OpenBLAS support | ||
RUN make clean && make GGML_OPENBLAS=1 | ||
|
||
RUN make clean | ||
|
||
RUN make GGML_OPENBLAS=1 | ||
|
||
FROM --platform=linux/arm64 ubuntu:22.04 AS runtime | ||
# Use the Ubuntu 22.04 base image for the runtime stage | ||
FROM ubuntu:22.04 AS runtime | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install runtime dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y curl ffmpeg libopenblas-dev \ | ||
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* | ||
apt-get install -y curl ffmpeg libopenblas-dev git wget && \ | ||
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* | ||
|
||
# Copy the built binaries and scripts from the build stage | ||
COPY --from=build /app /app | ||
|
||
# Ensure that the main executable and scripts have execute permissions | ||
RUN chmod +x /app/main && \ | ||
chmod +x /app/models/download-ggml-model.sh | ||
|
||
# Set the entrypoint to bash | ||
ENTRYPOINT [ "bash", "-c" ] |
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,16 @@ | ||
# .github/whisper.dockerignore | ||
|
||
# Ignore models directory (will be mounted as a volume) | ||
models | ||
|
||
# Ignore git metadata | ||
.git | ||
.gitignore | ||
|
||
# Ignore build artifacts | ||
build/ | ||
bin/ | ||
|
||
# Ignore any logs or temporary files | ||
*.log | ||
tmp/ |
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 |
---|---|---|
|
@@ -16,4 +16,5 @@ NEW.md | |
TODO.md | ||
nemo_msdd_configs | ||
temp_outputs | ||
tsconfig.tsbuildinfo | ||
tsconfig.tsbuildinfo | ||
show_notes.db |
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 |
---|---|---|
@@ -1,43 +1,84 @@ | ||
# docker-compose.yml | ||
|
||
services: | ||
# Main application service | ||
autoshow: | ||
# Build configuration for this service | ||
build: | ||
# Use the current directory as build context | ||
context: . | ||
# Use the Dockerfile in the root directory | ||
dockerfile: Dockerfile | ||
# Mount these directories/files from host to container | ||
volumes: | ||
# Share content directory between host and container | ||
- ./content:/usr/src/app/content | ||
# Mount environment variables file | ||
- ./.env:/usr/src/app/.env | ||
# Allow container to interact with Docker daemon | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
# Specify services that must start before this one | ||
depends_on: | ||
# Depends on the whisper service | ||
- whisper | ||
# Depends on the ollama service | ||
- ollama | ||
# Set environment variables for this container | ||
environment: | ||
# Configure Ollama host to point to the ollama service | ||
- OLLAMA_HOST=ollama | ||
# Connect to the autoshownet network | ||
networks: | ||
- autoshownet | ||
|
||
# Speech-to-text service using whisper.cpp | ||
whisper: | ||
# Build configuration for whisper service | ||
build: | ||
# Use whisper.cpp directory as build context | ||
context: ./whisper.cpp | ||
# Use the Dockerfile in the whisper.cpp directory | ||
dockerfile: Dockerfile | ||
# Mount these directories between host and container | ||
volumes: | ||
# Share content directory | ||
- ./content:/app/content | ||
- ./whisper.cpp/models:/app/models | ||
# Use a named volume for models | ||
- whisper-models:/app/models | ||
# Keep container running (placeholder command) | ||
command: tail -f /dev/null | ||
# Allocate a pseudo-TTY | ||
tty: true | ||
# Keep STDIN open | ||
stdin_open: true | ||
# Connect to the autoshownet network | ||
networks: | ||
- autoshownet | ||
|
||
# Large language model service | ||
ollama: | ||
# Use the official Ollama image | ||
image: ollama/ollama | ||
# Mount these volumes | ||
volumes: | ||
- ollama:/root/.ollama | ||
# Use a named volume for models | ||
- ollama-models:/root/.ollama | ||
# Set environment variables | ||
environment: | ||
# Make Ollama accessible on all network interfaces | ||
- OLLAMA_HOST=0.0.0.0 | ||
# Connect to the autoshownet network | ||
networks: | ||
- autoshownet | ||
|
||
# Define networks used by the services | ||
networks: | ||
# Custom network for internal communication | ||
autoshownet: | ||
# Use bridge network driver (standard Docker network type) | ||
driver: bridge | ||
|
||
# Define named volumes used by the services | ||
volumes: | ||
ollama: | ||
ollama-models: | ||
whisper-models: |
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
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,16 @@ | ||
// packages/server/db.ts | ||
|
||
import { DatabaseSync } from 'node:sqlite' | ||
|
||
// Initialize the database connection | ||
export const db = new DatabaseSync('show_notes.db', { open: true }) | ||
|
||
// Create the show_notes table if it doesn't exist | ||
db.exec(` | ||
CREATE TABLE IF NOT EXISTS show_notes ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
title TEXT NOT NULL, | ||
date TEXT NOT NULL, | ||
content TEXT NOT NULL | ||
) | ||
`) |
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,19 @@ | ||
// packages/server/routes/showNote.ts | ||
|
||
import { db } from '../db.js' | ||
|
||
export const getShowNote = async (request, reply) => { | ||
try { | ||
const { id } = request.params | ||
// Fetch the show note from the database | ||
const showNote = db.prepare(`SELECT * FROM show_notes WHERE id = ?`).get(id) | ||
if (showNote) { | ||
reply.send({ showNote }) | ||
} else { | ||
reply.status(404).send({ error: 'Show note not found' }) | ||
} | ||
} catch (error) { | ||
console.error('Error fetching show note:', error) | ||
reply.status(500).send({ error: 'An error occurred while fetching the show note' }) | ||
} | ||
} |
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,14 @@ | ||
// packages/server/routes/showNotes.ts | ||
|
||
import { db } from '../db.js' | ||
|
||
export const getShowNotes = async (request, reply) => { | ||
try { | ||
// Fetch all show notes from the database | ||
const showNotes = db.prepare(`SELECT * FROM show_notes ORDER BY date DESC`).all() | ||
reply.send({ showNotes }) | ||
} catch (error) { | ||
console.error('Error fetching show notes:', error) | ||
reply.status(500).send({ error: 'An error occurred while fetching show notes' }) | ||
} | ||
} |
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
Oops, something went wrong.