From 464dfdf02441af6f57a04d12547644c90c6b33a7 Mon Sep 17 00:00:00 2001 From: Justin Deal Date: Sat, 3 May 2025 15:38:34 -0700 Subject: [PATCH] Fix disk clean up on cicd --- .gitea/workflows/deploy.yml | 31 ++++++++++++++++--- astro.config.ci.mjs | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 astro.config.ci.mjs diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index e27425b..5f3c515 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -26,12 +26,23 @@ jobs: - name: Free up disk space run: | - # Remove unnecessary large packages - sudo apt-get remove -y '^ghc-.*' '^dotnet-.*' '^llvm-.*' '^mono-.*' '^php.*' '^mongodb-.*' '^mysql-.*' - sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox + # Display disk space before cleanup + df -h + + # Remove large packages without using regex + sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox mono-runtime sudo apt-get autoremove -y + # Remove large directories sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache + + # Clean Docker (if installed) + if command -v docker &> /dev/null; then + docker system prune -af + fi + + # Display disk space after cleanup + df -h - name: Install system dependencies run: | @@ -61,7 +72,19 @@ jobs: run: pnpm install - name: Build Astro site - run: pnpm run build + run: | + echo "Attempting to build with Sharp..." + if pnpm run build; then + echo "Build with Sharp successful!" + else + echo "Build with Sharp failed, falling back to passthrough image service..." + # Copy the CI config to use the passthrough image service + cp astro.config.ci.mjs astro.config.mjs + # Clean the previous failed build + rm -rf dist + # Try building again with the passthrough config + pnpm run build + fi - name: Deploy to server run: rsync -avzP ./dist/ root@${{ secrets.SERVER_IP }}:/var/www/html/ diff --git a/astro.config.ci.mjs b/astro.config.ci.mjs new file mode 100644 index 0000000..7fc4289 --- /dev/null +++ b/astro.config.ci.mjs @@ -0,0 +1,60 @@ +// @ts-check +import { defineConfig } from "astro/config"; +import tailwindcss from "@tailwindcss/vite"; + +// https://astro.build/config +export default defineConfig({ + site: 'https://justin.deal', + + // Performance optimizations + compressHTML: true, + + // Build optimizations + build: { + inlineStylesheets: 'auto', // Inline small stylesheets for better performance + }, + + // Image optimizations - using passthrough service for CI/CD + image: { + service: { + entrypoint: 'astro/assets/services/noop', + }, + }, + + // Vite configuration + vite: { + plugins: [tailwindcss()], + + // Build optimizations + build: { + // Enable chunk splitting + cssCodeSplit: true, + + // Optimize chunks + rollupOptions: { + output: { + // Customize chunk naming + manualChunks: { + // Group Alpine.js and related code + alpine: ['alpinejs'], + }, + }, + }, + }, + + // Optimize dependencies + optimizeDeps: { + include: ['alpinejs'], + }, + + // CSS optimization + css: { + devSourcemap: true, + }, + + // Enable server-side rendering optimizations + ssr: { + noExternal: ['@astrojs/tailwind'], + }, + }, +});