diff --git a/packages/database/src/pg/impl/tables/collection.ts b/packages/database/src/pg/impl/tables/collection.ts index dc2d94446..206dad27a 100644 --- a/packages/database/src/pg/impl/tables/collection.ts +++ b/packages/database/src/pg/impl/tables/collection.ts @@ -104,7 +104,7 @@ export class CollectionConverter implements Converter tokenSymbol: get(d, 'tokenSymbol', ''), tokenReward: get(d, 'tokenReward', 0), amount: get(d, 'amount', 0), - } as DiscountLine), + }) as DiscountLine, ), total: pg.total || 0, totalTrades: pg.totalTrades || 0, diff --git a/packages/notifier/.prettierignore b/packages/notifier/.prettierignore index 31dae4e58..626c4f31e 100644 --- a/packages/notifier/.prettierignore +++ b/packages/notifier/.prettierignore @@ -1,2 +1,2 @@ -/coverage /lib +/node_modules diff --git a/packages/notifier/Dockerfile b/packages/notifier/Dockerfile new file mode 100644 index 000000000..3dbea32c5 --- /dev/null +++ b/packages/notifier/Dockerfile @@ -0,0 +1,10 @@ +FROM node:20 + +WORKDIR /notifier + +COPY . . + +RUN npm i +RUN npm run build + +CMD ["node", "-r", "dotenv/config", "lib/index.js"] diff --git a/packages/notifier/README.md b/packages/notifier/README.md index ffaedaf91..a77be72e1 100644 --- a/packages/notifier/README.md +++ b/packages/notifier/README.md @@ -3,11 +3,6 @@ 1. cd packages/notifier 2. gcloud compute scp --recurse ./ notifier:~/notifier 3. gcloud compute ssh notifier -4. sudo apt install npm -5. curl -o cloud-sql-proxy \ - https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.0.0/cloud-sql-proxy.linux.amd64 -6. chmod +x cloud-sql-proxy -7. ./cloud-sql-proxy buildcore-prod:us-central1:buildcore & -8. sudo npm install pm2 -g -9. cd notifier && npm i && npm run build -10. pm2 start lib/index.js --name notifier +4. install docker: https://docs.docker.com/engine/install/ubuntu/ +5. cd notifier +6. docker compose up diff --git a/packages/notifier/docker-compose.yml b/packages/notifier/docker-compose.yml new file mode 100644 index 000000000..faf5a6bee --- /dev/null +++ b/packages/notifier/docker-compose.yml @@ -0,0 +1,27 @@ +services: + notifier: + container_name: notifier + build: + context: . + depends_on: + - cloudsql-proxy + networks: + - notifier + restart: unless-stopped + + cloudsql-proxy: + container_name: cloudsql-proxy + image: gcr.io/cloud-sql-connectors/cloud-sql-proxy + command: buildcore-prod:us-central1:buildcore --credentials-file=/secrets/cloudsql/credentials.json --address 0.0.0.0 --port 5432 + networks: + - notifier + ports: + - 127.0.0.1:5432:5432 + volumes: + - ./credentials.json:/secrets/cloudsql/credentials.json + restart: unless-stopped + +networks: + notifier: + name: notifier + driver: bridge diff --git a/packages/notifier/package.json b/packages/notifier/package.json index 605254d5f..9f86136db 100644 --- a/packages/notifier/package.json +++ b/packages/notifier/package.json @@ -5,7 +5,7 @@ "main": "lib/index.js", "scripts": { "build": "tsc", - "start": "export GOOGLE_APPLICATION_CREDENTIALS=\"./sa.json\" && node lib/index.js" + "start": "node -r dotenv/config lib/index.js" }, "author": "Boldizsar Mezei", "license": "Apache-2.0", diff --git a/packages/notifier/src/index.ts b/packages/notifier/src/index.ts index 48349637d..bf72c2711 100644 --- a/packages/notifier/src/index.ts +++ b/packages/notifier/src/index.ts @@ -1,8 +1,6 @@ import { PubSub, Topic } from '@google-cloud/pubsub'; import Knex from 'knex'; -import path from 'path'; import { logger } from './logger'; -require('dotenv').config({ path: path.join(__dirname, '/../.env') }); const knex = Knex({ client: 'pg',