Skip to content

Commit

Permalink
Merge pull request #242 from Chia-Network/feat/dockerfile
Browse files Browse the repository at this point in the history
ci: create dockerfile
  • Loading branch information
MichaelTaylor3D committed Jan 28, 2022
2 parents eb2d3e6 + 309471c commit e5f07a4
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 41 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ jobs:
- name: npm cache verify
run: npm cache verify

- name: install sequelize-cli globally
run: npm i -g sequelize-cli

- name: install cross-env globally
run: npm install -g cross-env
- name: install global packages
run: npm i -g @babel/cli sequelize-cli cross-env

- name: npm tests
run: npm run test
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:16

WORKDIR /usr/src/app
RUN npm install -g json
COPY package*.json ./
COPY data.sqlite3 ./
COPY .env.copy ./.env
RUN json -I -f package.json -e "this.type=\"commonjs\""
RUN npm set-script prepare ""
RUN npm set-script requirements-check ""
COPY ./build .
RUN npm install

EXPOSE 3030
CMD [ "node", "server.js" ]
37 changes: 6 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"express-joi-validation": "^5.0.0",
"joi": "^17.5.0",
"lodash": "^4.17.21",
"log-update": "^4.0.0",
"mysql2": "^2.3.3",
"node-xlsx": "^0.21.0",
"random-hash": "^4.0.1",
Expand Down
4 changes: 4 additions & 0 deletions src/config/config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ module.exports = {
local: {
dialect: 'sqlite',
storage: './data.sqlite3',
logging: false,
},
test: {
dialect: 'sqlite',
storage: './test.sqlite3',
logging: true,
},
mirrorTest: {
dialect: 'sqlite',
storage: './testMirror.sqlite3',
logging: true,
},
mirror: {
username: process.env.DB_USERNAME || '',
password: process.env.DB_PASSWORD || '',
database: process.env.DB_NAME || '',
host: process.env.DB_HOST || '',
dialect: 'mysql',
logging: false,
},
};
15 changes: 13 additions & 2 deletions src/fullnode/simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { uuid as uuidv4 } from 'uuidv4';
import { Simulator, Organization } from '../models';
import { Sequelize } from 'sequelize';
import { createHash } from 'crypto';
import logUpdate from 'log-update';

const Op = Sequelize.Op;

const frames = ['-', '\\', '|', '/'];

export const createDataLayerStore = async () => {
return uuidv4();
};
Expand Down Expand Up @@ -67,7 +70,11 @@ export const getRoot = async (storeId) => {
});

if (!myOrganization) {
console.log('Cant get root, Home org does not yet exist');
logUpdate(
`Cant get root, Home org does not yet exist ${
frames[Math.floor(Math.random() * 3)]
}`,
);
return Promise.resolve({
hash: null,
success: false,
Expand All @@ -94,7 +101,11 @@ export const getRoots = async (storeIds) => {
});

if (!myOrganization) {
console.log('Cant get root, Home org does not yet exist');
logUpdate(
`Cant get root, Home org does not yet exist ${
frames[Math.floor(Math.random() * 3)]
}`,
);
return Promise.resolve({
hash: null,
success: false,
Expand Down
17 changes: 14 additions & 3 deletions src/fullnode/syncService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import logUpdate from 'log-update';

import {
Organization,
Expand All @@ -18,16 +19,25 @@ import { sequelize, sequelizeMirror } from '../models/database';
import * as dataLayer from './persistance';
import * as simulator from './simulator';

export const POLLING_INTERVAL = 10000;
export const POLLING_INTERVAL = 5000;
const frames = ['-', '\\', '|', '/'];

console.log('Start Datalayer Update Polling');
export const startDataLayerUpdatePolling = async () => {
console.log('Start Datalayer Update Polling');

const tablesToUpdate = await dataLayerWasUpdated();
await Promise.all(
_.keys(tablesToUpdate).map(async (storeId) => {
if (tablesToUpdate[storeId]) {
logUpdate(
`Updates found syncing storeId: ${storeId} ${
frames[Math.floor(Math.random() * 3)]
}`,
);
await syncDataLayerStoreToClimateWarehouse(storeId);
} else {
logUpdate(
`No updates found yet ${frames[Math.floor(Math.random() * 3)]}`,
);
}
}),
);
Expand All @@ -48,6 +58,7 @@ export const syncDataLayerStoreToClimateWarehouse = async (storeId) => {
const organizationToTrucate = await Organization.findOne({
where: { registryId: storeId },
attributes: ['orgUid'],
raw: true,
});

try {
Expand Down

0 comments on commit e5f07a4

Please sign in to comment.