Skip to content

Commit 000b15d

Browse files
committed
add cube gitbase docker-compose running
0 parents  commit 000b15d

20 files changed

+617
-0
lines changed

.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
REDIS_URL=redis://redis_db:6379/0
2+
CUBEJS_DB_HOST=gitbase
3+
CUBEJS_DB_NAME=gitbase
4+
CUBEJS_DB_USER=root
5+
CUBEJS_DB_TYPE=mysql
6+
CUBEJS_API_SECRET=f175c412a9136d6bf6cb84bc59c027f39cc93ae35887774ac3fe091bb0717a8d53409a967a1d2014988ef344e75214d48e0cd65c8b6c9403f8d0850a5545afdd

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# cube gitbase(mysql) docker-compose running
2+
3+
> with redis for cache

cube/.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
npm-debug.log
3+
.env
4+
schema

cube/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:10-alpine
2+
LABEL AUTHOR="dalong"
3+
LABEL EMAIL="[email protected]"
4+
WORKDIR /usr/src/app
5+
COPY package*.json ./
6+
7+
RUN npm install
8+
9+
COPY . .
10+
11+
EXPOSE 4000

cube/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const CubejsServer = require('@cubejs-backend/server');
2+
3+
const server = new CubejsServer();
4+
5+
server.listen().then(({ port }) => {
6+
console.log(`🚀 Cube.js server is listening on ${port}`);
7+
});

cube/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "gitbase-demo",
3+
"version": "0.0.1",
4+
"private": true,
5+
"scripts": {
6+
"dev": "./node_modules/.bin/cubejs-dev-server"
7+
},
8+
"dependencies": {
9+
"@cubejs-backend/mysql-driver": "^0.9.2",
10+
"@cubejs-backend/server": "^0.9.2"
11+
}
12+
}

cube/schema/Blobs.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cube(`Blobs`, {
2+
sql: `SELECT * FROM gitbase.blobs`,
3+
4+
joins: {
5+
Repositories: {
6+
sql: `${CUBE}.repository_id = ${Repositories}.repository_id`,
7+
relationship: `belongsTo`
8+
}
9+
},
10+
11+
measures: {
12+
count: {
13+
type: `count`,
14+
drillMembers: [repositoryId]
15+
}
16+
},
17+
18+
dimensions: {
19+
repositoryId: {
20+
sql: `repository_id`,
21+
type: `string`,
22+
primaryKey: true
23+
},
24+
repositoryId2: {
25+
sql: `repository_id`,
26+
type: `string`,
27+
},
28+
blobHash: {
29+
sql: `blob_hash`,
30+
type: `string`
31+
},
32+
33+
blobContent: {
34+
sql: `blob_content`,
35+
type: `string`
36+
}
37+
}
38+
});

cube/schema/CommitBlobs.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cube(`CommitBlobs`, {
2+
sql: `SELECT * FROM gitbase.commit_blobs`,
3+
4+
joins: {
5+
Repositories: {
6+
sql: `${CUBE}.repository_id = ${Repositories}.repository_id`,
7+
relationship: `belongsTo`
8+
}
9+
},
10+
11+
measures: {
12+
count: {
13+
type: `count`,
14+
drillMembers: [repositoryId]
15+
}
16+
},
17+
18+
dimensions: {
19+
repositoryId: {
20+
sql: `repository_id`,
21+
type: `string`,
22+
primaryKey: true
23+
},
24+
repositoryId2: {
25+
sql: `repository_id`,
26+
type: `string`,
27+
},
28+
commitHash: {
29+
sql: `commit_hash`,
30+
type: `string`
31+
},
32+
33+
blobHash: {
34+
sql: `blob_hash`,
35+
type: `string`
36+
}
37+
}
38+
});

cube/schema/CommitFiles.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
cube(`CommitFiles`, {
2+
sql: `SELECT * FROM gitbase.commit_files`,
3+
4+
joins: {
5+
Repositories: {
6+
sql: `${CUBE}.repository_id = ${Repositories}.repository_id`,
7+
relationship: `belongsTo`
8+
}
9+
},
10+
11+
measures: {
12+
count: {
13+
type: `count`,
14+
drillMembers: [repositoryId]
15+
}
16+
},
17+
18+
dimensions: {
19+
repositoryId: {
20+
sql: `repository_id`,
21+
type: `string`,
22+
primaryKey: true
23+
},
24+
repositoryId2: {
25+
sql: `repository_id`,
26+
type: `string`,
27+
},
28+
commitHash: {
29+
sql: `commit_hash`,
30+
type: `string`
31+
},
32+
33+
filePath: {
34+
sql: `file_path`,
35+
type: `string`
36+
},
37+
38+
blobHash: {
39+
sql: `blob_hash`,
40+
type: `string`
41+
},
42+
43+
treeHash: {
44+
sql: `tree_hash`,
45+
type: `string`
46+
}
47+
}
48+
});

0 commit comments

Comments
 (0)