From 89c9ed842f068f82663c4711053f7ed877650dde Mon Sep 17 00:00:00 2001 From: xtcnet Date: Tue, 17 Mar 2026 23:24:53 +0700 Subject: [PATCH] fix: support 1GB RAM VPS for Docker image builds - workflow: limit Node.js to 768MB (NODE_OPTIONS --max-old-space-size) and remove GitHub Actions cache (not supported on Forgejo Actions) - install: auto-create 2GB swapfile when installing Forgejo Runner so the build process does not OOM on low-RAM machines Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/docker-publish.yml | 6 ++---- install.sh | 13 +++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index be8ad9b..4fccfe3 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -43,10 +43,10 @@ jobs: uses: actions/setup-node@v4 with: node-version: 20 - cache: 'yarn' - cache-dependency-path: frontend/yarn.lock - name: Install Frontend Dependencies & Build + env: + NODE_OPTIONS: "--max-old-space-size=768" run: | cd frontend yarn install --frozen-lockfile @@ -80,5 +80,3 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64 - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/install.sh b/install.sh index d9de14e..79e2af3 100644 --- a/install.sh +++ b/install.sh @@ -778,6 +778,19 @@ do_forgejo_runner_install() { mkdir -p "$FORGEJO_RUNNER_DIR" + # Ensure swap exists for low-RAM VPS (Docker image builds need ~2GB memory) + if [ ! -f /swapfile ]; then + log_step "Creating 2GB swapfile for build memory..." + fallocate -l 2G /swapfile + chmod 600 /swapfile + mkswap /swapfile > /dev/null + swapon /swapfile + echo '/swapfile none swap sw 0 0' >> /etc/fstab + log_ok "Swapfile created and enabled (persistent across reboots)." + else + log_ok "Swapfile already exists, skipping." + fi + # gitea/act_runner auto-registers on first start via env vars, then starts daemon log_step "Starting Forgejo Runner (auto-register on first boot)..." docker run -d \