From 720bab457ecebab170a6d462dfa1741a8e93d069 Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Thu, 28 May 2026 17:35:01 +0330 Subject: [PATCH] feat(mirror): add Liara npm/PyPI/Ubuntu APT mirrors to Nexus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds mirrors/nexus/add-liara-mirrors.sh that provisions: - npm-liara-proxy → https://package-mirror.liara.ir/repository/npm/ - npm-group → npm-liara-proxy + npm-proxy (Liara first, Runflare fallback) - pypi-liara-proxy → https://package-mirror.liara.ir/repository/pypi/ - pypi-group → pypi-liara-proxy + pypi-proxy - ubuntu-proxy → http://linux-mirror.liara.ir/repository/ubuntu/ - ubuntu-security-proxy → http://linux-mirror.liara.ir/repository/ubuntu-security/ Also updates CI npm install steps to use npm-group instead of npm-proxy so all four Node.js jobs benefit from the Liara-first, Runflare-fallback group from day one. Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/ci-cd.yml | 8 +- mirrors/nexus/add-liara-mirrors.sh | 153 +++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 mirrors/nexus/add-liara-mirrors.sh diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index 65904cc..a1f687e 100644 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -160,7 +160,7 @@ jobs: - name: Install dependencies working-directory: web/dashboard - run: npm install --legacy-peer-deps --ignore-scripts --registry http://mirror:8081/repository/npm-proxy/ + run: npm install --legacy-peer-deps --ignore-scripts --registry http://mirror:8081/repository/npm-group/ - name: TypeScript check working-directory: web/dashboard @@ -194,7 +194,7 @@ jobs: - name: Install dependencies working-directory: web/admin - run: npm install --legacy-peer-deps --ignore-scripts --registry http://mirror:8081/repository/npm-proxy/ + run: npm install --legacy-peer-deps --ignore-scripts --registry http://mirror:8081/repository/npm-group/ - name: TypeScript check working-directory: web/admin @@ -228,7 +228,7 @@ jobs: - name: Install dependencies working-directory: web/website - run: npm install --legacy-peer-deps --ignore-scripts --registry http://mirror:8081/repository/npm-proxy/ + run: npm install --legacy-peer-deps --ignore-scripts --registry http://mirror:8081/repository/npm-group/ - name: TypeScript check working-directory: web/website @@ -262,7 +262,7 @@ jobs: - name: Install dependencies working-directory: web/finder - run: npm install --legacy-peer-deps --ignore-scripts --registry http://mirror:8081/repository/npm-proxy/ + run: npm install --legacy-peer-deps --ignore-scripts --registry http://mirror:8081/repository/npm-group/ - name: TypeScript check working-directory: web/finder diff --git a/mirrors/nexus/add-liara-mirrors.sh b/mirrors/nexus/add-liara-mirrors.sh new file mode 100644 index 0000000..0a17aa8 --- /dev/null +++ b/mirrors/nexus/add-liara-mirrors.sh @@ -0,0 +1,153 @@ +#!/usr/bin/env bash +# ───────────────────────────────────────────────────────────────────────────── +# Add Liara mirror repos to Nexus and create groups (Liara → Runflare fallback) +# +# New repos: +# npm-liara-proxy → https://package-mirror.liara.ir/repository/npm/ +# npm-group → npm-liara-proxy + npm-proxy (Runflare) +# pypi-liara-proxy → https://package-mirror.liara.ir/repository/pypi/ +# pypi-group → pypi-liara-proxy + pypi-proxy (Runflare) +# ubuntu-proxy → http://linux-mirror.liara.ir/repository/ubuntu/ +# ubuntu-security-proxy → http://linux-mirror.liara.ir/repository/ubuntu-security/ +# +# Usage: +# ./mirrors/nexus/add-liara-mirrors.sh +# NEXUS_ADMIN_PASS=MyPass ./mirrors/nexus/add-liara-mirrors.sh +# UBUNTU_DIST=focal ./mirrors/nexus/add-liara-mirrors.sh # default: jammy +# ───────────────────────────────────────────────────────────────────────────── +set -euo pipefail + +NEXUS_URL="http://localhost:8081" +ADMIN_PASS="${NEXUS_ADMIN_PASS:-Mirror@2024!}" +UBUNTU_DIST="${UBUNTU_DIST:-jammy}" # change to focal/bionic if your Dockerfiles use older Ubuntu +AUTH="-u admin:$ADMIN_PASS" + +ok() { echo "✅ $1"; } +skip() { echo "⚠️ $1 already exists (skipped)"; } +fail() { echo "❌ $1 — HTTP $2"; } + +add_repo() { + local TYPE="$1" JSON="$2" + local NAME + NAME=$(echo "$JSON" | grep -o '"name":"[^"]*"' | head -1 | cut -d'"' -f4) + local HTTP + HTTP=$(curl -s -o /dev/null -w "%{http_code}" $AUTH \ + -X POST "$NEXUS_URL/service/rest/v1/repositories/$TYPE" \ + -H "Content-Type: application/json" -d "$JSON") + case "$HTTP" in + 201) ok "$NAME" ;; + 400) skip "$NAME" ;; + *) fail "$NAME" "$HTTP" ;; + esac +} + +# ── npm ─────────────────────────────────────────────────────────────────────── +echo "" +echo "📦 npm" + +add_repo "npm/proxy" '{ + "name": "npm-liara-proxy", + "online": true, + "storage": {"blobStoreName": "default", "strictContentTypeValidation": false}, + "proxy": { + "remoteUrl": "https://package-mirror.liara.ir/repository/npm/", + "contentMaxAge": 1440, "metadataMaxAge": 1440 + }, + "negativeCache": {"enabled": true, "timeToLive": 1440}, + "httpClient": {"blocked": false, "autoBlock": true} +}' + +add_repo "npm/group" '{ + "name": "npm-group", + "online": true, + "storage": {"blobStoreName": "default", "strictContentTypeValidation": false}, + "group": { + "memberNames": ["npm-liara-proxy", "npm-proxy"] + } +}' + +# ── PyPI ────────────────────────────────────────────────────────────────────── +echo "" +echo "🐍 PyPI" + +add_repo "pypi/proxy" '{ + "name": "pypi-liara-proxy", + "online": true, + "storage": {"blobStoreName": "default", "strictContentTypeValidation": true}, + "proxy": { + "remoteUrl": "https://package-mirror.liara.ir/repository/pypi/", + "contentMaxAge": 1440, "metadataMaxAge": 1440 + }, + "negativeCache": {"enabled": true, "timeToLive": 1440}, + "httpClient": {"blocked": false, "autoBlock": true} +}' + +add_repo "pypi/group" '{ + "name": "pypi-group", + "online": true, + "storage": {"blobStoreName": "default", "strictContentTypeValidation": true}, + "group": { + "memberNames": ["pypi-liara-proxy", "pypi-proxy"] + } +}' + +# ── Ubuntu APT ──────────────────────────────────────────────────────────────── +echo "" +echo "🐧 Ubuntu APT (distribution: $UBUNTU_DIST)" +echo " If your Dockerfiles use a different Ubuntu version, re-run with:" +echo " UBUNTU_DIST=focal $0" +echo "" + +add_repo "apt/proxy" '{ + "name": "ubuntu-proxy", + "online": true, + "storage": {"blobStoreName": "default", "strictContentTypeValidation": false}, + "proxy": { + "remoteUrl": "http://linux-mirror.liara.ir/repository/ubuntu/", + "contentMaxAge": 1440, "metadataMaxAge": 1440 + }, + "negativeCache": {"enabled": true, "timeToLive": 1440}, + "httpClient": { + "blocked": false, "autoBlock": true, + "connection": {"useTrustStore": false} + }, + "apt": {"distribution": "'"$UBUNTU_DIST"'", "flat": false} +}' + +add_repo "apt/proxy" '{ + "name": "ubuntu-security-proxy", + "online": true, + "storage": {"blobStoreName": "default", "strictContentTypeValidation": false}, + "proxy": { + "remoteUrl": "http://linux-mirror.liara.ir/repository/ubuntu-security/", + "contentMaxAge": 1440, "metadataMaxAge": 1440 + }, + "negativeCache": {"enabled": true, "timeToLive": 1440}, + "httpClient": { + "blocked": false, "autoBlock": true, + "connection": {"useTrustStore": false} + }, + "apt": {"distribution": "'"$UBUNTU_DIST"'", "flat": false} +}' + +# ── Done ────────────────────────────────────────────────────────────────────── +echo "" +echo "═══════════════════════════════════════════════════════════════" +echo "🎉 Done!" +echo "═══════════════════════════════════════════════════════════════" +echo "" +echo " npm-group → http://SERVER:8081/repository/npm-group/" +echo " Liara first, Runflare as fallback" +echo "" +echo " pypi-group → http://SERVER:8081/repository/pypi-group/" +echo " Liara first, Runflare as fallback" +echo "" +echo " Ubuntu APT → http://SERVER:8081/repository/ubuntu-proxy/" +echo " distribution: $UBUNTU_DIST" +echo " security: http://SERVER:8081/repository/ubuntu-security-proxy/" +echo "" +echo "To use Ubuntu APT in a Dockerfile:" +echo " RUN echo 'deb http://SERVER:8081/repository/ubuntu-proxy/ $UBUNTU_DIST main restricted universe' > /etc/apt/sources.list && \\" +echo " echo 'deb http://SERVER:8081/repository/ubuntu-security-proxy/ $UBUNTU_DIST-security main restricted universe' >> /etc/apt/sources.list && \\" +echo " apt-get update" +echo ""