Skip to content

Commit

Permalink
Merge pull request #760 from maschnetwork/main
Browse files Browse the repository at this point in the history
GraalVM sample
  • Loading branch information
deki committed Feb 5, 2024
2 parents 755752d + 5ed73c0 commit c423881
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion samples/springboot3/pet-store-native/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN ln -s /usr/lib/maven/bin/mvn /usr/bin/mvn
ENV GRADLE_VERSION 7.4.1
ENV GRADLE_FOLDERNAME gradle-${GRADLE_VERSION}
ENV GRADLE_FILENAME gradle-${GRADLE_VERSION}-bin.zip
RUN curl -LO https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
RUN curl -LO https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
RUN unzip gradle-${GRADLE_VERSION}-bin.zip
RUN mv $GRADLE_FOLDERNAME /usr/lib/gradle
RUN ln -s /usr/lib/gradle/bin/gradle /usr/bin/gradle
Expand Down
28 changes: 9 additions & 19 deletions samples/springboot3/pet-store-native/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
In this sample, you'll build a native GraalVM image for running web workloads in AWS Lambda.


## To build the sample on macOS (Apple silicon arm64)
## To build the sample

You first need to build the function, then you will deploy it to AWS Lambda.

Expand All @@ -10,31 +10,21 @@ You first need to build the function, then you will deploy it to AWS Lambda.
Before starting the build, you must clone or download the code in **pet-store-native**.

1. Change into the project directory: `samples/springboot3/pet-store-native`
2. Run the following to build a Docker container image which will be used to create the Lambda function zip file.
2. Run the following to build a Docker container image which will include all the necessary dependencies to build the application
```
docker build -t "al2-graalvm21:native-web" .
docker build -t al2023-graalvm21:native-web .
```
3. Start the container
3. Build the application within the previously created build image
```
docker run -dit -v `pwd`:`pwd` -w `pwd` -v ~/.m2:/root/.m2 al2-graalvm21:native-web
docker run -it -v `pwd`:`pwd` -w `pwd` -v ~/.m2:/root/.m2 al2023-graalvm21:native-web ./mvnw clean -Pnative package -DskipTests
```
4. In Docker, open the image terminal.

> Your working directory should default to the project root. Verify by running `ls` to view the files.
6. From inside the container, build the Lambda function:
```
./mvnw clean -Pnative native:compile -DskipTests
```

After the build finishes, you need to deploy the function.
You can do it manually or you can use SAM (AWS Serverless Application Model) with the included template.yaml file.
If you chose SAM simply execute the following command.
4. After the build finishes, you need to deploy the function:
```
sam deploy --guided
```
This will deploy your application and will attach an AWS API Gateway
Once the deployment is finished you shouild see the following:

This will deploy your application and will attach an AWS API Gateway
Once the deployment is finished you should see the following:
```
Key ServerlessWebNativeApi
Description URL for application
Expand Down
2 changes: 0 additions & 2 deletions samples/springboot3/pet-store-native/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
<configuration>
<jvmArguments>-agentlib:native-image-agent=config-merge-dir=src/main/resources/META-INF/native-image/ --enable-preview
</jvmArguments>
<compilerArguments>--enable-preview
</compilerArguments>
</configuration>
</plugin>
<plugin>
Expand Down
5 changes: 3 additions & 2 deletions samples/springboot3/pet-store-native/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ Resources:
CodeUri: ./target/pet-store-native-0.0.1-SNAPSHOT-native-zip.zip
Handler: NOP
Runtime: provided.al2023
Architectures:
- arm64
# If you want to build for ARM64 uncomment the following lines
# Architectures:
# - arm64
Events:
HttpApiEvent:
Type: HttpApi
Expand Down

0 comments on commit c423881

Please sign in to comment.