Skip to content

Commit 7e06d48

Browse files
authored
Merge pull request #1009 from datum-cloud/fix-prebuild-cache
Fix: prebuild cache and include .cache to image
2 parents 34b6b12 + 4bbd4cf commit 7e06d48

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ COPY package*.json ./
77

88
FROM base AS build
99
ENV NODE_ENV=production
10+
ENV STRAPI_CACHE_ENABLED=true
1011
COPY ./.kube/config.yaml ./.kube/config.yaml
1112
RUN --mount=type=cache,target=/root/.npm npm install --ignore-scripts
1213
COPY . .
1314
RUN chmod -R 755 src/pages
15+
# Warmup: .cache in layer, so production gets it at runtime
16+
RUN npm run build:cache
17+
# Build: cache mount speeds up rebuilds; .cache from layer above persists after unmount
1418
RUN --mount=type=cache,target=/app/.cache npm run build
1519

1620
FROM base AS development
@@ -29,6 +33,7 @@ COPY --from=build /app/server.mjs ./server.mjs
2933
COPY --from=build /app/package*.json ./
3034
RUN --mount=type=cache,target=/root/.npm npm install --omit=dev --ignore-scripts
3135
COPY --from=build /app/src/pages ./src/pages
36+
COPY --from=build /app/.cache ./.cache
3237
RUN chmod -R 755 src/pages
3338

3439
ENV HOST=0.0.0.0

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dev:astro": "astro dev --host --typecheck",
1111
"build:astro": "astro check --skip-playwright && astro build",
1212
"dev": "npm run build:pagefind && npm run copy:pagefind && npm run dev:astro",
13-
"build": "npm run build:cache && npm run build:astro && npm run build:pagefind",
13+
"build": "npm run build:astro && npm run build:pagefind",
1414
"build:cache": "tsx scripts/warmup-cache.ts",
1515
"start": "node ./server.mjs",
1616
"start:original": "node ./dist/server/entry.mjs",

0 commit comments

Comments
 (0)