From e4bacc2e7113dfeee81b1eeb3e8b12aa3b2a58e7 Mon Sep 17 00:00:00 2001 From: ZhaiSoul <842607283@qq.com> Date: Tue, 11 Nov 2025 08:34:06 +0000 Subject: [PATCH 1/6] chore: i18n use cache key --- docker/main/Dockerfile | 6 +++++- web/src/utils/i18n.ts | 2 +- web/vite.config.ts | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index 8dbf5ff86..744d5d92c 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -189,7 +189,7 @@ RUN /build_pysqlite3.sh COPY docker/main/requirements-wheels.txt /requirements-wheels.txt RUN pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt && \ if [ "$DEBUG" = "true" ]; then \ - pip3 wheel --wheel-dir=/wheels -r /requirements-dev.txt; \ + pip3 wheel --wheel-dir=/wheels -r /requirements-dev.txt; \ fi # Install HailoRT & Wheels @@ -318,6 +318,10 @@ FROM --platform=$BUILDPLATFORM node:20 AS web-build WORKDIR /work COPY web/package.json web/package-lock.json ./ + +ARG GIT_COMMIT_HASH +ENV GIT_COMMIT_HASH=$GIT_COMMIT_HASH + RUN npm install COPY web/ ./ diff --git a/web/src/utils/i18n.ts b/web/src/utils/i18n.ts index 1a386ccb3..d48e37d83 100644 --- a/web/src/utils/i18n.ts +++ b/web/src/utils/i18n.ts @@ -33,7 +33,7 @@ i18n fallbackLng: "en", // use en if detected lng is not available backend: { - loadPath: "locales/{{lng}}/{{ns}}.json", + loadPath: `locales/{{lng}}/{{ns}}.json?v=${import.meta.env.GIT_COMMIT_HASH || "unknown"}`, }, ns: [ diff --git a/web/vite.config.ts b/web/vite.config.ts index cb1a580bf..082b7a159 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -5,11 +5,12 @@ import react from "@vitejs/plugin-react-swc"; import monacoEditorPlugin from "vite-plugin-monaco-editor"; const proxyHost = process.env.PROXY_HOST || "localhost:5000"; - +const gitCommitHash = process.env.GIT_COMMIT_HASH || "unknown"; // https://vitejs.dev/config/ export default defineConfig({ define: { "import.meta.vitest": "undefined", + "import.meta.env.GIT_COMMIT_HASH": JSON.stringify(gitCommitHash), }, server: { proxy: { From 332487d7113155e004ccbaf9b75f1c50ae15d322 Mon Sep 17 00:00:00 2001 From: GuoQing Liu <842607283@qq.com> Date: Wed, 12 Nov 2025 13:16:40 +0800 Subject: [PATCH 2/6] Fix indentation in Dockerfile for pip command --- docker/main/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index 744d5d92c..f1a3ee4a1 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -189,7 +189,7 @@ RUN /build_pysqlite3.sh COPY docker/main/requirements-wheels.txt /requirements-wheels.txt RUN pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt && \ if [ "$DEBUG" = "true" ]; then \ - pip3 wheel --wheel-dir=/wheels -r /requirements-dev.txt; \ + pip3 wheel --wheel-dir=/wheels -r /requirements-dev.txt; \ fi # Install HailoRT & Wheels From 230a397d0f764c5f648c8b3c7a4fba94fb4b2de5 Mon Sep 17 00:00:00 2001 From: GuoQing Liu <842607283@qq.com> Date: Wed, 12 Nov 2025 23:46:49 +0800 Subject: [PATCH 3/6] Add build argument for GIT_COMMIT_HASH in CI workflow --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcf3070b5..c8b2beb32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,7 @@ jobs: context: . file: docker/main/Dockerfile push: true + build-args: GIT_COMMIT_HASH=${GITHUB_SHA::7} platforms: linux/amd64 target: frigate tags: ${{ steps.setup.outputs.image-name }}-amd64 @@ -61,6 +62,7 @@ jobs: context: . file: docker/main/Dockerfile push: true + build-args: GIT_COMMIT_HASH=${GITHUB_SHA::7} platforms: linux/arm64 target: frigate tags: | From 78c3108d94db71a1037e3df49eb41943bc871f31 Mon Sep 17 00:00:00 2001 From: GuoQing Liu <842607283@qq.com> Date: Thu, 13 Nov 2025 00:06:28 +0800 Subject: [PATCH 4/6] Add short-sha output to action.yml --- .github/actions/setup/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 724af45a5..befe4f57a 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -4,6 +4,8 @@ inputs: GITHUB_TOKEN: required: true outputs: + short-sha: + value: ${{ steps.create-short-sha.outputs.SHORT_SHA }} image-name: value: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ steps.create-short-sha.outputs.SHORT_SHA }} cache-name: From 52e6fbebd29a8efa15b9683da0db845ad1567860 Mon Sep 17 00:00:00 2001 From: GuoQing Liu <842607283@qq.com> Date: Thu, 13 Nov 2025 00:07:49 +0800 Subject: [PATCH 5/6] Update build args to use short SHA output --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8b2beb32..f98939d33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,8 @@ jobs: context: . file: docker/main/Dockerfile push: true - build-args: GIT_COMMIT_HASH=${GITHUB_SHA::7} + build-args: + GIT_COMMIT_HASH=${{ steps.setup.outputs.short-sha }} platforms: linux/amd64 target: frigate tags: ${{ steps.setup.outputs.image-name }}-amd64 @@ -62,7 +63,8 @@ jobs: context: . file: docker/main/Dockerfile push: true - build-args: GIT_COMMIT_HASH=${GITHUB_SHA::7} + build-args: + GIT_COMMIT_HASH=${{ steps.setup.outputs.short-sha }} platforms: linux/arm64 target: frigate tags: | From df420783ebc1bdd809737a7bd2c6aa6fb2e35d5c Mon Sep 17 00:00:00 2001 From: ZhaiSoul <842607283@qq.com> Date: Thu, 13 Nov 2025 05:50:08 +0000 Subject: [PATCH 6/6] build: use vite .env --- .github/actions/setup/action.yml | 2 -- .github/workflows/ci.yml | 4 ---- .gitignore | 1 + Makefile | 1 + docker/main/Dockerfile | 3 --- web/.gitignore | 1 + web/src/utils/i18n.ts | 2 +- web/vite.config.ts | 2 -- 8 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index befe4f57a..724af45a5 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -4,8 +4,6 @@ inputs: GITHUB_TOKEN: required: true outputs: - short-sha: - value: ${{ steps.create-short-sha.outputs.SHORT_SHA }} image-name: value: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ steps.create-short-sha.outputs.SHORT_SHA }} cache-name: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f98939d33..dcf3070b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,8 +37,6 @@ jobs: context: . file: docker/main/Dockerfile push: true - build-args: - GIT_COMMIT_HASH=${{ steps.setup.outputs.short-sha }} platforms: linux/amd64 target: frigate tags: ${{ steps.setup.outputs.image-name }}-amd64 @@ -63,8 +61,6 @@ jobs: context: . file: docker/main/Dockerfile push: true - build-args: - GIT_COMMIT_HASH=${{ steps.setup.outputs.short-sha }} platforms: linux/arm64 target: frigate tags: | diff --git a/.gitignore b/.gitignore index 8456d9be0..660a378b0 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ frigate/version.py web/build web/node_modules web/coverage +web/.env core !/web/**/*.ts .idea/* diff --git a/Makefile b/Makefile index 2baac5aad..d1427b6df 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ push-boards: $(BOARDS:%=push-%) version: echo 'VERSION = "$(VERSION)-$(COMMIT_HASH)"' > frigate/version.py + echo 'VITE_GIT_COMMIT_HASH=$(COMMIT_HASH)' > web/.env local: version docker buildx build --target=frigate --file docker/main/Dockerfile . \ diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index f1a3ee4a1..7cd9c22e1 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -319,9 +319,6 @@ FROM --platform=$BUILDPLATFORM node:20 AS web-build WORKDIR /work COPY web/package.json web/package-lock.json ./ -ARG GIT_COMMIT_HASH -ENV GIT_COMMIT_HASH=$GIT_COMMIT_HASH - RUN npm install COPY web/ ./ diff --git a/web/.gitignore b/web/.gitignore index a547bf36d..1cac5597e 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -22,3 +22,4 @@ dist-ssr *.njsproj *.sln *.sw? +.env \ No newline at end of file diff --git a/web/src/utils/i18n.ts b/web/src/utils/i18n.ts index d48e37d83..eba5ff7a5 100644 --- a/web/src/utils/i18n.ts +++ b/web/src/utils/i18n.ts @@ -33,7 +33,7 @@ i18n fallbackLng: "en", // use en if detected lng is not available backend: { - loadPath: `locales/{{lng}}/{{ns}}.json?v=${import.meta.env.GIT_COMMIT_HASH || "unknown"}`, + loadPath: `locales/{{lng}}/{{ns}}.json?v=${import.meta.env.VITE_GIT_COMMIT_HASH || "unknown"}`, }, ns: [ diff --git a/web/vite.config.ts b/web/vite.config.ts index 082b7a159..b3a14b4a7 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -5,12 +5,10 @@ import react from "@vitejs/plugin-react-swc"; import monacoEditorPlugin from "vite-plugin-monaco-editor"; const proxyHost = process.env.PROXY_HOST || "localhost:5000"; -const gitCommitHash = process.env.GIT_COMMIT_HASH || "unknown"; // https://vitejs.dev/config/ export default defineConfig({ define: { "import.meta.vitest": "undefined", - "import.meta.env.GIT_COMMIT_HASH": JSON.stringify(gitCommitHash), }, server: { proxy: {