From 0569e29bb28eb402c60daa953985e52da72f1ed4 Mon Sep 17 00:00:00 2001 From: bgharbi Date: Mon, 20 Nov 2023 14:15:41 +0100 Subject: [PATCH] add DO database certificate --- .github/workflows/cicd.yml | 4 ++-- Dockerfile | 2 ++ indexer/src/utils/db.ts | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 2cb6cf8..fcb4ac3 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -39,8 +39,8 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # secrets: | - # "certificate=${{ secrets.CERTIFICATE }}" + secrets: | + "certificate=${{ secrets.CERTIFICATE }}" Deploy-review: if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' diff --git a/Dockerfile b/Dockerfile index 1130557..cc364a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,8 @@ FROM node:16.15.1 ADD indexer/ /app WORKDIR /app +RUN --mount=type=secret,id=certificate \ + cat /run/secrets/certificate >> /app/ca-certificate.crt RUN yarn install && yarn build diff --git a/indexer/src/utils/db.ts b/indexer/src/utils/db.ts index ea808f1..e10409e 100644 --- a/indexer/src/utils/db.ts +++ b/indexer/src/utils/db.ts @@ -8,7 +8,7 @@ import { Transaction } from "../entity/transaction"; import { Balance } from "../view/balance"; import { Creator } from '../view/creator'; import { Infinite } from '../view/infinite'; - +import * as fs from 'fs'; // We need to store bigints in jsonb column, typeorm doesn't support that. // Transformers in typeorm run _before_ typeorm's JSON.stringify run, so it is problematic @@ -34,6 +34,9 @@ export const AppDataSource = new DataSource({ username: process.env.DB_USER, password: process.env.DB_PASS, database: process.env.DB_NAME, + ssl: { + ca: fs.readFileSync("ca-certificate.crt").toString(), + }, synchronize: false, logging: false, entities: [Block, Event, Transaction, Refresh, Balance, Creator, Infinite],