Skip to content

Commit 6543668

Browse files
committed
Adding new GRPC demo API
Signed-off-by: Laurent Broudoux <[email protected]>
1 parent a9529a9 commit 6543668

File tree

18 files changed

+1213
-0
lines changed

18 files changed

+1213
-0
lines changed

.github/workflows/build-package.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,50 @@ on:
1212
- 'LICENSE'
1313
- 'README*'
1414
jobs:
15+
build-package-grpc-hello:
16+
runs-on: ubuntu-latest
17+
environment: Build
18+
steps:
19+
# Checkout repository content
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Filter contract-testing
24+
uses: dorny/paths-filter@v2
25+
id: changes
26+
with:
27+
filters: |
28+
grpc-hello-world:
29+
- 'grpc-hello-world-demo/**'
30+
31+
- name: Set up QEMU
32+
if: github.repository_owner == 'microcks' && steps.changes.outputs.grpc-hello-world == 'true'
33+
uses: docker/setup-qemu-action@v2
34+
35+
- name: Set up Docker Buildx
36+
if: github.repository_owner == 'microcks' && steps.changes.outputs.grpc-hello-world == 'true'
37+
uses: docker/setup-buildx-action@v2
38+
39+
- name: Login to Quay.io Registry and setup multi-arch builder
40+
if: github.repository_owner == 'microcks' && steps.changes.outputs.grpc-hello-world == 'true'
41+
run: |
42+
echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
43+
BUILDER=buildx-multi-arch
44+
docker buildx inspect $BUILDER || docker buildx create --name=$BUILDER --driver=docker-container --driver-opt=network=host
45+
46+
- name: Build and push container image
47+
if: github.repository_owner == 'microcks' && steps.changes.outputs.grpc-hello-world == 'true'
48+
run: |
49+
cd grpc-hello-world-demo
50+
mvn -B package -Pnative -Dquarkus.native.container-build=true
51+
docker buildx build --push \
52+
--platform=linux/amd64,linux/arm64 \
53+
--builder=buildx-multi-arch \
54+
--provenance=false \
55+
--build-arg TAG=latest \
56+
--file src/main/docker/Dockerfile.native \
57+
--tag=quay.io/microcks/grpc-hello-world:latest .
58+
1559
build-package-contract-testing:
1660
runs-on: ubuntu-latest
1761
environment: Build
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!target/*-runner
3+
!target/*-runner.jar
4+
!target/lib/*
5+
!target/quarkus-app/*

grpc-hello-world-demo/.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#Maven
2+
target/
3+
pom.xml.tag
4+
pom.xml.releaseBackup
5+
pom.xml.versionsBackup
6+
release.properties
7+
.flattened-pom.xml
8+
9+
# Eclipse
10+
.project
11+
.classpath
12+
.settings/
13+
bin/
14+
15+
# IntelliJ
16+
.idea
17+
*.ipr
18+
*.iml
19+
*.iws
20+
21+
# NetBeans
22+
nb-configuration.xml
23+
24+
# Visual Studio Code
25+
.vscode
26+
.factorypath
27+
28+
# OSX
29+
.DS_Store
30+
31+
# Vim
32+
*.swp
33+
*.swo
34+
35+
# patch
36+
*.orig
37+
*.rej
38+
39+
# Local environment
40+
.env
41+
42+
# Plugin directory
43+
/.quarkus/cli/plugins/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
maven-wrapper.jar
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import java.io.IOException;
21+
import java.io.InputStream;
22+
import java.net.Authenticator;
23+
import java.net.PasswordAuthentication;
24+
import java.net.URL;
25+
import java.nio.file.Files;
26+
import java.nio.file.Path;
27+
import java.nio.file.Paths;
28+
import java.nio.file.StandardCopyOption;
29+
30+
public final class MavenWrapperDownloader
31+
{
32+
private static final String WRAPPER_VERSION = "3.2.0";
33+
34+
private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );
35+
36+
public static void main( String[] args )
37+
{
38+
log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );
39+
40+
if ( args.length != 2 )
41+
{
42+
System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
43+
System.exit( 1 );
44+
}
45+
46+
try
47+
{
48+
log( " - Downloader started" );
49+
final URL wrapperUrl = new URL( args[0] );
50+
final String jarPath = args[1].replace( "..", "" ); // Sanitize path
51+
final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
52+
downloadFileFromURL( wrapperUrl, wrapperJarPath );
53+
log( "Done" );
54+
}
55+
catch ( IOException e )
56+
{
57+
System.err.println( "- Error downloading: " + e.getMessage() );
58+
if ( VERBOSE )
59+
{
60+
e.printStackTrace();
61+
}
62+
System.exit( 1 );
63+
}
64+
}
65+
66+
private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
67+
throws IOException
68+
{
69+
log( " - Downloading to: " + wrapperJarPath );
70+
if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
71+
{
72+
final String username = System.getenv( "MVNW_USERNAME" );
73+
final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
74+
Authenticator.setDefault( new Authenticator()
75+
{
76+
@Override
77+
protected PasswordAuthentication getPasswordAuthentication()
78+
{
79+
return new PasswordAuthentication( username, password );
80+
}
81+
} );
82+
}
83+
try ( InputStream inStream = wrapperUrl.openStream() )
84+
{
85+
Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
86+
}
87+
log( " - Downloader complete" );
88+
}
89+
90+
private static void log( String msg )
91+
{
92+
if ( VERBOSE )
93+
{
94+
System.out.println( msg );
95+
}
96+
}
97+
98+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

grpc-hello-world-demo/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# quarkus-grpc-hello
2+
3+
This project uses Quarkus, the Supersonic Subatomic Java Framework.
4+
5+
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
6+
7+
## Running the application in dev mode
8+
9+
You can run your application in dev mode that enables live coding using:
10+
```shell script
11+
./mvnw compile quarkus:dev
12+
```
13+
14+
> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
15+
16+
## Packaging and running the application
17+
18+
The application can be packaged using:
19+
```shell script
20+
./mvnw package
21+
```
22+
It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
23+
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.
24+
25+
The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.
26+
27+
If you want to build an _über-jar_, execute the following command:
28+
```shell script
29+
./mvnw package -Dquarkus.package.jar.type=uber-jar
30+
```
31+
32+
The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`.
33+
34+
## Creating a native executable
35+
36+
You can create a native executable using:
37+
```shell script
38+
./mvnw package -Dnative
39+
```
40+
41+
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
42+
```shell script
43+
./mvnw package -Dnative -Dquarkus.native.container-build=true
44+
```
45+
46+
You can then execute your native executable with: `./target/quarkus-grpc-hello-1.0.0-SNAPSHOT-runner`
47+
48+
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.
49+
50+
## Related Guides
51+
52+
53+
## Provided Code
54+
55+
### gRPC
56+
57+
Create your first gRPC service
58+
59+
[Related guide section...](https://quarkus.io/guides/grpc-getting-started)

0 commit comments

Comments
 (0)