diff --git a/.air.toml b/.air.toml index fb007309..18ffccce 100644 --- a/.air.toml +++ b/.air.toml @@ -10,7 +10,8 @@ tmp_dir = "tmp" # Temporary directory for build artifacts if command -v tailwindcss >/dev/null 2>&1; then tailwindcss -i input.css -o assets/tailwind.css elif command -v npx >/dev/null 2>&1; then - npx tailwindcss -i input.css -o assets/tailwind.css + npm install -D daisyui + npx --yes tailwindcss@latest -i input.css -o assets/tailwind.css else echo "Error: Neither 'tailwindcss' binary nor 'npx' found. Please install Tailwind CSS." exit 1 @@ -33,14 +34,14 @@ tmp_dir = "tmp" # Temporary directory for build artifacts delay = 1000 # Delay (in milliseconds) before restarting the app after a change # Directories to exclude from watching - exclude_dir = ["assets", "tmp", "vendor", "testdata", "bin"] + exclude_dir = ["tmp", "vendor", "testdata", "bin"] exclude_file = [] # Files to exclude from watching (none specified) exclude_regex = ["_test.go"] # Exclude test files exclude_unchanged = false # Watch even files that haven't changed follow_symlink = false # Don't follow symlinks full_bin = "" # Additional arguments when running the built binary - include_dir = ["views", "internal"] # Directories to include (watches all if empty) - include_ext = ["go", "tpl", "tmpl", "html", "css"] # File extensions to watch + include_dir = ["views", "internal", "assets"] # Directories to include (watches all if empty) + include_ext = ["go", "tpl", "tmpl", "html", "css", "js"] # File extensions to watch kill_delay = "0s" # Delay before killing the app on a rebuild log = "build-errors.log" # File to log build errors send_interrupt = false # Send interrupt signal before killing the app diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index ac5f5d4b..1e167cee 100755 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -14,6 +14,3 @@ sudo apt-get install -y dialog # Install air to support live reloading of server on code changes go install github.com/air-verse/air@latest - -# Install golangci-lint to allow running of linting locally -curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)/bin" v1.57.2 diff --git a/.gitignore b/.gitignore index 705bc2c9..86830cf7 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ output/soundscape.wav.csv birdnet.db birdnet.txt custom_confidence_list.txt +node_modules diff --git a/Dockerfile b/Dockerfile index c5c72288..f85c09b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG TFLITE_LIB_DIR=/usr/lib -FROM --platform=$BUILDPLATFORM golang:1.22.3-bookworm as buildenv +FROM --platform=$BUILDPLATFORM golang:1.23.2-bookworm AS buildenv # Install zip utility along with other dependencies RUN apt-get update && apt-get install -y \ @@ -8,6 +8,7 @@ RUN apt-get update && apt-get install -y \ git \ sudo \ zip \ + npm \ gcc-aarch64-linux-gnu \ && rm -rf /var/lib/apt/lists/* @@ -33,7 +34,7 @@ ARG TFLITE_LIB_DIR RUN TFLITE_LIB_ARCH=$(echo ${TARGETPLATFORM} | tr '/' '_').tar.gz \ make download-tflite -FROM --platform=$BUILDPLATFORM buildenv as build +FROM --platform=$BUILDPLATFORM buildenv AS build WORKDIR /home/dev-user/src/BirdNET-Go # Compile BirdNET-Go @@ -43,6 +44,10 @@ RUN --mount=type=cache,target=/go/pkg/mod,uid=10001,gid=10001 \ --mount=type=cache,target=/home/dev-user/.cache/go-build,uid=10001,gid=10001 \ make $(echo ${TARGETPLATFORM} | tr '/' '_') +# Download latest versions of Leaflet, htmx, Alpine.js and Tailwind CSS +RUN make download-assets +RUN make generate-tailwindcss + # Create final image using a multi-platform base image FROM debian:bookworm-slim diff --git a/Makefile b/Makefile index 04af10be..530d9a04 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,10 @@ LDFLAGS := -ldflags "-s -w -X 'main.buildDate=$(shell date -u +%Y-%m-%dT%H:%M:%S UNAME_S := $(shell uname -s) UNAME_M := $(shell uname -m) +# Tailwind CSS +TAILWIND_INPUT := input.css +TAILWIND_OUTPUT := assets/tailwind.css + ifeq ($(UNAME_S),Linux) NATIVE_TARGET := linux_$(if $(filter x86_64,$(UNAME_M)),amd64,arm64) TFLITE_LIB_DIR := /usr/lib @@ -69,6 +73,24 @@ download-tflite: echo "TensorFlow Lite C library already exists."; \ fi + +# Download assets +download-assets: + @echo "Downloading latest versions of Leaflet, htmx, Alpine.js, and Tailwind CSS" + @mkdir -p assets + @curl -sL https://unpkg.com/leaflet/dist/leaflet.js -o assets/leaflet.js + @curl -sL https://unpkg.com/leaflet/dist/leaflet.css -o assets/leaflet.css + @curl -sL https://unpkg.com/htmx.org -o assets/htmx.min.js + @curl -sL https://unpkg.com/alpinejs -o assets/alpinejs.min.js + @echo "Assets downloaded successfully" + +# Create Tailwind CSS +generate-tailwindcss: + @echo "Creating Tailwind CSS with DaisyUI" + npm -D install daisyui + npx --yes tailwindcss@latest -i $(TAILWIND_INPUT) -o $(TAILWIND_OUTPUT) --minify + @echo "Tailwind CSS processed successfully" + # labels.zip depends on all files in the labels directory $(LABELS_ZIP): $(LABELS_FILES) @echo "Creating or updating labels.zip from contents of $(LABELS_DIR)/*" diff --git a/go.mod b/go.mod index b961693d..ea86aa45 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tphakala/birdnet-go -go 1.22.3 +go 1.23.2 require ( cgt.name/pkg/go-mwclient v1.3.0