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.

build: only use the vercelPresets in the vercel environment

Brad Barbin24a537b92e15
diff --git a/.gitignore b/.gitignore
index f4b054f99a..89f0e99aab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ node_modules
.next
.vercel
.trigger
+.sst
dist
dist-ssr
*.local
@@ -19,8 +20,10 @@ scripts/paperless-test.ts
# local env files
.env
.env.local
+.env.dev
.env.development.local
.env.test.local
+.env.prod
.env.production
.env.production.local
!packages/apps/**/.env
diff --git a/apps/erp/Dockerfile b/apps/erp/Dockerfile
index 207bf937e3..e6e34bfaf3 100644
--- a/apps/erp/Dockerfile
+++ b/apps/erp/Dockerfile
@@ -1,22 +1,24 @@
-FROM node:20-alpine AS development-dependencies-env
-COPY . /app
-WORKDIR /app
-RUN npm ci
+FROM node:20-alpine AS deps
+WORKDIR /repo
+# Copy root manifests for workspaces
+COPY package.json package-lock.json turbo.json ./
+# Copy only what we need to install and build
+COPY apps ./apps
+COPY packages ./packages
+# Install all workspaces (dev deps are needed to build)
+RUN npm ci --workspaces
-FROM node:20-alpine AS production-dependencies-env
-COPY ./package.json package-lock.json /app/
-WORKDIR /app
-RUN npm ci --omit=dev
-
-FROM node:20-alpine AS build-env
-COPY . /app/
-COPY --from=development-dependencies-env /app/node_modules /app/node_modules
-WORKDIR /app
-RUN npm run build
+FROM deps AS build
+# Build only ERP and its deps
+RUN npx [email protected] run build --filter=./apps/erp
FROM node:20-alpine
-COPY ./package.json package-lock.json /app/
-COPY --from=production-dependencies-env /app/node_modules /app/node_modules
-COPY --from=build-env /app/build /app/build
-WORKDIR /app
-CMD ["npm", "run", "start"]
\ No newline at end of file
+WORKDIR /repo
+ENV NODE_ENV=production
+ENV PORT=3000
+# Production needs only built app + node_modules
+COPY --from=deps /repo/node_modules ./node_modules
+COPY --from=build /repo/apps/erp ./apps/erp
+EXPOSE 3000
+WORKDIR /repo/apps/erp
+CMD ["npm","run","start"]
\ No newline at end of file
diff --git a/apps/erp/vite.config.ts b/apps/erp/vite.config.ts
index 65a2eb5a51..490fd9ad5f 100644
--- a/apps/erp/vite.config.ts
+++ b/apps/erp/vite.config.ts
@@ -37,7 +37,7 @@ export default defineConfig({
},
plugins: [
remix({
- presets: [vercelPreset()],
+ presets: process.env.VERCEL === "1" ? [vercelPreset()] : [],
future: {
unstable_singleFetch: false,
unstable_lazyRouteDiscovery: false,
diff --git a/apps/mes/Dockerfile b/apps/mes/Dockerfile
new file mode 100644
index 0000000000..f3b0867931
--- /dev/null
+++ b/apps/mes/Dockerfile
@@ -0,0 +1,24 @@
+FROM node:20-alpine AS deps
+WORKDIR /repo
+# Copy root manifests for workspaces
+COPY package.json package-lock.json turbo.json ./
+# Copy only what we need to install and build
+COPY apps ./apps
+COPY packages ./packages
+# Install all workspaces (dev deps are needed to build)
+RUN npm ci --workspaces
+
+FROM deps AS build
+# Build only ERP and its deps
+RUN npx [email protected] run build --filter=./apps/mes
+
+FROM node:20-alpine
+WORKDIR /repo
+ENV NODE_ENV=production
+ENV PORT=3000
+# Production needs only built app + node_modules
+COPY --from=deps /repo/node_modules ./node_modules
+COPY --from=build /repo/apps/mes ./apps/mes
+EXPOSE 3001
+WORKDIR /repo/apps/mes
+CMD ["npm","run","start"]
\ No newline at end of file
diff --git a/apps/mes/vite.config.ts b/apps/mes/vite.config.ts
index ad371e1985..993e20015d 100644
--- a/apps/mes/vite.config.ts
+++ b/apps/mes/vite.config.ts
@@ -35,7 +35,7 @@ export default defineConfig({
},
plugins: [
remix({
- presets: [vercelPreset()],
+ presets: process.env.VERCEL === "1" ? [vercelPreset()] : [],
future: {
unstable_singleFetch: false,
},