Merge pull request 'fix: webpack build, low memory limits, and sitemap try/catch for Docker deploy' (#10) from fix/all-deploy-fixes into main
Reviewed-on: #10
This commit is contained in:
@@ -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_BASE_URL=$NEXT_PUBLIC_BASE_URL
|
||||||
ENV NEXT_PUBLIC_DEFAULT_REGION=$NEXT_PUBLIC_DEFAULT_REGION
|
ENV NEXT_PUBLIC_DEFAULT_REGION=$NEXT_PUBLIC_DEFAULT_REGION
|
||||||
ENV NODE_ENV=production
|
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
|
RUN npm run build --workspace=@dtc/suman-bosna
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ const S3_PATHNAME = process.env.MEDUSA_CLOUD_S3_PATHNAME
|
|||||||
*/
|
*/
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
|
experimental: {
|
||||||
|
cpus: 1,
|
||||||
|
},
|
||||||
async headers() {
|
async headers() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 8000",
|
"dev": "next dev -p 8000",
|
||||||
"build": "next build",
|
"build": "next build --webpack",
|
||||||
"start": "next start -p 8000",
|
"start": "next start -p 8000",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"analyze": "ANALYZE=true next build"
|
"analyze": "ANALYZE=true next build"
|
||||||
|
|||||||
@@ -30,10 +30,12 @@ async function listAll<T>(fetchPage: (offset: number) => Promise<Page<T>>) {
|
|||||||
type Entry = { handle?: string | null; updated_at?: string | Date | null }
|
type Entry = { handle?: string | null; updated_at?: string | Date | null }
|
||||||
|
|
||||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||||
|
const origin = await getSiteOrigin()
|
||||||
|
|
||||||
|
try {
|
||||||
const query = { fields: "handle,updated_at", limit: PAGE_SIZE }
|
const query = { fields: "handle,updated_at", limit: PAGE_SIZE }
|
||||||
|
|
||||||
const [origin, regions, products, categories, collections] = await Promise.all([
|
const [regions, products, categories, collections] = await Promise.all([
|
||||||
getSiteOrigin(),
|
|
||||||
listRegions(),
|
listRegions(),
|
||||||
listAll<Entry>((offset) =>
|
listAll<Entry>((offset) =>
|
||||||
sdk.store.product
|
sdk.store.product
|
||||||
@@ -43,7 +45,10 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|||||||
listAll<Entry>((offset) =>
|
listAll<Entry>((offset) =>
|
||||||
sdk.store.category
|
sdk.store.category
|
||||||
.list({ ...query, offset })
|
.list({ ...query, offset })
|
||||||
.then((res) => ({ items: res.product_categories, count: res.count }))
|
.then((res) => ({
|
||||||
|
items: res.product_categories,
|
||||||
|
count: res.count,
|
||||||
|
}))
|
||||||
),
|
),
|
||||||
listAll<Entry>((offset) =>
|
listAll<Entry>((offset) =>
|
||||||
sdk.store.collection
|
sdk.store.collection
|
||||||
@@ -57,7 +62,9 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|||||||
.filter((item) => item.handle)
|
.filter((item) => item.handle)
|
||||||
.map((item) => ({
|
.map((item) => ({
|
||||||
url: `${base}/${prefix}/${item.handle}`,
|
url: `${base}/${prefix}/${item.handle}`,
|
||||||
lastModified: item.updated_at ? new Date(item.updated_at) : undefined,
|
lastModified: item.updated_at
|
||||||
|
? new Date(item.updated_at)
|
||||||
|
: undefined,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return listCountryCodes(regions).flatMap((countryCode) => {
|
return listCountryCodes(regions).flatMap((countryCode) => {
|
||||||
@@ -69,4 +76,8 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|||||||
...toEntries(base, "collections", collections),
|
...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}` }))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_BASE_URL=$NEXT_PUBLIC_BASE_URL
|
||||||
ENV NEXT_PUBLIC_DEFAULT_REGION=$NEXT_PUBLIC_DEFAULT_REGION
|
ENV NEXT_PUBLIC_DEFAULT_REGION=$NEXT_PUBLIC_DEFAULT_REGION
|
||||||
ENV NODE_ENV=production
|
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
|
RUN npm run build --workspace=@dtc/suman-hrvatska
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ const S3_PATHNAME = process.env.MEDUSA_CLOUD_S3_PATHNAME
|
|||||||
*/
|
*/
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
|
experimental: {
|
||||||
|
cpus: 1,
|
||||||
|
},
|
||||||
async headers() {
|
async headers() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 8002",
|
"dev": "next dev -p 8002",
|
||||||
"build": "next build",
|
"build": "next build --webpack",
|
||||||
"start": "next start -p 8002",
|
"start": "next start -p 8002",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"analyze": "ANALYZE=true next build"
|
"analyze": "ANALYZE=true next build"
|
||||||
|
|||||||
@@ -30,10 +30,12 @@ async function listAll<T>(fetchPage: (offset: number) => Promise<Page<T>>) {
|
|||||||
type Entry = { handle?: string | null; updated_at?: string | Date | null }
|
type Entry = { handle?: string | null; updated_at?: string | Date | null }
|
||||||
|
|
||||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||||
|
const origin = await getSiteOrigin()
|
||||||
|
|
||||||
|
try {
|
||||||
const query = { fields: "handle,updated_at", limit: PAGE_SIZE }
|
const query = { fields: "handle,updated_at", limit: PAGE_SIZE }
|
||||||
|
|
||||||
const [origin, regions, products, categories, collections] = await Promise.all([
|
const [regions, products, categories, collections] = await Promise.all([
|
||||||
getSiteOrigin(),
|
|
||||||
listRegions(),
|
listRegions(),
|
||||||
listAll<Entry>((offset) =>
|
listAll<Entry>((offset) =>
|
||||||
sdk.store.product
|
sdk.store.product
|
||||||
@@ -43,7 +45,10 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|||||||
listAll<Entry>((offset) =>
|
listAll<Entry>((offset) =>
|
||||||
sdk.store.category
|
sdk.store.category
|
||||||
.list({ ...query, offset })
|
.list({ ...query, offset })
|
||||||
.then((res) => ({ items: res.product_categories, count: res.count }))
|
.then((res) => ({
|
||||||
|
items: res.product_categories,
|
||||||
|
count: res.count,
|
||||||
|
}))
|
||||||
),
|
),
|
||||||
listAll<Entry>((offset) =>
|
listAll<Entry>((offset) =>
|
||||||
sdk.store.collection
|
sdk.store.collection
|
||||||
@@ -57,7 +62,9 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|||||||
.filter((item) => item.handle)
|
.filter((item) => item.handle)
|
||||||
.map((item) => ({
|
.map((item) => ({
|
||||||
url: `${base}/${prefix}/${item.handle}`,
|
url: `${base}/${prefix}/${item.handle}`,
|
||||||
lastModified: item.updated_at ? new Date(item.updated_at) : undefined,
|
lastModified: item.updated_at
|
||||||
|
? new Date(item.updated_at)
|
||||||
|
: undefined,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return listCountryCodes(regions).flatMap((countryCode) => {
|
return listCountryCodes(regions).flatMap((countryCode) => {
|
||||||
@@ -69,4 +76,8 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|||||||
...toEntries(base, "collections", collections),
|
...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}` }))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user