Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat(build): ASSETS_URL build arg bakes a CDN asset base into erp/mes

Sidwebworks6fcb87b160f1
diff --git a/Dockerfile b/Dockerfile
index a6470aa96e..4f8b85a5d1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -24,6 +24,11 @@ RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store,sharing=locked \
FROM deps AS build
ARG APP
+# CDN base for client assets, baked into the build (vite base is build-time;
+# apps/*/vite.config.ts normalizes the trailing slash). Empty keeps assets
+# same-origin — the controlled/air-gapped variant is this default, not a flag.
+ARG ASSETS_URL
+ENV ASSETS_URL=${ASSETS_URL}
ARG NODE_OPTIONS="--max-old-space-size=8024"
ENV NODE_OPTIONS=${NODE_OPTIONS}
RUN --mount=type=cache,id=turbo,target=/repo/.turbo,sharing=locked \
diff --git a/apps/erp/vite.config.ts b/apps/erp/vite.config.ts
index 06e75afb2e..c2b7acdba7 100644
--- a/apps/erp/vite.config.ts
+++ b/apps/erp/vite.config.ts
@@ -61,6 +61,14 @@ export default defineConfig(({ command, isSsrBuild, mode }) => {
];
return {
+ // ASSETS_URL bakes a CDN asset base into the client build (Dockerfile
+ // build arg). Vite's base is build-time only, so an image built without
+ // it serves assets same-origin — that IS the controlled/air-gapped
+ // variant, not a fallback. Normalized: Vite requires the trailing slash.
+ base:
+ command === "build" && process.env.ASSETS_URL
+ ? process.env.ASSETS_URL.replace(/\/*$/, "/")
+ : undefined,
build: {
minify: true,
rolldownOptions: {
diff --git a/apps/mes/vite.config.ts b/apps/mes/vite.config.ts
index 7cc7e9192f..3f92211926 100644
--- a/apps/mes/vite.config.ts
+++ b/apps/mes/vite.config.ts
@@ -6,7 +6,7 @@ import path from "node:path";
import { defineConfig, PluginOption } from "vite";
import babelMacros from "vite-plugin-babel-macros";
-export default defineConfig(({ mode, isSsrBuild }) => {
+export default defineConfig(({ command, mode, isSsrBuild }) => {
applyDotenvToProcessEnv(mode, __dirname);
/**
@@ -47,6 +47,14 @@ export default defineConfig(({ mode, isSsrBuild }) => {
];
return {
+ // ASSETS_URL bakes a CDN asset base into the client build (Dockerfile
+ // build arg). Vite's base is build-time only, so an image built without
+ // it serves assets same-origin — that IS the controlled/air-gapped
+ // variant, not a fallback. Normalized: Vite requires the trailing slash.
+ base:
+ command === "build" && process.env.ASSETS_URL
+ ? process.env.ASSETS_URL.replace(/\/*$/, "/")
+ : undefined,
build: {
minify: true,
rolldownOptions: {
diff --git a/turbo.json b/turbo.json
index 4d056623c3..e3769cc660 100644
--- a/turbo.json
+++ b/turbo.json
@@ -3,6 +3,7 @@
"tasks": {
"build": {
"dependsOn": ["^build", "//#lingui:compile", "//#generate:mcp"],
+ "env": ["ASSETS_URL"],
"outputs": [
"dist/**",
"build/**",