-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code demo-livelab/books-management for Live Lab (#195)
* Adding demo-livelab books-management * Create books-management.zip * Create build-and-push-demo-book-image.yml * Update schema.yaml * Update build-and-push-demo-book-image.yml * Final * Update books-management.zip
- Loading branch information
1 parent
4bee2e0
commit b02f4d8
Showing
38 changed files
with
1,915 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Build and publish Demo Movie container image to GitHub Container Registry | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'demo-livelab/books-management/src/*' | ||
- '.github/workflows/build-and-push-demo-book-image.yml' | ||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE_NAME: demo-nosql-book-example-app | ||
|
||
|
||
jobs: | ||
build-and-push: | ||
name: Build and push Book Demo container image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Repository owner needs to be lowercase | ||
id: repo-owner | ||
run: | | ||
REPO_OWNER="${{ github.repository_owner }}" | ||
echo "repo-owner=${REPO_OWNER,,}" >> "$GITHUB_OUTPUT" | ||
- | ||
name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m')" >> "$GITHUB_OUTPUT" | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Generate container image metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ steps.repo-owner.outputs.repo-owner }}/${{ env.IMAGE_NAME }} | ||
flavor: | | ||
latest=false | ||
tags: | | ||
type=raw,value=latest | ||
type=raw,value=${{ env.TAG }} | ||
env: | ||
TAG: ${{ steps.date.outputs.date }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./demo-livelab/books-management/ | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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,73 @@ | ||
name: Deploy Demo VoD in OCI | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE_NAME: demo-nosql-book-example-app | ||
|
||
jobs: | ||
deploy-oci: | ||
name: Deploy Book Demo in OCI | ||
#needs: push-build-image | ||
runs-on: ubuntu-latest | ||
environment: OCI | ||
env: | ||
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }} | ||
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }} | ||
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }} | ||
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }} | ||
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Retrieve the OCID of a named compartment in tenancy | ||
uses: oracle-actions/run-oci-cli-command@v1.1.1 | ||
id: find-compartment-id | ||
with: | ||
command: 'iam compartment list --compartment-id-in-subtree=true' | ||
query: "data[?name=='davega'].id" | ||
|
||
- name: Set the ddl-table-name | ||
id: ddl-table-name | ||
run: | | ||
DDL_TABLE=$(cat nosql/mbooks-create-table-for-jakarta-nosq-with-frozen.ddl) | ||
DDL_TABLE="${DDL_TABLE//$'\n'/' '}" | ||
DDL_TABLE="${DDL_TABLE//$'\r'/' '}" | ||
echo $DDL_TABLE | ||
echo "ddl-table-name=${DDL_TABLE,,}" >> $GITHUB_OUTPUT | ||
- name: Set the ddl-limits | ||
id: table-limits | ||
run: | | ||
TABLE_LIMITS='{\"maxReadUnits\":50,\"maxStorageInGBs\":25,\"maxWriteUnits\": 50}' | ||
echo $TABLE_LIMITS | ||
echo "table-limits=${TABLE_LIMITS,,}" >> $GITHUB_OUTPUT | ||
- name: Create NoSQL Table | ||
uses: oracle-actions/run-oci-cli-command@v1.1.1 | ||
id: create-table | ||
with: | ||
command: 'nosql table create --compartment-id ${{ steps.find-compartment-id.outputs.raw_output }} --name stream_acct --ddl-statement "${{ steps.ddl-table-name.outputs.ddl-table-name }}" --table-limits "${{ steps.table-limits.outputs.table-limits }}" --wait-for-state SUCCEEDED --wait-for-state FAILED' | ||
|
||
- name: Retrieve the display name and table limits of the NoSQL tables in my compartment | ||
uses: oracle-actions/run-oci-cli-command@v1.1.1 | ||
id: find-tables | ||
with: | ||
command: 'nosql table list --compartment-id ${{ steps.find-compartment-id.outputs.raw_output }}' | ||
query: 'data.items[*].{name:name,tlimits:\"table-limits\"}' | ||
|
||
- name: List the display name and table limits of the NoSQL tables in my compartment | ||
run: | | ||
echo ${{ steps.find-tables.outputs.output }} | jq . | ||
- name: Configure Kubectl for Oracle Container Engine for Kubernetes (OKE) | ||
uses: oracle-actions/configure-kubectl-oke@v1.3 | ||
id: configure-kubectl-oke-action | ||
with: | ||
cluster: ${{ secrets.OKE_CLUSTER_OCID }} | ||
- name: Deploy oracle-app-ndcs-deployment and Get all resources | ||
run: | | ||
kubectl apply -f ./oracle-app-ndcs-deployment.yaml | ||
sleep 120 | ||
kubectl get all |
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 @@ | ||
target/* |
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,6 @@ | ||
#Helidon Project Configuration | ||
#Mon Nov 11 14:29:25 UTC 2024 | ||
schema.version=1.1.0 | ||
helidon.version=4.1.3 | ||
project.flavor=mp | ||
project.archetype=quickstart |
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,39 @@ | ||
|
||
# 1st stage, build the app | ||
FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build | ||
|
||
# Install maven | ||
WORKDIR /usr/share | ||
RUN set -x && \ | ||
curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ | ||
tar -xvf apache-maven-*-bin.tar.gz && \ | ||
rm apache-maven-*-bin.tar.gz && \ | ||
mv apache-maven-* maven && \ | ||
ln -s /usr/share/maven/bin/mvn /bin/ | ||
|
||
WORKDIR /helidon | ||
|
||
# Create a first layer to cache the "Maven World" in the local repository. | ||
# Incremental docker builds will always resume after that, unless you update | ||
# the pom | ||
ADD pom.xml . | ||
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip -Declipselink.weave.skip -DskipOpenApiGenerate | ||
|
||
# Do the Maven build! | ||
# Incremental docker builds will resume here when you change sources | ||
ADD src src | ||
RUN mvn package -DskipTests | ||
|
||
RUN echo "done!" | ||
|
||
# 2nd stage, build the runtime image | ||
FROM container-registry.oracle.com/java/jdk-no-fee-term:21 | ||
WORKDIR /helidon | ||
|
||
# Copy the binary built in the 1st stage | ||
COPY --from=build /helidon/target/books.jar ./ | ||
COPY --from=build /helidon/target/libs ./libs | ||
|
||
CMD ["java", "-jar", "books.jar"] | ||
|
||
EXPOSE 8080 |
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,35 @@ | ||
|
||
# 1st stage, build the app | ||
FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build | ||
|
||
WORKDIR /usr/share | ||
|
||
# Install maven | ||
RUN set -x && \ | ||
curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ | ||
tar -xvf apache-maven-*-bin.tar.gz && \ | ||
rm apache-maven-*-bin.tar.gz && \ | ||
mv apache-maven-* maven && \ | ||
ln -s /usr/share/maven/bin/mvn /bin/ | ||
|
||
WORKDIR /helidon | ||
|
||
# Create a first layer to cache the "Maven World" in the local repository. | ||
# Incremental docker builds will always resume after that, unless you update | ||
# the pom | ||
ADD pom.xml . | ||
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip | ||
|
||
# Do the Maven build to create the custom Java Runtime Image | ||
# Incremental docker builds will resume here when you change sources | ||
ADD src src | ||
RUN mvn package -Pjlink-image -DskipTests | ||
RUN echo "done!" | ||
|
||
# 2nd stage, build the final image with the JRI built in the 1st stage | ||
|
||
FROM debian:stretch-slim | ||
WORKDIR /helidon | ||
COPY --from=build /helidon/target/books-jri ./ | ||
ENTRYPOINT ["/bin/bash", "/helidon/bin/start"] | ||
EXPOSE 8080 |
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,39 @@ | ||
|
||
# 1st stage, build the app | ||
FROM ghcr.io/graalvm/graalvm-community:21.0.0-ol9 as build | ||
|
||
WORKDIR /usr/share | ||
|
||
# Install maven | ||
RUN set -x && \ | ||
curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ | ||
tar -xvf apache-maven-*-bin.tar.gz && \ | ||
rm apache-maven-*-bin.tar.gz && \ | ||
mv apache-maven-* maven && \ | ||
ln -s /usr/share/maven/bin/mvn /bin/ | ||
|
||
WORKDIR /helidon | ||
|
||
# Create a first layer to cache the "Maven World" in the local repository. | ||
# Incremental docker builds will always resume after that, unless you update | ||
# the pom | ||
ADD pom.xml . | ||
RUN mvn package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipselink.weave.skip | ||
|
||
# Do the Maven build! | ||
# Incremental docker builds will resume here when you change sources | ||
ADD src src | ||
RUN mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests | ||
|
||
RUN echo "done!" | ||
|
||
# 2nd stage, build the runtime image | ||
FROM scratch | ||
WORKDIR /helidon | ||
|
||
# Copy the binary built in the 1st stage | ||
COPY --from=build /helidon/target/books . | ||
|
||
ENTRYPOINT ["./books"] | ||
|
||
EXPOSE 8080 |
Oops, something went wrong.