Skip to content

Commit 19e1a6d

Browse files
committed
chore: build scripts setup
1 parent 0187f54 commit 19e1a6d

38 files changed

+3367
-6622
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dist
2+
node_modules
3+
reflections
4+
.env
5+
.gitignore
6+
.git
7+
README.md
8+

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules/
2-
reflections/
2+
reflections/*
33
dist/
44
.env
55
.DS_Store
6+
.npmrc

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:18.11.0-alpine3.16 as ts-compile
2+
WORKDIR /usr/tc-acl
3+
COPY package*.json ./
4+
COPY tsconfig*.json ./
5+
RUN npm install
6+
COPY . ./
7+
RUN npm run build:app
8+
9+
FROM node:18.11.0-alpine3.16 as ts-remove
10+
WORKDIR /usr/tc-acl
11+
COPY --from=ts-compile /usr/tc-acl/package*.json ./
12+
COPY --from=ts-compile /usr/tc-acl/dist ./
13+
RUN npm install --omit=dev
14+
15+
FROM gcr.io/distroless/nodejs:18
16+
WORKDIR /usr/tc-acl
17+
COPY --from=ts-remove /usr/tc-acl ./
18+
USER 1000
19+
CMD ["server.js"]
20+
21+

bin/nosql-client.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
require("dotenv").config();
2-
31
const path = require("path");
4-
const { execSync } = require("child_process");
52
const rimraf = require("rimraf");
63

7-
const PROTO_DIR = process.env.GRPC_NOSQL_PROTO_PATH;
8-
const MODEL_DIR = path.join(__dirname, "../src/dal/models/nosql/");
4+
const { execSync } = require("child_process");
5+
6+
const PROTO_DIR = path.join(
7+
__dirname,
8+
"../node_modules/topcoder-interface/data-access-layer/nosql"
9+
);
10+
const MODEL_DIR = path.join(__dirname, "../src/grpc/models/nosql/");
911

1012
const PROTOC_PATH = "protoc";
1113
const PLUGIN_PATH = path.join(
@@ -23,6 +25,8 @@ const protoConfig = [
2325
"--ts_proto_opt=outputServices=grpc-js,env=node,useOptionals=messages,exportCommonSymbols=false,esModuleInterop=true",
2426
`--ts_proto_opt=oneof=unions`,
2527
`--ts_proto_opt=addGrpcMetadata=true`,
28+
`--ts_proto_opt=stringEnums=true`,
29+
`--ts_proto_opt=useDate=string`,
2630
`--ts_proto_opt=outputServerImpl=false`,
2731
`--ts_proto_out=${MODEL_DIR}`,
2832
`--proto_path ${PROTO_DIR} ${PROTO_DIR}/*.proto`,

bin/rdb-client.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
require("dotenv").config();
2-
31
const path = require("path");
4-
const { execSync } = require("child_process");
52
const rimraf = require("rimraf");
63

7-
const PROTO_DIR = process.env.GRPC_RDB_PROTO_PATH;
8-
const MODEL_DIR = path.join(__dirname, "../src/dal/models/rdb/");
4+
const { execSync } = require("child_process");
5+
6+
const PROTO_DIR = path.join(
7+
__dirname,
8+
"../node_modules/topcoder-interface/data-access-layer/relational"
9+
);
10+
const MODEL_DIR = path.join(__dirname, "../src/grpc/models/rdb/");
911

1012
const PROTOC_PATH = "protoc";
1113
const PLUGIN_PATH = path.join(
@@ -26,7 +28,6 @@ const protoConfig = [
2628
`--ts_proto_opt=outputServerImpl=false`,
2729
`--ts_proto_out=${MODEL_DIR}`,
2830
`--proto_path ${PROTO_DIR} ${PROTO_DIR}/*.proto`,
29-
`--include_imports`,
3031
];
3132

3233
// https://github.com/stephenh/ts-proto#usage

bin/server.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
require("dotenv").config();
2-
31
const path = require("path");
4-
const { execSync } = require("child_process");
52
const rimraf = require("rimraf");
63

7-
const PROTO_DIR = process.env.PROTO_PATH;
4+
const { execSync } = require("child_process");
5+
6+
const PROTO_DIR = path.join(__dirname, "../node_modules/topcoder-interface");
87
const PROTO_REFLECTIONS = path.join(__dirname, "../reflections/reflection.bin");
98

109
const MODEL_DIR = path.join(__dirname, "../src/models/");
@@ -24,12 +23,15 @@ const protoConfig = [
2423
// https://github.com/stephenh/ts-proto/blob/main/README.markdown
2524
"--ts_proto_opt=outputServices=grpc-js,env=node,useOptionals=messages,exportCommonSymbols=false,esModuleInterop=true",
2625
`--ts_proto_out=${MODEL_DIR}`,
27-
`--proto_path ${PROTO_DIR} ${PROTO_DIR}/**/*.proto`,
2826
`--ts_proto_opt=oneof=unions`,
2927
`--ts_proto_opt=addGrpcMetadata=true`,
3028
`--ts_proto_opt=outputClientImpl=false`,
31-
`--descriptor_set_out ${PROTO_REFLECTIONS}`,
3229
`--include_imports`,
30+
`--descriptor_set_out ${PROTO_REFLECTIONS}`,
31+
`--ts_proto_opt=Mcommon/common.proto=@topcoder-framework/lib-common`,
32+
`--ts_proto_opt=Mgoogle/protobuf/struct.proto=@topcoder-framework/lib-common`,
33+
`--ts_proto_opt=Mgoogle/protobuf/timestamp.proto=@topcoder-framework/lib-common`,
34+
`--proto_path ${PROTO_DIR} ${PROTO_DIR}/domain-layer/legacy/**/*.proto`,
3335
];
3436

3537
// https://github.com/stephenh/ts-proto#usage

0 commit comments

Comments
 (0)