From b0094e46583141c7e56810f83cfbd897496ccaa5 Mon Sep 17 00:00:00 2001 From: Denis Shatskiy Date: Fri, 8 Aug 2025 08:18:32 +0700 Subject: [PATCH] feat: Update Docker configuration and enhance AutoUrlManager with copy functionality for example format --- .dockerignore | 84 +++++++----------------- .gitea/workflows/docker-publish-fast.yml | 13 ++-- Dockerfile.fast | 27 ++++---- frontend/src/AutoUrlManager.jsx | 84 ++++++++++++++++++++---- 4 files changed, 117 insertions(+), 91 deletions(-) diff --git a/.dockerignore b/.dockerignore index e277b99..8f3a68e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,69 +1,35 @@ -# Dependencies -node_modules -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Production builds -frontend/dist -frontend/build - -# Environment files -.env -.env.local -.env.development.local -.env.test.local -.env.production.local - -# IDE files -.vscode -.idea -*.swp -*.swo - -# OS files -.DS_Store -Thumbs.db - -# Git +# VCS .git +.gitattributes .gitignore -# Documentation -README.md -CHANGELOG.md -DOCKER.md +# CI config (excluded from build context) +.gitea/ -# CI/CD -.gitea +# Node modules +node_modules/ +frontend/node_modules/ +backend/node_modules/ + +# IDE/OS +.vscode/ +.idea/ +.DS_Store # Logs -logs *.log -# Runtime data -pids -*.pid -*.seed -*.pid.lock +# Frontend build output +frontend/dist/ -# Coverage directory used by tools like istanbul -coverage +# Large example data not needed for image build +example/ +example-servers*.json -# nyc test coverage -.nyc_output - -# Dependency directories -jspm_packages/ - -# Optional npm cache directory -.npm - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity \ No newline at end of file +# Misc docs +Dockerfile* +README.md +CHANGELOG.md +CI_TROUBLESHOOTING.md +DOCKER.md +SHX_NETWORK.md \ No newline at end of file diff --git a/.gitea/workflows/docker-publish-fast.yml b/.gitea/workflows/docker-publish-fast.yml index 286bb92..3389c34 100644 --- a/.gitea/workflows/docker-publish-fast.yml +++ b/.gitea/workflows/docker-publish-fast.yml @@ -12,12 +12,14 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver-opts: | - image=moby/buildkit:v0.12.0 + image=moby/buildkit:v0.13.2 - name: Log in to Gitea Registry uses: docker/login-action@v3 @@ -33,8 +35,10 @@ jobs: file: ./Dockerfile.fast push: true platforms: linux/amd64 - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: | + type=registry,ref=git.shts.su/${{ gitea.repository }}:tabler-fast-buildcache + type=registry,ref=git.shts.su/${{ gitea.repository }}:tabler-fast + cache-to: type=registry,ref=git.shts.su/${{ gitea.repository }}:tabler-fast-buildcache,mode=max tags: | git.shts.su/${{ gitea.repository }}:tabler-fast git.shts.su/${{ gitea.repository }}:tabler-fast-${{ gitea.sha }} @@ -45,4 +49,5 @@ jobs: org.opencontainers.image.revision=${{ gitea.sha }} org.opencontainers.image.created=${{ gitea.event.head_commit.timestamp }} build-args: | - BUILDKIT_INLINE_CACHE=1 \ No newline at end of file + BUILDKIT_INLINE_CACHE=1 + provenance: false \ No newline at end of file diff --git a/Dockerfile.fast b/Dockerfile.fast index 2cdaf17..7e2b842 100644 --- a/Dockerfile.fast +++ b/Dockerfile.fast @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.6 # Stage 1: Build React frontend FROM node:20-alpine AS frontend-builder WORKDIR /app/frontend @@ -5,19 +6,17 @@ WORKDIR /app/frontend # Install build dependencies for native modules RUN apk add --no-cache python3 make g++ -# Set npm config for better performance and caching -RUN npm config set registry https://registry.npmjs.org/ -RUN npm config set fetch-timeout 300000 -RUN npm config set fetch-retry-mintimeout 20000 -RUN npm config set fetch-retry-maxtimeout 120000 -RUN npm config set cache /tmp/.npm +# Set npm config for better performance +RUN npm config set registry https://registry.npmjs.org/ \ + && npm config set fetch-timeout 300000 \ + && npm config set fetch-retry-mintimeout 20000 \ + && npm config set fetch-retry-maxtimeout 120000 # Copy package files first for better caching COPY frontend/package*.json ./ -# Clean install dependencies to fix rollup issue with optimized flags -RUN rm -rf node_modules package-lock.json -RUN npm install --no-audit --no-fund --prefer-offline --build-from-source --production=false --cache /tmp/.npm +# Clean install dependencies with lockfile for reproducible and cached builds +RUN --mount=type=cache,target=/root/.npm npm ci --no-audit --no-fund # Copy source code (only what's needed for build) COPY frontend/src/ ./src/ @@ -33,20 +32,18 @@ RUN npm run build FROM node:20-alpine WORKDIR /app -# Set npm config for better performance and caching -RUN npm config set registry https://registry.npmjs.org/ -RUN npm config set fetch-timeout 300000 -RUN npm config set cache /tmp/.npm +# Set npm config for better performance +RUN npm config set registry https://registry.npmjs.org/ \ + && npm config set fetch-timeout 300000 # Copy package files first for better caching COPY backend/package*.json ./ # Install production dependencies only with optimized flags -RUN npm ci --only=production --no-audit --no-fund --prefer-offline --cache /tmp/.npm +RUN --mount=type=cache,target=/root/.npm npm ci --only=production --no-audit --no-fund # Copy backend source code (only what's needed) COPY backend/server.js ./ -COPY backend/package.json ./ # Copy built frontend assets from the previous stage COPY --from=frontend-builder /app/frontend/dist ./public diff --git a/frontend/src/AutoUrlManager.jsx b/frontend/src/AutoUrlManager.jsx index 4ceb5db..f379b36 100644 --- a/frontend/src/AutoUrlManager.jsx +++ b/frontend/src/AutoUrlManager.jsx @@ -9,7 +9,9 @@ import { IconLoader, IconUpload, IconDeviceFloppy, - IconInfoCircle + IconInfoCircle, + IconCircleCheck, + IconCopy } from '@tabler/icons-react'; function AutoUrlManager() { @@ -119,6 +121,29 @@ function AutoUrlManager() { } }; + const copyExample = async () => { + const text = 'https://test.com/ips.txt 555\nhttps://example.com/blacklist.txt 666'; + try { + if (navigator.clipboard) { + await navigator.clipboard.writeText(text); + } else { + const ta = document.createElement('textarea'); + ta.value = text; + document.body.appendChild(ta); + ta.select(); + document.execCommand('copy'); + document.body.removeChild(ta); + } + setMessage('Пример формата скопирован'); + setMessageType('success'); + setTimeout(() => setMessage(''), 2000); + } catch (e) { + setMessage('Не удалось скопировать пример'); + setMessageType('error'); + setTimeout(() => setMessage(''), 2000); + } + }; + if (loading) { return (
@@ -327,22 +352,55 @@ function AutoUrlManager() {

Информация

-
+
-

Как это работает:

-
    -
  • Добавьте URL-адреса, которые содержат списки IP-адресов
  • -
  • Укажите community для каждого URL
  • -
  • Нажмите "Загрузить IP-списки" для обработки всех URL
  • -
  • IP-адреса будут добавлены в файл bgp_data/ips.txt
  • +

    Как это работает

    +
      +
    • + + Добавьте URL-адреса, которые содержат списки IP-адресов +
    • +
    • + + Укажите community для каждого URL (только цифры) +
    • +
    • + + Нажмите «Загрузить IP-списки» для обработки всех URL +
    • +
    • + + IP-адреса будут добавлены в файл bgp_data/ips.txt +
-

Формат файла:

-

Файл сохраняется в формате:

-
-{`https://test.com/ips.txt 555\nhttps://example.com/blacklist.txt 666`}
-              
+

Формат файла

+
+
+

Пример

+
+ +
+
+
+
+                    {`https://test.com/ips.txt 555\nhttps://example.com/blacklist.txt 666`}
+                  
+
Каждая строка: URL и community через пробел
+
+