fix(number-fields): избегаем потери точности длинных чисел
- number-поля теперь рендерятся как text + inputMode=numeric, чтобы браузер не округлял значения через input type=number - пробелы при вставке в number-поля удаляются - бэкенд нормализует значения number-полей в строку перед сохранением - добавлен хелпер normalizeFieldValueForStorage Closes: искажение расчётного счёта и других длинных числовых полей
This commit is contained in:
57
.github/workflows/build-document-worker.yml
vendored
Normal file
57
.github/workflows/build-document-worker.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: Build and Push Document Worker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'server/documents/worker/**'
|
||||
- 'docker/Dockerfile.documents'
|
||||
- '.github/workflows/build-document-worker.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build document-worker image
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 50
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository_owner }}/iistwin-document-worker
|
||||
tags: |
|
||||
type=sha,prefix=,suffix=,format=short
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: docker/Dockerfile.documents
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
ALPINE_MIRROR=mirrors.aliyun.com
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
171
.github/workflows/deploy.yml
vendored
Normal file
171
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
name: Deploy to Server
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
# Daily production deploy at 03:00 UTC.
|
||||
# All feature branches merged into main during the day are deployed at this time.
|
||||
- cron: '0 3 * * *'
|
||||
workflow_dispatch:
|
||||
# Manual deploy for emergencies only.
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Type Check & Build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Type check
|
||||
run: npm run check
|
||||
|
||||
- name: Type check document worker
|
||||
run: |
|
||||
cd server/documents/worker
|
||||
npm ci
|
||||
npm run check
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
deploy:
|
||||
name: Deploy to VPS
|
||||
needs: check
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main'
|
||||
timeout-minutes: 50
|
||||
concurrency:
|
||||
group: production-deploy
|
||||
cancel-in-progress: false
|
||||
|
||||
steps:
|
||||
- name: Deploy via SSH
|
||||
uses: appleboy/ssh-action@v1
|
||||
env:
|
||||
GHCR_USERNAME: ${{ github.actor }}
|
||||
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
host: 82.202.130.22
|
||||
username: root
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
timeout: 60s
|
||||
command_timeout: 45m
|
||||
envs: GHCR_USERNAME,GHCR_TOKEN
|
||||
script: |
|
||||
set -e
|
||||
cd /opt/crm
|
||||
|
||||
# 1. Сохранить кастомизации сервера
|
||||
git stash push -m 'server-customizations' \
|
||||
-- docker-compose.yml docker-entrypoint.sh \
|
||||
server/index.ts shared/schema.ts \
|
||||
client/src/services/auth.service.ts || true
|
||||
|
||||
# 2. Получить ровно ту версию, что в GitHub (без merge-конфликтов)
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
|
||||
# 3. Восстановить кастомизации
|
||||
git stash pop || true
|
||||
|
||||
# 4. Восстановить docker-compose из бэкапа (вне репозитория)
|
||||
cp /opt/crm-server/docker-compose.yml.bak.serverfix docker-compose.yml
|
||||
|
||||
# 5. Удалить старые/зависшие контейнеры, чтобы избежать
|
||||
# Conflict: container name is already in use
|
||||
docker compose stop app document-worker || true
|
||||
docker compose rm -f app document-worker || true
|
||||
docker ps -aq --filter "name=crm-app" | xargs -r docker rm -f || true
|
||||
docker ps -aq --filter "name=crm-document-worker" | xargs -r docker rm -f || true
|
||||
|
||||
# 5.5 Логин в GitHub Container Registry для скачивания prebuilt образа document-worker
|
||||
echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GHCR_USERNAME" --password-stdin
|
||||
|
||||
# 5.6 Мягкая очистка: удалить старые контейнеры и dangling образы,
|
||||
# но оставить build cache для ускорения сборки CRM.
|
||||
docker system prune -f
|
||||
|
||||
# 6. Собрать и запустить приложение.
|
||||
# document-worker больше не собирается здесь — используется готовый образ из GHCR.
|
||||
# BUILD_ARG инвалидирует слой сборки фронтенда, если код изменился,
|
||||
# но позволяет Docker кэшировать слои npm ci.
|
||||
# Retry 3 times to work around transient Alpine mirror I/O errors.
|
||||
BUILD_SHA=${{ github.sha }}
|
||||
BUILD_OK=false
|
||||
for attempt in 1 2 3; do
|
||||
echo "=== Docker build attempt $attempt ==="
|
||||
if docker compose build --build-arg BUILD_SHA=$BUILD_SHA --build-arg ALPINE_MIRROR=mirrors.aliyun.com app; then
|
||||
BUILD_OK=true
|
||||
break
|
||||
fi
|
||||
echo "Build failed on attempt $attempt"
|
||||
if [ "$attempt" -lt 3 ]; then
|
||||
echo "Cleaning Docker cache and retrying in 30s..."
|
||||
docker system prune -a -f
|
||||
docker builder prune -f
|
||||
sleep 30
|
||||
fi
|
||||
done
|
||||
if [ "$BUILD_OK" != "true" ]; then
|
||||
echo "Docker build failed after 3 attempts"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 6.5 Получить свежий prebuilt образ document-worker из GHCR
|
||||
docker compose pull document-worker
|
||||
|
||||
docker compose up -d app document-worker
|
||||
|
||||
# 7. Дождаться healthcheck'ов
|
||||
echo "Waiting for healthchecks..."
|
||||
APP_HEALTHY=false
|
||||
WORKER_HEALTHY=false
|
||||
for i in $(seq 1 30); do
|
||||
if [ "$APP_HEALTHY" != "true" ] && docker ps | grep crm-app | grep -q healthy; then
|
||||
echo "iistwin app is healthy!"
|
||||
APP_HEALTHY=true
|
||||
fi
|
||||
if [ "$WORKER_HEALTHY" != "true" ] && docker ps | grep crm-document-worker | grep -q healthy; then
|
||||
echo "document-worker is healthy!"
|
||||
WORKER_HEALTHY=true
|
||||
fi
|
||||
if [ "$APP_HEALTHY" = "true" ] && [ "$WORKER_HEALTHY" = "true" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if [ "$APP_HEALTHY" != "true" ]; then
|
||||
echo "App healthcheck failed"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$WORKER_HEALTHY" != "true" ]; then
|
||||
echo "Document worker healthcheck failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 8. Мягкая очистка Docker: оставляем build cache и tagged базовые образы,
|
||||
# чтобы следующий деплой переиспользовал слои npm ci и сборки.
|
||||
# Полная очистка запускается ежедневно через cron (disk-check.sh / docker-cleanup.sh).
|
||||
docker system prune -f
|
||||
docker builder prune -f --keep-storage 5gb
|
||||
|
||||
# 9. Удалить старые образы crm-app, чтобы они не копились между деплоями.
|
||||
# Текущий образ используется запущенным контейнером, поэтому он не удалится.
|
||||
CURRENT_IMAGE_ID=$(docker inspect --format='{{.Image}}' crm-app-1)
|
||||
docker images crm-app --format "{{.ID}}" | grep -v "$CURRENT_IMAGE_ID" | xargs -r docker rmi -f || true
|
||||
|
||||
echo "Cleanup completed"
|
||||
39
.github/workflows/pr-check.yml
vendored
Normal file
39
.github/workflows/pr-check.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
name: Branch Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Type Check & Build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Type check
|
||||
run: npm run check
|
||||
|
||||
- name: Type check document worker
|
||||
run: |
|
||||
cd server/documents/worker
|
||||
npm ci
|
||||
npm run check
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
Reference in New Issue
Block a user