Skip to content

Commit 5ed73c0

Browse files
committed
GraalVM sample
1 parent 755752d commit 5ed73c0

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

samples/springboot3/pet-store-native/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RUN ln -s /usr/lib/maven/bin/mvn /usr/bin/mvn
2525
ENV GRADLE_VERSION 7.4.1
2626
ENV GRADLE_FOLDERNAME gradle-${GRADLE_VERSION}
2727
ENV GRADLE_FILENAME gradle-${GRADLE_VERSION}-bin.zip
28-
RUN curl -LO https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
28+
RUN curl -LO https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
2929
RUN unzip gradle-${GRADLE_VERSION}-bin.zip
3030
RUN mv $GRADLE_FOLDERNAME /usr/lib/gradle
3131
RUN ln -s /usr/lib/gradle/bin/gradle /usr/bin/gradle

samples/springboot3/pet-store-native/README.md

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
In this sample, you'll build a native GraalVM image for running web workloads in AWS Lambda.
22

33

4-
## To build the sample on macOS (Apple silicon arm64)
4+
## To build the sample
55

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

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

1212
1. Change into the project directory: `samples/springboot3/pet-store-native`
13-
2. Run the following to build a Docker container image which will be used to create the Lambda function zip file.
13+
2. Run the following to build a Docker container image which will include all the necessary dependencies to build the application
1414
```
15-
docker build -t "al2-graalvm21:native-web" .
15+
docker build -t al2023-graalvm21:native-web .
1616
```
17-
3. Start the container
17+
3. Build the application within the previously created build image
1818
```
19-
docker run -dit -v `pwd`:`pwd` -w `pwd` -v ~/.m2:/root/.m2 al2-graalvm21:native-web
19+
docker run -it -v `pwd`:`pwd` -w `pwd` -v ~/.m2:/root/.m2 al2023-graalvm21:native-web ./mvnw clean -Pnative package -DskipTests
2020
```
21-
4. In Docker, open the image terminal.
22-
23-
> Your working directory should default to the project root. Verify by running `ls` to view the files.
24-
25-
6. From inside the container, build the Lambda function:
26-
```
27-
./mvnw clean -Pnative native:compile -DskipTests
28-
```
29-
30-
After the build finishes, you need to deploy the function.
31-
You can do it manually or you can use SAM (AWS Serverless Application Model) with the included template.yaml file.
32-
If you chose SAM simply execute the following command.
21+
4. After the build finishes, you need to deploy the function:
3322
```
3423
sam deploy --guided
3524
```
36-
This will deploy your application and will attach an AWS API Gateway
37-
Once the deployment is finished you shouild see the following:
25+
26+
This will deploy your application and will attach an AWS API Gateway
27+
Once the deployment is finished you should see the following:
3828
```
3929
Key ServerlessWebNativeApi
4030
Description URL for application

samples/springboot3/pet-store-native/pom.xml

-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@
6969
<configuration>
7070
<jvmArguments>-agentlib:native-image-agent=config-merge-dir=src/main/resources/META-INF/native-image/ --enable-preview
7171
</jvmArguments>
72-
<compilerArguments>--enable-preview
73-
</compilerArguments>
7472
</configuration>
7573
</plugin>
7674
<plugin>

samples/springboot3/pet-store-native/template.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ Resources:
1111
CodeUri: ./target/pet-store-native-0.0.1-SNAPSHOT-native-zip.zip
1212
Handler: NOP
1313
Runtime: provided.al2023
14-
Architectures:
15-
- arm64
14+
# If you want to build for ARM64 uncomment the following lines
15+
# Architectures:
16+
# - arm64
1617
Events:
1718
HttpApiEvent:
1819
Type: HttpApi

0 commit comments

Comments
 (0)