From 57c90201b1e89e1ef6bca3dffd9b592c2206bd66 Mon Sep 17 00:00:00 2001 From: Hugues Chocart Date: Fri, 20 Sep 2024 19:27:46 +0100 Subject: [PATCH] chore: improve docker build pipeline (#570) --- .github/workflows/build-push-deploy.yml | 56 +------------------------ packages/backend/src/utils/db.ts | 4 +- 2 files changed, 4 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build-push-deploy.yml b/.github/workflows/build-push-deploy.yml index 86c5085c..5b8cef1b 100644 --- a/.github/workflows/build-push-deploy.yml +++ b/.github/workflows/build-push-deploy.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - service: [backend, realtime-evaluators] + service: [backend, frontend, realtime-evaluators] steps: - name: Check out the private Ops repo uses: actions/checkout@v4 @@ -46,7 +46,7 @@ jobs: run: echo "tag=$(echo ${{ github.event.release.tag_name }} | sed 's/^v//')" >> $GITHUB_OUTPUT - name: Build and push ${{ matrix.service }} - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . file: ./ops/${{ matrix.service }}.Dockerfile @@ -76,55 +76,3 @@ jobs: docker compose pull docker compose down docker compose up -d - - build-push-others: - needs: deploy - runs-on: ubuntu-latest - strategy: - matrix: - service: [frontend] - steps: - - name: Check out the private Ops repo - uses: actions/checkout@v4 - with: - token: ${{ secrets.GH_TOKEN }} - submodules: "recursive" - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - version: "lab:latest" - driver: cloud - endpoint: "lunary/lunary" - - - name: Generate date - id: date - run: echo "date=$(date +%Y-%m-%d-%Hh%Mm%Ss)" >> $GITHUB_OUTPUT - - - name: Get short commit hash - id: commit - run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - - name: Remove 'v' prefix from release tag - id: release_tag - run: echo "tag=$(echo ${{ github.event.release.tag_name }} | sed 's/^v//')" >> $GITHUB_OUTPUT - - - name: Build and push frontend - uses: docker/build-push-action@v5 - with: - context: . - file: ./ops/${{ matrix.service }}.Dockerfile - push: true - tags: | - lunary/${{ matrix.service }}:latest - lunary/${{ matrix.service }}:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }} - ${{ github.event.release.tag_name != '' && format('lunary/{0}:{1}', matrix.service, steps.release_tag.outputs.tag) || '' }} - platforms: linux/arm64,linux/amd64 - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/packages/backend/src/utils/db.ts b/packages/backend/src/utils/db.ts index 5c2f1b82..60204639 100644 --- a/packages/backend/src/utils/db.ts +++ b/packages/backend/src/utils/db.ts @@ -19,10 +19,10 @@ const sql = postgres(process.env.DATABASE_URL!, { // Values outside JS safe range will be capped at +/- Infinity, because above Number.MAX_SAFE_INTEGER there are rounding approximations parse: (x: string) => { const number = Number(x); - if (number > Number.MAX_SAFE_INTEGER) { + if (!Number.isSafeInteger(number)) { return Infinity; } - return Number(x); + return number; }, }, },