Skip to content

Commit

Permalink
Run native:compile in prepare-package so `spring-native-aws-lambd…
Browse files Browse the repository at this point in the history
…a-function.jar.original` would include `spring-native-aws-lambda-function` file

Signed-off-by: matto <muhamadto@gmail.com>
  • Loading branch information
muhamadto committed Dec 31, 2023
1 parent 0d16e15 commit 0d5d437
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $ ./mvnw -ntp clean verify -U
$ curl --location --request POST 'http://localhost:4566/restapis/<restApiId>/test/_user_request_/test' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "CoffeeBeans"
"body": "{ \"name\": \"CoffeeBeans\" }"
}'
```
The service responds
Expand All @@ -56,7 +56,7 @@ $ ./mvnw -ntp clean verify -U
1. Run the following commands
```shell
$ export SPRING_PROFILES_ACTIVE=local
$ ./mvnw -ntp clean package -U -Pnative -DskipTests native:compile -pl spring-native-aws-lambda-function
$ ./mvnw -ntp clean package -U -Pnative -DskipTests -pl spring-native-aws-lambda-function
$ ./spring-native-aws-lambda-function/target/spring-native-aws-lambda-function
```
The service starts in less than 100 ms
Expand All @@ -77,8 +77,8 @@ $ ./mvnw -ntp clean verify -U
$ curl --location --request POST 'http://localhost:8080' \
--header 'Content-Type: application/json' \
--data-raw '{
"body": "{ \"name\": \"CoffeeBeans\" }"
}'
"body": "{ \"name\": \"CoffeeBeans\" }"
}'
```
The service responds
```json
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ services:
print_info_message "divider" "Package GraalVM function" &&
./mvnw -ntp clean package -U -Pnative -DskipTests native:compile -pl spring-native-aws-lambda-function &&
./mvnw -ntp clean package -U -Pnative -DskipTests -pl spring-native-aws-lambda-function &&
print_info_message "divider" "Creating LAMBDA function" &&
lambda_create_function lambda-FUNCTION provided.al2023 512 ./spring-native-aws-lambda-function/target/spring-native-aws-lambda-function-native-zip.zip spring-native-aws-lambda-function &&
Expand All @@ -64,7 +64,7 @@ services:
apigateway_create_method "$$REST_API_ID" "$$RESOURCE_ID" "POST" &&
apigateway_create_lambda_integration "$$REST_API_ID" "$$RESOURCE_ID" "POST" "arn:aws:apigateway:ap-southeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-southeast-2:000000000000:function:lambda-FUNCTION/invocations" &&
apigateway_create_deployment "$$REST_API_ID" "test" &&
apigateway_list_restapis &&
--rest-api-id &&
print_info_message "plain" "Endpoint available at: http://localhost:4566/restapis/$$REST_API_ID/test/_user_request_/test" &&
Expand Down
11 changes: 10 additions & 1 deletion spring-native-aws-lambda-function/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,23 @@
<buildArg>--verbose</buildArg>
<buildArg>--no-fallback</buildArg>
<buildArg>--enable-preview</buildArg>
<buildArg>--gc=G1</buildArg>
<!-- <buildArg>&#45;&#45;gc=G1</buildArg>-->
<buildArg>-march=native</buildArg>
<buildArg>--strict-image-heap</buildArg>
<buildArg>--enable-url-protocols=http</buildArg>
<buildArg>-H:+AddAllCharsets</buildArg>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
</buildArgs>
</configuration>
<executions>
<execution>
<id>build-native</id>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down

0 comments on commit 0d5d437

Please sign in to comment.