diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..8fb0045e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,14 @@ +{ + "name": "Go Build Environment", + "dockerFile": "../Dockerfile", + "build": { + "context": "..", + "target": "buildenv" + }, + "runArgs": ["--device=/dev/snd"], + "containerEnv": { + "ALSA_CARD": "0" + }, + "postCreateCommand": "apt-get update && apt-get install -y ca-certificates libasound2 ffmpeg sox && apt-get clean && go install github.com/cosmtrek/air@latest", + "postAttachCommand": "make dev_server" +} diff --git a/Dockerfile b/Dockerfile index 9412b623..913a3514 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Use ARGs to define default build-time variables for TensorFlow version and target platform ARG TENSORFLOW_VERSION=v2.14.0 -FROM golang:1.22.1-bookworm as build +FROM golang:1.22.1-bookworm as buildenv # Pass in ARGs after FROM to use them in build stage ARG TENSORFLOW_VERSION @@ -33,6 +33,8 @@ WORKDIR /root/src # Download TensorFlow headers RUN git clone --branch ${TENSORFLOW_VERSION} --depth 1 https://github.com/tensorflow/tensorflow.git +FROM buildenv as build + # Compile BirdNET-Go COPY . BirdNET-Go RUN --mount=type=cache,target=/go/pkg/mod \ diff --git a/Makefile b/Makefile index 06191458..f886d33a 100644 --- a/Makefile +++ b/Makefile @@ -100,6 +100,9 @@ darwin_arm64: TFLITE_LIB_ARCH=tflite_c_$(TFLITE_VERSION)_darwin_arm64.tar.gz darwin_arm64: $(LABELS_ZIP) check-tools check-tensorflow download-tflite install-tflite build $(CGO_FLAGS) go build $(LDFLAGS) -o $(BINARY_DIR)/$(BINARY_NAME) +dev_server: + $(CGO_FLAGS) air realtime + clean: go clean rm -rf $(BINARY_DIR)/* tflite_c *.tar.gz *.zip