Skip to content

Commit a544937

Browse files
committed
Generate protobuf code for Typescript service - Frontend
1 parent 98e85e1 commit a544937

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ test/tracetesting/tracetesting-vars.yaml
4444
/src/accounting/src/protos/
4545
/src/cart/src/protos/
4646
/src/fraud-detection/src/main/proto
47-
/src/frontend/pb/
48-
/src/frontend/protos/
4947
/src/payment/demo.proto
5048
/src/shipping/proto/
5149
/src/currency/proto

docker-gen-proto.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@ gen_proto_python() {
3030
python -m grpc_tools.protoc -I /build/pb/ --python_out="./src/$1/" --grpc_python_out="./src/$1/" /build/pb/demo.proto
3131
}
3232

33+
gen_proto_ts() {
34+
echo "Generating Typescript protobuf files for $1"
35+
docker build -f "src/$1/genproto/Dockerfile" -t "$1-genproto" .
36+
docker run --rm -v $(pwd):/build "$1-genproto"
37+
}
38+
3339
if [ -z "$1" ]; then
3440
#gen_proto_dotnet accounting
3541
#gen_proto_java ad
3642
#gen_proto_dotnet cart
3743
gen_proto_go checkout
3844
gen_proto_cpp currency
3945
#gen_proto_ruby email
40-
#gen_proto_ts frontend
46+
gen_proto_ts frontend
4147
#gen_proto_js payment
4248
gen_proto_go product-catalog
4349
#gen_proto_php quote

src/frontend/Dockerfile

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
54
FROM node:20-alpine AS deps
65
RUN apk add --no-cache libc6-compat
76

@@ -11,18 +10,16 @@ COPY ./src/frontend/package*.json ./
1110
RUN npm ci
1211

1312
FROM node:20-alpine AS builder
14-
RUN apk add --no-cache libc6-compat protobuf-dev protoc
13+
RUN apk add --no-cache libc6-compat
1514
WORKDIR /app
1615
COPY --from=deps /app/node_modules ./node_modules
17-
COPY ./pb ./pb
16+
COPY ./src/frontend/protos ./protos
1817
COPY ./src/frontend .
1918

20-
RUN npm run grpc:generate
2119
RUN npm run build
2220

2321
FROM node:20-alpine AS runner
2422
WORKDIR /app
25-
RUN apk add --no-cache protobuf-dev protoc
2623

2724
ENV NODE_ENV=production
2825

src/frontend/genproto/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
FROM node:20-alpine
5+
6+
WORKDIR /build
7+
8+
RUN apk add --no-cache libc6-compat protobuf-dev protoc
9+
10+
COPY ./src/frontend/package*.json ./
11+
RUN npm ci
12+
13+
CMD ["npm", "run", "grpc:generate"]

src/frontend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "npm run grpc:generate && NODE_OPTIONS='-r ./utils/telemetry/Instrumentation.js' next dev",
6+
"dev": "NODE_OPTIONS='-r ./utils/telemetry/Instrumentation.js' next dev",
77
"build": "next build",
88
"start": "node --require ./Instrumentation.js server.js",
99
"lint": "next lint",

0 commit comments

Comments
 (0)