build: use vite .env

This commit is contained in:
ZhaiSoul 2025-11-13 05:50:08 +00:00
parent 52e6fbebd2
commit df420783eb
8 changed files with 4 additions and 12 deletions

View File

@ -4,8 +4,6 @@ inputs:
GITHUB_TOKEN: GITHUB_TOKEN:
required: true required: true
outputs: outputs:
short-sha:
value: ${{ steps.create-short-sha.outputs.SHORT_SHA }}
image-name: image-name:
value: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ steps.create-short-sha.outputs.SHORT_SHA }} value: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ steps.create-short-sha.outputs.SHORT_SHA }}
cache-name: cache-name:

View File

@ -37,8 +37,6 @@ jobs:
context: . context: .
file: docker/main/Dockerfile file: docker/main/Dockerfile
push: true push: true
build-args:
GIT_COMMIT_HASH=${{ steps.setup.outputs.short-sha }}
platforms: linux/amd64 platforms: linux/amd64
target: frigate target: frigate
tags: ${{ steps.setup.outputs.image-name }}-amd64 tags: ${{ steps.setup.outputs.image-name }}-amd64
@ -63,8 +61,6 @@ jobs:
context: . context: .
file: docker/main/Dockerfile file: docker/main/Dockerfile
push: true push: true
build-args:
GIT_COMMIT_HASH=${{ steps.setup.outputs.short-sha }}
platforms: linux/arm64 platforms: linux/arm64
target: frigate target: frigate
tags: | tags: |

1
.gitignore vendored
View File

@ -15,6 +15,7 @@ frigate/version.py
web/build web/build
web/node_modules web/node_modules
web/coverage web/coverage
web/.env
core core
!/web/**/*.ts !/web/**/*.ts
.idea/* .idea/*

View File

@ -14,6 +14,7 @@ push-boards: $(BOARDS:%=push-%)
version: version:
echo 'VERSION = "$(VERSION)-$(COMMIT_HASH)"' > frigate/version.py echo 'VERSION = "$(VERSION)-$(COMMIT_HASH)"' > frigate/version.py
echo 'VITE_GIT_COMMIT_HASH=$(COMMIT_HASH)' > web/.env
local: version local: version
docker buildx build --target=frigate --file docker/main/Dockerfile . \ docker buildx build --target=frigate --file docker/main/Dockerfile . \

View File

@ -319,9 +319,6 @@ FROM --platform=$BUILDPLATFORM node:20 AS web-build
WORKDIR /work WORKDIR /work
COPY web/package.json web/package-lock.json ./ COPY web/package.json web/package-lock.json ./
ARG GIT_COMMIT_HASH
ENV GIT_COMMIT_HASH=$GIT_COMMIT_HASH
RUN npm install RUN npm install
COPY web/ ./ COPY web/ ./

1
web/.gitignore vendored
View File

@ -22,3 +22,4 @@ dist-ssr
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
.env

View File

@ -33,7 +33,7 @@ i18n
fallbackLng: "en", // use en if detected lng is not available fallbackLng: "en", // use en if detected lng is not available
backend: { 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: [ ns: [

View File

@ -5,12 +5,10 @@ import react from "@vitejs/plugin-react-swc";
import monacoEditorPlugin from "vite-plugin-monaco-editor"; import monacoEditorPlugin from "vite-plugin-monaco-editor";
const proxyHost = process.env.PROXY_HOST || "localhost:5000"; const proxyHost = process.env.PROXY_HOST || "localhost:5000";
const gitCommitHash = process.env.GIT_COMMIT_HASH || "unknown";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
define: { define: {
"import.meta.vitest": "undefined", "import.meta.vitest": "undefined",
"import.meta.env.GIT_COMMIT_HASH": JSON.stringify(gitCommitHash),
}, },
server: { server: {
proxy: { proxy: {