Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(webv2): read the app version from the Python package at build time

Josh Corbett9ed7e29c1e71
diff --git a/docker/Dockerfile b/docker/Dockerfile
index f04a840b55..6be57bd808 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -7,10 +7,12 @@ ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack use [email protected] && corepack enable
-WORKDIR /build
+# Mirror the repository layout: the webv2 build reads the release version from invokeai/version.
+WORKDIR /build/invokeai/frontend/webv2
COPY invokeai/frontend/webv2/ ./
RUN --mount=type=cache,target=/pnpm/store \
pnpm install --frozen-lockfile
+COPY invokeai/version/invokeai_version.py /build/invokeai/version/
RUN pnpm exec vite build
FROM web-builder AS legacy-web-builder
@@ -100,7 +102,7 @@ ENTRYPOINT ["/opt/invokeai/docker-entrypoint.sh"]
CMD ["invokeai-web"]
# --link requires buldkit w/ dockerfile syntax 1.4, does not work with podman
-COPY --link --from=web-builder /build/dist ${INVOKEAI_SRC}/invokeai/frontend/webv2/dist
+COPY --link --from=web-builder /build/invokeai/frontend/webv2/dist ${INVOKEAI_SRC}/invokeai/frontend/webv2/dist
COPY --link --from=legacy-web-builder /legacy-build/dist ${INVOKEAI_SRC}/invokeai/frontend/webv1/dist
# add sources last to minimize image changes on code changes
diff --git a/docs/src/content/docs/development/Process/release-process.mdx b/docs/src/content/docs/development/Process/release-process.mdx
index 2764f4b101..c6b22730fb 100644
--- a/docs/src/content/docs/development/Process/release-process.mdx
+++ b/docs/src/content/docs/development/Process/release-process.mdx
@@ -21,7 +21,8 @@ The launcher uses GitHub as the source of truth for available releases.
Make a developer call-out for PRs to merge. Merge and test things
out. Create a branch with a name like user/chore/vX.X.X-prep and bump the version by editing
-`invokeai/version/invokeai_version.py` and commit locally.
+`invokeai/version/invokeai_version.py` and commit locally. The web UI reads its version from the same file when it is
+built, so there is no separate frontend version to update.
## Release Workflow
diff --git a/invokeai/frontend/webv2/src/platform/runtime/appMetadata.ts b/invokeai/frontend/webv2/src/platform/runtime/appMetadata.ts
index 9b54abb519..125211580c 100644
--- a/invokeai/frontend/webv2/src/platform/runtime/appMetadata.ts
+++ b/invokeai/frontend/webv2/src/platform/runtime/appMetadata.ts
@@ -1,5 +1,5 @@
/** Build-time application metadata with no domain dependencies. */
-export const APP_VERSION = '7.0';
+export const APP_VERSION = import.meta.env.APP_VERSION;
export const DOCS_URL = 'https://invoke-ai.github.io/InvokeAI-7/';
diff --git a/invokeai/frontend/webv2/src/vite-env.d.ts b/invokeai/frontend/webv2/src/vite-env.d.ts
index feb9fa84f7..3a070d8e82 100644
--- a/invokeai/frontend/webv2/src/vite-env.d.ts
+++ b/invokeai/frontend/webv2/src/vite-env.d.ts
@@ -2,3 +2,8 @@
/** Rewrites canvas pixel goldens instead of comparing them; set by `test:browser:update-goldens`. */
declare const __CANVAS_GOLDEN_UPDATE__: boolean;
+
+interface ImportMetaEnv {
+ /** The release version from `invokeai/version/invokeai_version.py`, injected by `vite.config.mts`. */
+ readonly APP_VERSION: string;
+}
diff --git a/invokeai/frontend/webv2/vite.config.mts b/invokeai/frontend/webv2/vite.config.mts
index 375c819800..9d55e5489b 100644
--- a/invokeai/frontend/webv2/vite.config.mts
+++ b/invokeai/frontend/webv2/vite.config.mts
@@ -1,5 +1,6 @@
import babel from '@rolldown/plugin-babel';
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
+import { readFileSync } from 'node:fs';
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
@@ -17,6 +18,19 @@ const ALLOWED_HOSTS = process.env.INVOKEAI_DEV_HOSTS?.split(',')
.filter(Boolean);
const PROJECT_ROOT = fileURLToPath(new URL('.', import.meta.url));
+// The Python package owns the release version, and the release workflow checks it against the tag. Fail the build
+// rather than ship a guessed version if the file moves or its format changes.
+const VERSION_FILE = fileURLToPath(new URL('../../version/invokeai_version.py', import.meta.url));
+const readAppVersion = (): string => {
+ const version = /^__version__\s*=\s*["']([^"']+)["']/m.exec(readFileSync(VERSION_FILE, 'utf8'))?.[1];
+
+ if (!version) {
+ throw new Error(`No __version__ assignment found in ${VERSION_FILE}.`);
+ }
+
+ return version;
+};
+
// Group eager dependencies shared by both routes to avoid extra chunk requests.
const ROUTE_SHARED_MODULES = [
'/features/fonts/data/keys.ts',
@@ -318,6 +332,8 @@ const getLegacyChunkName = (id: string): string | null => {
export default defineConfig({
define: {
+ // An env define, not a global: Vitest browser mode re-encodes string globals, wrapping them in quotes.
+ 'import.meta.env.APP_VERSION': JSON.stringify(readAppVersion()),
// Use a boolean: Vitest browser mode treats string defines as truthy string literals.
__CANVAS_GOLDEN_UPDATE__: false,
},