diff --git a/apps/suman-bosna/Dockerfile b/apps/suman-bosna/Dockerfile index d35cb32..eaaece3 100644 --- a/apps/suman-bosna/Dockerfile +++ b/apps/suman-bosna/Dockerfile @@ -30,7 +30,7 @@ ENV NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=$NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL ENV NEXT_PUBLIC_DEFAULT_REGION=$NEXT_PUBLIC_DEFAULT_REGION ENV NODE_ENV=production -ENV NODE_OPTIONS="--max-old-space-size=2048" +ENV NODE_OPTIONS="--max-old-space-size=1024" RUN npm run build --workspace=@dtc/suman-bosna diff --git a/apps/suman-bosna/next.config.js b/apps/suman-bosna/next.config.js index 1ec35bf..a0dda59 100644 --- a/apps/suman-bosna/next.config.js +++ b/apps/suman-bosna/next.config.js @@ -13,6 +13,9 @@ const S3_PATHNAME = process.env.MEDUSA_CLOUD_S3_PATHNAME */ const nextConfig = { reactStrictMode: true, + experimental: { + cpus: 1, + }, async headers() { return [ { diff --git a/apps/suman-bosna/package.json b/apps/suman-bosna/package.json index a130448..b75d492 100644 --- a/apps/suman-bosna/package.json +++ b/apps/suman-bosna/package.json @@ -9,7 +9,7 @@ ], "scripts": { "dev": "next dev -p 8000", - "build": "next build", + "build": "next build --webpack", "start": "next start -p 8000", "lint": "eslint .", "analyze": "ANALYZE=true next build" diff --git a/apps/suman-bosna/src/app/sitemap.ts b/apps/suman-bosna/src/app/sitemap.ts index 9d23cce..faade21 100644 --- a/apps/suman-bosna/src/app/sitemap.ts +++ b/apps/suman-bosna/src/app/sitemap.ts @@ -30,43 +30,54 @@ async function listAll(fetchPage: (offset: number) => Promise>) { type Entry = { handle?: string | null; updated_at?: string | Date | null } export default async function sitemap(): Promise { - const query = { fields: "handle,updated_at", limit: PAGE_SIZE } + const origin = await getSiteOrigin() - const [origin, regions, products, categories, collections] = await Promise.all([ - getSiteOrigin(), - listRegions(), - listAll((offset) => - sdk.store.product - .list({ ...query, offset }) - .then((res) => ({ items: res.products, count: res.count })) - ), - listAll((offset) => - sdk.store.category - .list({ ...query, offset }) - .then((res) => ({ items: res.product_categories, count: res.count })) - ), - listAll((offset) => - sdk.store.collection - .list({ ...query, offset }) - .then((res) => ({ items: res.collections, count: res.count })) - ), - ]) + try { + const query = { fields: "handle,updated_at", limit: PAGE_SIZE } - const toEntries = (base: string, prefix: string, items: Entry[]) => - items - .filter((item) => item.handle) - .map((item) => ({ - url: `${base}/${prefix}/${item.handle}`, - lastModified: item.updated_at ? new Date(item.updated_at) : undefined, - })) + const [regions, products, categories, collections] = await Promise.all([ + listRegions(), + listAll((offset) => + sdk.store.product + .list({ ...query, offset }) + .then((res) => ({ items: res.products, count: res.count })) + ), + listAll((offset) => + sdk.store.category + .list({ ...query, offset }) + .then((res) => ({ + items: res.product_categories, + count: res.count, + })) + ), + listAll((offset) => + sdk.store.collection + .list({ ...query, offset }) + .then((res) => ({ items: res.collections, count: res.count })) + ), + ]) - return listCountryCodes(regions).flatMap((countryCode) => { - const base = `${origin}/${countryCode}` - return [ - ...STATIC_PATHS.map((path) => ({ url: `${base}${path}` })), - ...toEntries(base, "products", products), - ...toEntries(base, "categories", categories), - ...toEntries(base, "collections", collections), - ] - }) + const toEntries = (base: string, prefix: string, items: Entry[]) => + items + .filter((item) => item.handle) + .map((item) => ({ + url: `${base}/${prefix}/${item.handle}`, + lastModified: item.updated_at + ? new Date(item.updated_at) + : undefined, + })) + + return listCountryCodes(regions).flatMap((countryCode) => { + const base = `${origin}/${countryCode}` + return [ + ...STATIC_PATHS.map((path) => ({ url: `${base}${path}` })), + ...toEntries(base, "products", products), + ...toEntries(base, "categories", categories), + ...toEntries(base, "collections", collections), + ] + }) + } catch { + // During Docker build the backend is not running — return static paths only + return STATIC_PATHS.map((path) => ({ url: `${origin}${path}` })) + } } diff --git a/apps/suman-hrvatska/Dockerfile b/apps/suman-hrvatska/Dockerfile index ce79ac0..52911ae 100644 --- a/apps/suman-hrvatska/Dockerfile +++ b/apps/suman-hrvatska/Dockerfile @@ -30,7 +30,7 @@ ENV NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=$NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL ENV NEXT_PUBLIC_DEFAULT_REGION=$NEXT_PUBLIC_DEFAULT_REGION ENV NODE_ENV=production -ENV NODE_OPTIONS="--max-old-space-size=2048" +ENV NODE_OPTIONS="--max-old-space-size=1024" RUN npm run build --workspace=@dtc/suman-hrvatska diff --git a/apps/suman-hrvatska/next.config.js b/apps/suman-hrvatska/next.config.js index eb26246..1918252 100644 --- a/apps/suman-hrvatska/next.config.js +++ b/apps/suman-hrvatska/next.config.js @@ -13,6 +13,9 @@ const S3_PATHNAME = process.env.MEDUSA_CLOUD_S3_PATHNAME */ const nextConfig = { reactStrictMode: true, + experimental: { + cpus: 1, + }, async headers() { return [ { diff --git a/apps/suman-hrvatska/package.json b/apps/suman-hrvatska/package.json index 4306eec..817b2bf 100644 --- a/apps/suman-hrvatska/package.json +++ b/apps/suman-hrvatska/package.json @@ -9,7 +9,7 @@ ], "scripts": { "dev": "next dev -p 8002", - "build": "next build", + "build": "next build --webpack", "start": "next start -p 8002", "lint": "eslint .", "analyze": "ANALYZE=true next build" diff --git a/apps/suman-hrvatska/src/app/sitemap.ts b/apps/suman-hrvatska/src/app/sitemap.ts index 9d23cce..faade21 100644 --- a/apps/suman-hrvatska/src/app/sitemap.ts +++ b/apps/suman-hrvatska/src/app/sitemap.ts @@ -30,43 +30,54 @@ async function listAll(fetchPage: (offset: number) => Promise>) { type Entry = { handle?: string | null; updated_at?: string | Date | null } export default async function sitemap(): Promise { - const query = { fields: "handle,updated_at", limit: PAGE_SIZE } + const origin = await getSiteOrigin() - const [origin, regions, products, categories, collections] = await Promise.all([ - getSiteOrigin(), - listRegions(), - listAll((offset) => - sdk.store.product - .list({ ...query, offset }) - .then((res) => ({ items: res.products, count: res.count })) - ), - listAll((offset) => - sdk.store.category - .list({ ...query, offset }) - .then((res) => ({ items: res.product_categories, count: res.count })) - ), - listAll((offset) => - sdk.store.collection - .list({ ...query, offset }) - .then((res) => ({ items: res.collections, count: res.count })) - ), - ]) + try { + const query = { fields: "handle,updated_at", limit: PAGE_SIZE } - const toEntries = (base: string, prefix: string, items: Entry[]) => - items - .filter((item) => item.handle) - .map((item) => ({ - url: `${base}/${prefix}/${item.handle}`, - lastModified: item.updated_at ? new Date(item.updated_at) : undefined, - })) + const [regions, products, categories, collections] = await Promise.all([ + listRegions(), + listAll((offset) => + sdk.store.product + .list({ ...query, offset }) + .then((res) => ({ items: res.products, count: res.count })) + ), + listAll((offset) => + sdk.store.category + .list({ ...query, offset }) + .then((res) => ({ + items: res.product_categories, + count: res.count, + })) + ), + listAll((offset) => + sdk.store.collection + .list({ ...query, offset }) + .then((res) => ({ items: res.collections, count: res.count })) + ), + ]) - return listCountryCodes(regions).flatMap((countryCode) => { - const base = `${origin}/${countryCode}` - return [ - ...STATIC_PATHS.map((path) => ({ url: `${base}${path}` })), - ...toEntries(base, "products", products), - ...toEntries(base, "categories", categories), - ...toEntries(base, "collections", collections), - ] - }) + const toEntries = (base: string, prefix: string, items: Entry[]) => + items + .filter((item) => item.handle) + .map((item) => ({ + url: `${base}/${prefix}/${item.handle}`, + lastModified: item.updated_at + ? new Date(item.updated_at) + : undefined, + })) + + return listCountryCodes(regions).flatMap((countryCode) => { + const base = `${origin}/${countryCode}` + return [ + ...STATIC_PATHS.map((path) => ({ url: `${base}${path}` })), + ...toEntries(base, "products", products), + ...toEntries(base, "categories", categories), + ...toEntries(base, "collections", collections), + ] + }) + } catch { + // During Docker build the backend is not running — return static paths only + return STATIC_PATHS.map((path) => ({ url: `${origin}${path}` })) + } }