-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new sample for native web workloads #748
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
samples/springboot3/function-sample-aws-serverless-web-native/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
Binary file added
BIN
+61.1 KB
samples/springboot3/function-sample-aws-serverless-web-native/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions
18
...ringboot3/function-sample-aws-serverless-web-native/.mvn/wrapper/maven-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip | ||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar |
46 changes: 46 additions & 0 deletions
46
samples/springboot3/function-sample-aws-serverless-web-native/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM arm64v8/amazonlinux:2 | ||
|
||
RUN yum -y update \ | ||
&& yum install -y tar unzip gzip bzip2-devel ed gcc gcc-c++ gcc-gfortran \ | ||
less libcurl-devel openssl openssl-devel readline-devel xz-devel \ | ||
zlib-devel glibc-static libcxx libcxx-devel llvm-toolset-7 zlib-static \ | ||
&& rm -rf /var/cache/yum | ||
|
||
#ENV GRAAL_VERSION 22.3.1 | ||
ENV GRAAL_FOLDERNAME graalvm-community-openjdk-21.0.1+12.1 | ||
#ENV GRAAL_FILENAME graalvm-community-jdk-21.0.1_linux-x64_bin.tar.gz | ||
|
||
RUN curl -4 -L https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.1/graalvm-community-jdk-21.0.1_linux-aarch64_bin.tar.gz | tar -xvz | ||
RUN mv $GRAAL_FOLDERNAME /usr/lib/graalvm | ||
RUN rm -rf $GRAAL_FOLDERNAME | ||
|
||
# Graal maven plugin requires Maven 3.3.x | ||
ENV MVN_VERSION 3.6.3 | ||
ENV MVN_FOLDERNAME apache-maven-${MVN_VERSION} | ||
ENV MVN_FILENAME apache-maven-${MVN_VERSION}-bin.tar.gz | ||
RUN curl -4 -L https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/${MVN_VERSION}/${MVN_FILENAME} | tar -xvz | ||
RUN mv $MVN_FOLDERNAME /usr/lib/maven | ||
RUN rm -rf $MVN_FOLDERNAME | ||
|
||
# Gradle | ||
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 unzip gradle-${GRADLE_VERSION}-bin.zip | ||
RUN mv $GRADLE_FOLDERNAME /usr/lib/gradle | ||
RUN rm -rf $GRADLE_FOLDERNAME | ||
|
||
VOLUME /project | ||
WORKDIR /project | ||
|
||
|
||
|
||
#RUN /usr/lib/graalvm/bin/gu install native-image | ||
#RUN ln -s /usr/lib/graalvm/bin/native-image /usr/bin/native-image | ||
RUN ln -s /usr/lib/maven/bin/mvn /usr/bin/mvn | ||
RUN ln -s /usr/lib/gradle/bin/gradle /usr/bin/gradle | ||
|
||
ENV JAVA_HOME /usr/lib/graalvm | ||
|
||
WORKDIR /function-sample-aws-native |
44 changes: 44 additions & 0 deletions
44
samples/springboot3/function-sample-aws-serverless-web-native/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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) | ||
|
||
You first need to build the function, then you will deploy it to AWS Lambda. | ||
|
||
### Step 1 - Build the native image | ||
|
||
Before starting the build, you must clone or download the code in **function-sample-aws-native**. | ||
|
||
1. Change into the project directory: `samples/springboot3/function-sample-aws-serverless-web-native` | ||
2. Run the following to build a Docker container image which will be used to create the Lambda function zip file. | ||
``` | ||
docker build -t "al2-graalvm21:native-function" . | ||
``` | ||
3. Start the container | ||
``` | ||
docker run -dit -v `pwd`:`pwd` -w `pwd` -v ~/.m2:/root/.m2 al2-graalvm21:native-function | ||
``` | ||
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. | ||
``` | ||
sam depploy --guided | ||
olegz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
This will deploy your application and will attach an AWS API Gateway | ||
Once the deployment is finished you shouild see the following: | ||
``` | ||
Key ServerlessWebNativeApi | ||
Description URL for application | ||
Value https://xxxxxxxx.execute-api.us-east-2.amazonaws.com/pets | ||
``` | ||
|
||
You can now simply execute GET on this URL and see the listing fo all pets. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use Amazon Linux 2023 and GraalVM 21.0.2
my working version:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update