{"id":15805225,"url":"https://github.com/ddobrin/java-trace-spring-google-native-client-lib","last_synced_at":"2025-03-31T22:11:39.769Z","repository":{"id":50349493,"uuid":"518841787","full_name":"ddobrin/java-trace-spring-google-native-client-lib","owner":"ddobrin","description":"A simple Spring app leveraging Google Native Java Client Libraries","archived":false,"fork":false,"pushed_at":"2022-08-03T11:53:09.000Z","size":63,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-06T02:05:40.202Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddobrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-28T12:42:15.000Z","updated_at":"2022-08-02T19:53:27.000Z","dependencies_parsed_at":"2022-08-17T15:00:50.781Z","dependency_job_id":null,"html_url":"https://github.com/ddobrin/java-trace-spring-google-native-client-lib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fjava-trace-spring-google-native-client-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fjava-trace-spring-google-native-client-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fjava-trace-spring-google-native-client-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fjava-trace-spring-google-native-client-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddobrin","download_url":"https://codeload.github.com/ddobrin/java-trace-spring-google-native-client-lib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246547369,"owners_count":20794970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T02:05:12.060Z","updated_at":"2025-03-31T22:11:39.743Z","avatar_url":"https://github.com/ddobrin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# java-trace-spring-google-native-client-lib\nThis sample intends to show how you can build a [Spring Native](https://docs.spring.io/spring-native/docs/0.12.1/reference/htmlsingle/#overview) application leveraging the [Google Cloud Client Libraries for Java](https://cloud.google.com/java/docs/compile-native-images) support for native images.\n\nThe sample is based on the [Cloud Trace Sample](https://github.com/googleapis/java-trace), with instructions to deploy to [Cloud Run](https://cloud.google.com/run) provided.\n\nConfiguration:\n* Java 17\n* Spring Native 0.12.2\n\n## Runtimes\nThis project has been configured to let you generate either a lightweight container or a native executable.\n\n## Native Executable with Native Build Tools\nUse this option if you want to explore more options such as running your tests in a native image.\n\nThe GraalVM native-image compiler should be installed and configured on your machine, see [the Getting Started section of the reference guide](https://docs.spring.io/spring-native/docs/0.12.1/reference/htmlsingle/#getting-started-native-build-tools).\n\nTo create the executable, run the following goal:\n\n```\n$ ./mvnw package -Pnative\n```\n\nThen, you can run the app as follows:\n```\n$ ./target/google-cloud-trace-samples\n```\n\nRun native tests using:\n```\n$ ./target/native-tests\n```\n\n## Lightweight Container with Cloud Native Buildpacks\n\nDocker should be installed and configured on your machine prior to creating the image, see [the Getting Started section of the reference guide](https://docs.spring.io/spring-native/docs/0.12.1/reference/htmlsingle/#getting-started-buildpacks).\n\nTo create the image, run the following goal:\n\n```\n$ ./mvnw spring-boot:build-image\n```\n\nThen, you can run the app like any other container\n\n```\n$ docker run --rm google-cloud-trace-samples:0.0.1-SNAPSHOT\n```\n\nYou can observe a failure, due to missing Google Cloud Credentials, therefore deploy it to Cloud Run:\n```\n# authorize the user to GCP\ngcloud auth list\n\n# check if the project is set\ngcloud config list\n\n...\nproject = optimize-serverless-apps\n...\n\n# set project ID if not already set\ngcloud config set project \u003cproject id\u003e\n# ex:\ngcloud config set project optimize-serverless-apps\n\n# tag the images and push them to the Container Registry \ndocker tag google-cloud-trace-samples:0.0.1-SNAPSHOT gcr.io/optimize-serverless-apps/google-cloud-trace-samples\n\n# push the image(s) to the Container Registry\ndocker push gcr.io/optimize-serverless-apps/google-cloud-trace-samples\n\n# deploy the container to CloudRun\n# Note that we are specifying:\n#    app name - hello-function\n#    region - us-central1\n#    memory allocated for the process - 1Gi\n#    simple apps allow all users, unauthenticated, best practice is to set service accounts up\n\n# deploy the Native Image to Cloud Run\ngcloud run deploy google-cloud-trace-samples \\\n  --image=gcr.io/optimize-serverless-apps/google-cloud-trace-samples \\\n  --region us-central1 \\\n  --memory 1Gi --allow-unauthenticated\n\n# validate the deployment\ngcloud run services list\n   SERVICE                     REGION        URL                                                         LAST DEPLOYED BY    LAST DEPLOYED AT\n✔  google-cloud-trace-samples  us-central1   https://google-cloud-trace-samples-...-uc.a.run.app         ......              2022-07-28T22:42:56.695734Z\n\n# run a request  and wait for some traces to be generated\ncurl https://google-cloud-trace-samples-...-uc.a.run.app\n```\n\n### Reference Documentation\nFor further reference, please consider the following sections:\n\n* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)\n* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.7.2/maven-plugin/reference/html/)\n* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.7.2/maven-plugin/reference/html/#build-image)\n* [Spring Native Reference Guide](https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/)\n\n### Additional Links\nThese additional references should also help you:\n\n* [Configure the Spring AOT Plugin](https://docs.spring.io/spring-native/docs/0.12.1/reference/htmlsingle/#spring-aot-maven)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddobrin%2Fjava-trace-spring-google-native-client-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddobrin%2Fjava-trace-spring-google-native-client-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddobrin%2Fjava-trace-spring-google-native-client-lib/lists"}