From ed28c99fc8247e4120f246c98a27b877257ab1de Mon Sep 17 00:00:00 2001 From: Hampus Carlsson Date: Sat, 2 Mar 2024 18:32:57 +0100 Subject: [PATCH 1/4] Fix spelling error in Dockerfile --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8b5a6623..fc215fd6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,18 @@ FROM golang:1.22.0-bookworm as build -ARG TESNSORFLOW_VERSION=v2.14.0 +ARG TENSORFLOW_VERSION=v2.14.0 ARG PLATFORM=linux_amd64 # Download and configure precompiled TensorFlow Lite C library RUN curl -L \ - https://github.com/tphakala/tflite_c/releases/download/${TESNSORFLOW_VERSION}/tflite_c_${TESNSORFLOW_VERSION}_${PLATFORM}.tar.gz | \ + https://github.com/tphakala/tflite_c/releases/download/${TENSORFLOW_VERSION}/tflite_c_${TENSORFLOW_VERSION}_${PLATFORM}.tar.gz | \ tar -C "/usr/local/lib" -xz \ && ldconfig WORKDIR /root/src # Download TensorFlow headers -RUN git clone --branch ${TESNSORFLOW_VERSION} --depth 1 https://github.com/tensorflow/tensorflow.git +RUN git clone --branch ${TENSORFLOW_VERSION} --depth 1 https://github.com/tensorflow/tensorflow.git # Compile BirdNET-GO COPY . BirdNET-Go From a2e8617ebc4d75108d718bd98fd5557c7e22c27b Mon Sep 17 00:00:00 2001 From: Hampus Carlsson Date: Sat, 2 Mar 2024 18:54:46 +0100 Subject: [PATCH 2/4] Add .git to .dockerignore Speeds up the copy process since the git history is not of interest while building the image. --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index ce70d54f..913020ff 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ Dockerfile .dockerignore .gitignore +.git From afb63b042910f67aaad6f5acec4b1366125ff05e Mon Sep 17 00:00:00 2001 From: Hampus Carlsson Date: Sat, 2 Mar 2024 22:56:12 +0100 Subject: [PATCH 3/4] Ignore .github in .dockerignore --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 913020ff..651028c1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,4 @@ Dockerfile .dockerignore .gitignore .git +.github From 937e0988344b830d2fc1479859bf7a226ffd3df9 Mon Sep 17 00:00:00 2001 From: Hampus Carlsson Date: Sat, 2 Mar 2024 19:12:39 +0100 Subject: [PATCH 4/4] Add basic docker building github action The workflow job will for every new commit to the main branch, build and push a docker image to the latest tag. The latest tag will get overwritten each commmit. --- .github/workflows/docker-build.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..b984315d --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,30 @@ +name: Deploy Image to GHCR + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + push-docker-image: + runs-on: ubuntu-latest + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@v4.1.1 + + - name: 'Login to GitHub Container Registry' + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + + - name: 'Generate downcase repository name' + run: | + echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + + - name: 'Build Inventory Image' + run: | + docker build . --tag ghcr.io/${REPO}:latest + docker push ghcr.io/${REPO}:latest