Slim the Docker image and clean up after every deploy
Deploy Vault CMS / deploy (push) Successful in 1m15s
Deploy Vault CMS / deploy (push) Successful in 1m15s
- Build Next.js as a standalone server and copy only that into the runtime image, instead of the whole node_modules tree - Mark three dynamic file reads with turbopackIgnore so the standalone trace does not pull in the entire project - Deploy workflow prunes unused images and build cache older than a day at the start and end of every run, including failed ones, and logs disk usage before building Failed builds were leaving their layers behind until the server's disk filled, which broke the deploy, the database and Gitea sign-in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,20 @@ jobs:
|
||||
|
||||
cd /opt/owicms
|
||||
|
||||
docker compose up -d --build
|
||||
# Clean up afterwards whether or not the deploy succeeds; otherwise
|
||||
# every failed build leaves its layers behind until the disk fills.
|
||||
# Build cache used in the last day is kept, so routine deploys stay fast.
|
||||
cleanup() {
|
||||
docker image prune -f || true
|
||||
docker builder prune -af --filter until=24h || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
docker image prune -f
|
||||
# Start from a clean slate too, in case an earlier run was killed.
|
||||
cleanup
|
||||
|
||||
echo "Disk before build:"
|
||||
df -h /opt || true
|
||||
docker system df || true
|
||||
|
||||
docker compose up -d --build
|
||||
Reference in New Issue
Block a user