Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Cargo.lock

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

21 changes: 21 additions & 0 deletions dockertest/runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ RUN --mount=type=cache,sharing=private,target=/go/pkg/mod \
# Build grpcurl
CGO_ENABLED=0 go build -o /usr/local/bin/grpcurl ./cmd/grpcurl

# Use Rust base image for building grpcweb-cli
FROM rust:trixie AS builder-grpcweb-cli

# Set the working directory for grpcweb-cli
WORKDIR /usr/src/grpcweb-cli

# Clone the grpcweb-cli Git repository
RUN git clone https://github.com/DorianNiemiecSVRJS/grpcweb-cli.git /usr/src/grpcweb-cli

# Build grpcweb-cli
RUN --mount=type=cache,sharing=private,target=/usr/local/cargo/git \
--mount=type=cache,sharing=private,target=/usr/local/cargo/registry \
--mount=type=cache,sharing=private,target=/usr/src/grpcweb-cli/target \
# Build grpcweb-cli
cargo build --release && \
# Copy executables out of the cache
mkdir .dist && cp target/release/grpcweb-cli .dist

# Use Debian base image
FROM debian:trixie

Expand All @@ -47,3 +65,6 @@ COPY --from=builder-websocat /usr/src/websocat/.dist /usr/local/bin

# Copy the built grpcurl
COPY --from=builder-grpcurl /usr/local/bin/grpcurl /usr/local/bin

# Copy the built grpcweb-cli
COPY --from=builder-grpcweb-cli /usr/src/grpcweb-cli/.dist /usr/local/bin
2 changes: 2 additions & 0 deletions dockertest/tests/grpcweb/backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/Dockerfile
2 changes: 2 additions & 0 deletions dockertest/tests/grpcweb/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/hello.proto
17 changes: 17 additions & 0 deletions dockertest/tests/grpcweb/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the official Node.js image
FROM node:22-alpine

# Set the working directory
WORKDIR /app

# Copy files into the container
COPY . .

# Install dependencies
RUN npm install

# Expose port 3000
EXPOSE 3000

# Start the application
CMD ["node", "index.js"]
60 changes: 60 additions & 0 deletions dockertest/tests/grpcweb/backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Based on https://github.com/grpc/grpc-node/blob/master/examples/helloworld/dynamic_codegen/greeter_server.js,
// with a custom .proto file path
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

const PROTO_PATH = __dirname + "/hello.proto";

const grpc = require("@grpc/grpc-js");
const protoLoader = require("@grpc/proto-loader");
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
});
const hello_proto = grpc.loadPackageDefinition(packageDefinition).helloworld;

/**
* Implements the SayHello RPC method.
*/
function sayHello(call, callback) {
callback(null, { message: "Hello " + call.request.name });
}

/**
* Starts an RPC server that receives requests for the Greeter service at the
* sample server port
*/
function main() {
var server = new grpc.Server();
server.addService(hello_proto.Greeter.service, { sayHello: sayHello });
server.bindAsync(
"0.0.0.0:50051",
grpc.ServerCredentials.createInsecure(),
(err, port) => {
if (err != null) {
return console.error(err);
}
console.log(`gRPC listening on ${port}`);
},
);
}

main();
Loading