Skip to content

Commit 21e5738

Browse files
committed
fix(webapp): guard asset carry-forward retention and prefer latest as semver fallback
The 14-day prune depends on the builder preserving mtimes through COPY. Assert the outcome instead of the mechanism: fail the image build if public/build exceeds 1GB, so silent retention failure becomes a loud CI error. Also try :latest before :main when resolving the previous image, so semver releases carry forward their true predecessor's assets.
1 parent 1ef1aae commit 21e5738

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/publish-webapp.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ jobs:
117117
id: prev_image
118118
# Previous image whose /build assets the Dockerfile carries forward.
119119
# Prefer the tag being published (mutable tags still point at the
120-
# previous build here), fall back to `main`; if neither exists the
121-
# Dockerfile default makes the carry-forward a no-op.
120+
# previous build here); for fresh immutable/semver tags fall back to
121+
# `latest` (the previous release — its users hold the stale HTML),
122+
# then `main`. If nothing exists the Dockerfile default makes the
123+
# carry-forward a no-op.
122124
run: |
123-
for candidate in "${IMAGE_REPO}:${TAG}" "${IMAGE_REPO}:main"; do
125+
for candidate in "${IMAGE_REPO}:${TAG}" "${IMAGE_REPO}:latest" "${IMAGE_REPO}:main"; do
124126
if docker manifest inspect "$candidate" >/dev/null 2>&1; then
125127
echo "prev_image=${candidate}" >> "$GITHUB_OUTPUT"
126128
echo "Using previous image: ${candidate}"

docker/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ COPY --from=prev-assets --chown=node:node /triggerdotdev/apps/webapp/public/buil
101101
RUN find ./apps/webapp/public/build -type f -mtime +14 -delete \
102102
&& find ./apps/webapp/public/build -type d -empty -delete
103103
COPY --from=builder --chown=node:node /triggerdotdev/apps/webapp/public ./apps/webapp/public
104+
# Guard against silent retention failure (e.g. a builder that stops
105+
# preserving mtimes, making the prune a no-op): fail the build loudly if the
106+
# carried-forward window grows past a size no healthy 14-day window can reach.
107+
RUN size_mb=$(du -sm ./apps/webapp/public/build | cut -f1) \
108+
&& if [ "$size_mb" -gt 1024 ]; then \
109+
echo "public/build is ${size_mb}MB (>1024MB): asset carry-forward is not being pruned" >&2; \
110+
exit 1; \
111+
fi
104112
COPY --from=builder --chown=node:node /triggerdotdev/scripts ./scripts
105113

106114
# Goose and schemas

0 commit comments

Comments
 (0)