From 2969ee9ef502f5d6ceda12c95d7f62edcd891b3f Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 22 Nov 2025 23:05:29 +0300 Subject: [PATCH] deploy --- .forgejo/workflows/deploy.yaml | 26 +++++++++++++++++++++++ tools/deploy/backend-build_app.sh | 2 +- tools/deploy/backend-build_app_webroot.sh | 2 +- tools/deploy/fix-backend-port-conflict.sh | 7 +++--- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index 4b47bf2..2d7b5c2 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -90,6 +90,22 @@ jobs: chmod 600 ~/.ssh/id_rsa ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts + - name: Setup Swap + run: | + SWAP_SIZE=2048 # 2GB + CURRENT_SWAP=$(free -m | awk '/^Swap:/ {print $2}' || echo "0") + + if [ "$CURRENT_SWAP" -lt "$SWAP_SIZE" ]; then + echo "Creating ${SWAP_SIZE}MB swap file..." + dd if=/dev/zero of=/tmp/swapfile bs=1M count=$SWAP_SIZE status=progress + chmod 600 /tmp/swapfile + mkswap /tmp/swapfile + swapon /tmp/swapfile + echo "Swap activated: $(free -m | awk '/^Swap:/ {print $2}')MB" + else + echo "Swap already available: ${CURRENT_SWAP}MB" + fi + - name: Build Web App working-directory: mnemo_cards_web_v2 run: | @@ -98,6 +114,16 @@ jobs: --dart-define=API_BASE_URL=https://api.mnemo-cards.online \ --dart2js-optimization=O4 + - name: Remove Swap + if: always() + run: | + if [ -f /tmp/swapfile ]; then + echo "Removing swap file..." + swapoff /tmp/swapfile 2>/dev/null || true + rm -f /tmp/swapfile + echo "Swap removed" + fi + - name: Deploy Web App run: | rsync -avz --delete mnemo_cards_web_v2/build/web/ \ diff --git a/tools/deploy/backend-build_app.sh b/tools/deploy/backend-build_app.sh index ab4f8ec..3d35504 100644 --- a/tools/deploy/backend-build_app.sh +++ b/tools/deploy/backend-build_app.sh @@ -137,7 +137,7 @@ server { # Proxy to HTTP backend (SSL termination in nginx) location / { - proxy_pass http://localhost:8081; + proxy_pass http://127.0.0.1:8081; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/tools/deploy/backend-build_app_webroot.sh b/tools/deploy/backend-build_app_webroot.sh index 0996af6..f92b476 100755 --- a/tools/deploy/backend-build_app_webroot.sh +++ b/tools/deploy/backend-build_app_webroot.sh @@ -57,7 +57,7 @@ server { # Proxy to HTTP backend (SSL termination in nginx) location / { - proxy_pass http://localhost:8081; + proxy_pass http://127.0.0.1:8081; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/tools/deploy/fix-backend-port-conflict.sh b/tools/deploy/fix-backend-port-conflict.sh index 8163930..3cb98f1 100755 --- a/tools/deploy/fix-backend-port-conflict.sh +++ b/tools/deploy/fix-backend-port-conflict.sh @@ -48,9 +48,10 @@ ssh "$SERVER_USER@$SERVER_IP" << 'ENDSSH' # Backup nginx config cp /etc/nginx/sites-available/api /etc/nginx/sites-available/api.backup.$(date +%Y%m%d_%H%M%S) - # Update proxy_pass to use port 8081 - sed -i 's|proxy_pass https://localhost:8443|proxy_pass https://localhost:8081|g' /etc/nginx/sites-available/api - sed -i 's|proxy_pass http://localhost:8443|proxy_pass http://localhost:8081|g' /etc/nginx/sites-available/api + # Update proxy_pass to use port 8081 and 127.0.0.1 (IPv4) instead of localhost (IPv6) + sed -i 's|proxy_pass https://localhost:8443|proxy_pass http://127.0.0.1:8081|g' /etc/nginx/sites-available/api + sed -i 's|proxy_pass http://localhost:8443|proxy_pass http://127.0.0.1:8081|g' /etc/nginx/sites-available/api + sed -i 's|proxy_pass http://localhost:8081|proxy_pass http://127.0.0.1:8081|g' /etc/nginx/sites-available/api echo "Updated proxy_pass:" grep "proxy_pass" /etc/nginx/sites-available/api | head -3