-
Notifications
You must be signed in to change notification settings - Fork 3
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 #26 from mfreeman451/25-sqlite-integration
25 sqlite integration
- Loading branch information
Showing
10 changed files
with
884 additions
and
292 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,33 @@ | ||
name: Build HomeMon Packages | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y gcc libc6-dev libsqlite3-dev | ||
- name: Build packages | ||
run: | | ||
./buildAll.sh | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: homemon-packages | ||
path: release-artifacts/*.deb |
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,27 @@ | ||
FROM --platform=linux/amd64 golang:1.23-bullseye | ||
|
||
# Install Node.js and npm | ||
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ | ||
&& apt-get update \ | ||
&& apt-get install -y \ | ||
gcc \ | ||
libc6-dev \ | ||
libsqlite3-dev \ | ||
make \ | ||
nodejs \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Verify installations | ||
RUN node --version && npm --version | ||
|
||
WORKDIR /build | ||
|
||
# Copy go mod files first for better caching | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
# Copy the rest of the source | ||
COPY . . | ||
|
||
# Default command - but we'll override this in build.sh | ||
CMD ["./setup-deb-cloud.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Build the builder image | ||
docker build -t homemon-builder -f Dockerfile.build . | ||
|
||
# Run just the cloud package build in the container | ||
docker run --rm -v $(pwd):/build homemon-builder ./setup-deb-cloud.sh | ||
|
||
echo "Build completed. Check release-artifacts/ directory for the cloud package." |
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,52 @@ | ||
-- Node information | ||
CREATE TABLE IF NOT EXISTS nodes ( | ||
node_id TEXT PRIMARY KEY, | ||
first_seen TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
last_seen TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
is_healthy BOOLEAN NOT NULL DEFAULT 0 | ||
); | ||
|
||
-- Node status history | ||
CREATE TABLE IF NOT EXISTS node_history ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
node_id TEXT NOT NULL, | ||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
is_healthy BOOLEAN NOT NULL DEFAULT 0, | ||
FOREIGN KEY (node_id) REFERENCES nodes(node_id) ON DELETE CASCADE | ||
); | ||
|
||
-- Service status | ||
CREATE TABLE IF NOT EXISTS service_status ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
node_id TEXT NOT NULL, | ||
service_name TEXT NOT NULL, | ||
service_type TEXT NOT NULL, | ||
available BOOLEAN NOT NULL DEFAULT 0, | ||
details TEXT, | ||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
FOREIGN KEY (node_id) REFERENCES nodes(node_id) ON DELETE CASCADE | ||
); | ||
|
||
-- Service history | ||
CREATE TABLE IF NOT EXISTS service_history ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
service_status_id INTEGER NOT NULL, | ||
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
available BOOLEAN NOT NULL DEFAULT 0, | ||
details TEXT, | ||
FOREIGN KEY (service_status_id) REFERENCES service_status(id) ON DELETE CASCADE | ||
); | ||
|
||
-- Indexes for better query performance | ||
CREATE INDEX IF NOT EXISTS idx_node_history_node_time | ||
ON node_history(node_id, timestamp); | ||
CREATE INDEX IF NOT EXISTS idx_service_status_node_time | ||
ON service_status(node_id, timestamp); | ||
CREATE INDEX IF NOT EXISTS idx_service_status_type | ||
ON service_status(service_type); | ||
CREATE INDEX IF NOT EXISTS idx_service_history_status_time | ||
ON service_history(service_status_id, timestamp); | ||
|
||
-- Enable WAL mode for better concurrent access | ||
PRAGMA journal_mode=WAL; | ||
PRAGMA foreign_keys=ON; |
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
Oops, something went wrong.