-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add springboot buildpack/builder (#46)
* fix: add springboot buildpack/builder SpringBoot Buildpack and Builder for building Spring Cloud Functions fix: #45 * removed extra spaces in stack
- Loading branch information
1 parent
00c5e8b
commit 141f6c5
Showing
8 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
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
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,16 @@ | ||
# Buildpacks to include in builder | ||
[[buildpacks]] | ||
id = "com.redhat.faas.springboot" | ||
image = "quay.io/boson/faas-springboot-bp:{{VERSION}}" | ||
|
||
[[order]] | ||
[[order.group]] | ||
id = "com.redhat.faas.springboot" | ||
|
||
# Stack that will be used by the builder | ||
[stack] | ||
id = "com.redhat.faas.stacks.springboot" | ||
# This image is used at runtime | ||
run-image = "quay.io/boson/faas-stack-run:springboot-{{VERSION}}" | ||
# This image is used at build-time | ||
build-image = "quay.io/boson/faas-stack-build:springboot-{{VERSION}}" |
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,47 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
set -o pipefail | ||
|
||
echo "$@" | ||
|
||
echo "---> Spring Cloud Functions Buildpack" | ||
|
||
build_dir=$(pwd) | ||
bp_dir=$(cd "$(dirname "$0")"/..; pwd) | ||
layers_dir=$1 | ||
platform_dir=$2 | ||
|
||
|
||
mvn_repo_layer="${layers_dir}/mvn_repo" | ||
|
||
mkdir -p "${mvn_repo_layer}" | ||
cat <<TOML > "${mvn_repo_layer}.toml" | ||
launch = false | ||
build = true | ||
cache = true | ||
TOML | ||
|
||
mvn -B -Dmaven.repo.local="${mvn_repo_layer}" package -DskipTests | ||
|
||
runner_jar=$(find target -maxdepth 1 -iname "*.jar") | ||
|
||
app_layer="${layers_dir}/app" | ||
mkdir -p "${app_layer}" | ||
|
||
cp -v "${runner_jar}" "${app_layer}/app.jar" | ||
|
||
cat <<TOML > "${app_layer}.toml" | ||
launch = true | ||
build = false | ||
cache = false | ||
TOML | ||
|
||
cp "${runner_jar}" "${app_layer}/app.jar" | ||
|
||
rm -fr target src pom.xml | ||
|
||
cat <<TOML > "${layers_dir}/launch.toml" | ||
[[processes]] | ||
type = "web" | ||
command = "JAVA_APP_DIR=${app_layer} run-java.sh" | ||
TOML |
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,11 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
dep_xpath='/*[local-name()="project"]' | ||
dep_xpath+='/*[local-name()="dependencies"]' | ||
dep_xpath+='/*[local-name()="dependency"]' | ||
dep_xpath+='/*[local-name()="artifactId" and contains(.,"spring-cloud-starter-function-web")]' | ||
|
||
if ! xmllint --xpath "${dep_xpath}" pom.xml > /dev/null 2> /dev/null; then | ||
exit 100 | ||
fi |
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,9 @@ | ||
api = "0.2" | ||
|
||
[buildpack] | ||
id = "com.redhat.faas.springboot" | ||
version = "0.0.1" | ||
name = "Spring Cloud Functions Buildpack" | ||
|
||
[[stacks]] | ||
id = "com.redhat.faas.stacks.springboot" |
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,2 @@ | ||
[buildpack] | ||
uri = "../../buildpacks/springboot" |
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,20 @@ | ||
ARG version=tip | ||
FROM quay.io/boson/faas-stack-build:ubi8-${version} | ||
|
||
ARG stack_id | ||
ENV CNB_STACK_ID=${stack_id} | ||
LABEL io.buildpacks.stack.id=${stack_id} | ||
|
||
ENV HOME /projects/spring-cloud-function | ||
WORKDIR $HOME | ||
|
||
USER root | ||
|
||
RUN dnf module install -y maven:3.6 \ | ||
&& dnf install -y wget maven tar gzip java-11-openjdk-headless \ | ||
&& dnf update -y \ | ||
&& dnf clean all -y \ | ||
&& chown cnb:cnb $HOME | ||
|
||
USER cnb | ||
|
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 @@ | ||
ARG version=tip | ||
FROM quay.io/boson/faas-stack-run:ubi8-minimal-${version} | ||
|
||
ARG stack_id | ||
ENV CNB_STACK_ID=${stack_id} | ||
LABEL io.buildpacks.stack.id=${stack_id} | ||
|
||
ENV HOME /projects/spring-cloud-function | ||
WORKDIR $HOME | ||
USER root | ||
|
||
ARG JAVA_PACKAGE=java-11-openjdk-headless | ||
ARG RUN_JAVA_VERSION=1.3.8 | ||
|
||
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' | ||
|
||
# Install java and the run-java script | ||
# Also set up permissions for user `1001` | ||
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ | ||
&& microdnf update \ | ||
&& microdnf clean all \ | ||
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /usr/local/bin/run-java.sh \ | ||
&& chmod "a+rx" /usr/local/bin/run-java.sh \ | ||
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security \ | ||
&& chown cnb:cnb $HOME | ||
|
||
|
||
USER cnb | ||
|
||
ENV PORT 8080 | ||
|
||
EXPOSE 8080 | ||
EXPOSE 5005 |