Skip to content

Commit b02f4d8

Browse files
authored
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
1 parent 4bee2e0 commit b02f4d8

38 files changed

+1915
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build and publish Demo Movie container image to GitHub Container Registry
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'demo-livelab/books-management/src/*'
9+
- '.github/workflows/build-and-push-demo-book-image.yml'
10+
workflow_dispatch:
11+
12+
env:
13+
IMAGE_NAME: demo-nosql-book-example-app
14+
15+
16+
jobs:
17+
build-and-push:
18+
name: Build and push Book Demo container image
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
-
23+
name: Checkout
24+
uses: actions/checkout@v4
25+
-
26+
name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
-
29+
name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
-
32+
name: Repository owner needs to be lowercase
33+
id: repo-owner
34+
run: |
35+
REPO_OWNER="${{ github.repository_owner }}"
36+
echo "repo-owner=${REPO_OWNER,,}" >> "$GITHUB_OUTPUT"
37+
-
38+
name: Get current date
39+
id: date
40+
run: echo "date=$(date +'%Y-%m')" >> "$GITHUB_OUTPUT"
41+
-
42+
name: Login to Docker Hub
43+
uses: docker/login-action@v3
44+
with:
45+
registry: ghcr.io
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
-
49+
name: Generate container image metadata
50+
id: meta
51+
uses: docker/metadata-action@v5
52+
with:
53+
images: ghcr.io/${{ steps.repo-owner.outputs.repo-owner }}/${{ env.IMAGE_NAME }}
54+
flavor: |
55+
latest=false
56+
tags: |
57+
type=raw,value=latest
58+
type=raw,value=${{ env.TAG }}
59+
env:
60+
TAG: ${{ steps.date.outputs.date }}
61+
-
62+
name: Build and push
63+
uses: docker/build-push-action@v5
64+
with:
65+
context: ./demo-livelab/books-management/
66+
platforms: linux/amd64,linux/arm64
67+
push: true
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Deploy Demo VoD in OCI
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
IMAGE_NAME: demo-nosql-book-example-app
8+
9+
jobs:
10+
deploy-oci:
11+
name: Deploy Book Demo in OCI
12+
#needs: push-build-image
13+
runs-on: ubuntu-latest
14+
environment: OCI
15+
env:
16+
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
17+
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
18+
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
19+
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
20+
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- name: Retrieve the OCID of a named compartment in tenancy
25+
uses: oracle-actions/[email protected]
26+
id: find-compartment-id
27+
with:
28+
command: 'iam compartment list --compartment-id-in-subtree=true'
29+
query: "data[?name=='davega'].id"
30+
31+
- name: Set the ddl-table-name
32+
id: ddl-table-name
33+
run: |
34+
DDL_TABLE=$(cat nosql/mbooks-create-table-for-jakarta-nosq-with-frozen.ddl)
35+
DDL_TABLE="${DDL_TABLE//$'\n'/' '}"
36+
DDL_TABLE="${DDL_TABLE//$'\r'/' '}"
37+
echo $DDL_TABLE
38+
echo "ddl-table-name=${DDL_TABLE,,}" >> $GITHUB_OUTPUT
39+
40+
- name: Set the ddl-limits
41+
id: table-limits
42+
run: |
43+
TABLE_LIMITS='{\"maxReadUnits\":50,\"maxStorageInGBs\":25,\"maxWriteUnits\": 50}'
44+
echo $TABLE_LIMITS
45+
echo "table-limits=${TABLE_LIMITS,,}" >> $GITHUB_OUTPUT
46+
47+
- name: Create NoSQL Table
48+
uses: oracle-actions/[email protected]
49+
id: create-table
50+
with:
51+
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'
52+
53+
- name: Retrieve the display name and table limits of the NoSQL tables in my compartment
54+
uses: oracle-actions/[email protected]
55+
id: find-tables
56+
with:
57+
command: 'nosql table list --compartment-id ${{ steps.find-compartment-id.outputs.raw_output }}'
58+
query: 'data.items[*].{name:name,tlimits:\"table-limits\"}'
59+
60+
- name: List the display name and table limits of the NoSQL tables in my compartment
61+
run: |
62+
echo ${{ steps.find-tables.outputs.output }} | jq .
63+
64+
- name: Configure Kubectl for Oracle Container Engine for Kubernetes (OKE)
65+
uses: oracle-actions/[email protected]
66+
id: configure-kubectl-oke-action
67+
with:
68+
cluster: ${{ secrets.OKE_CLUSTER_OCID }}
69+
- name: Deploy oracle-app-ndcs-deployment and Get all resources
70+
run: |
71+
kubectl apply -f ./oracle-app-ndcs-deployment.yaml
72+
sleep 120
73+
kubectl get all
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/*
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Helidon Project Configuration
2+
#Mon Nov 11 14:29:25 UTC 2024
3+
schema.version=1.1.0
4+
helidon.version=4.1.3
5+
project.flavor=mp
6+
project.archetype=quickstart
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
# 1st stage, build the app
3+
FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build
4+
5+
# Install maven
6+
WORKDIR /usr/share
7+
RUN set -x && \
8+
curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \
9+
tar -xvf apache-maven-*-bin.tar.gz && \
10+
rm apache-maven-*-bin.tar.gz && \
11+
mv apache-maven-* maven && \
12+
ln -s /usr/share/maven/bin/mvn /bin/
13+
14+
WORKDIR /helidon
15+
16+
# Create a first layer to cache the "Maven World" in the local repository.
17+
# Incremental docker builds will always resume after that, unless you update
18+
# the pom
19+
ADD pom.xml .
20+
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip -Declipselink.weave.skip -DskipOpenApiGenerate
21+
22+
# Do the Maven build!
23+
# Incremental docker builds will resume here when you change sources
24+
ADD src src
25+
RUN mvn package -DskipTests
26+
27+
RUN echo "done!"
28+
29+
# 2nd stage, build the runtime image
30+
FROM container-registry.oracle.com/java/jdk-no-fee-term:21
31+
WORKDIR /helidon
32+
33+
# Copy the binary built in the 1st stage
34+
COPY --from=build /helidon/target/books.jar ./
35+
COPY --from=build /helidon/target/libs ./libs
36+
37+
CMD ["java", "-jar", "books.jar"]
38+
39+
EXPOSE 8080
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
# 1st stage, build the app
3+
FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build
4+
5+
WORKDIR /usr/share
6+
7+
# Install maven
8+
RUN set -x && \
9+
curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \
10+
tar -xvf apache-maven-*-bin.tar.gz && \
11+
rm apache-maven-*-bin.tar.gz && \
12+
mv apache-maven-* maven && \
13+
ln -s /usr/share/maven/bin/mvn /bin/
14+
15+
WORKDIR /helidon
16+
17+
# Create a first layer to cache the "Maven World" in the local repository.
18+
# Incremental docker builds will always resume after that, unless you update
19+
# the pom
20+
ADD pom.xml .
21+
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip
22+
23+
# Do the Maven build to create the custom Java Runtime Image
24+
# Incremental docker builds will resume here when you change sources
25+
ADD src src
26+
RUN mvn package -Pjlink-image -DskipTests
27+
RUN echo "done!"
28+
29+
# 2nd stage, build the final image with the JRI built in the 1st stage
30+
31+
FROM debian:stretch-slim
32+
WORKDIR /helidon
33+
COPY --from=build /helidon/target/books-jri ./
34+
ENTRYPOINT ["/bin/bash", "/helidon/bin/start"]
35+
EXPOSE 8080
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
# 1st stage, build the app
3+
FROM ghcr.io/graalvm/graalvm-community:21.0.0-ol9 as build
4+
5+
WORKDIR /usr/share
6+
7+
# Install maven
8+
RUN set -x && \
9+
curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \
10+
tar -xvf apache-maven-*-bin.tar.gz && \
11+
rm apache-maven-*-bin.tar.gz && \
12+
mv apache-maven-* maven && \
13+
ln -s /usr/share/maven/bin/mvn /bin/
14+
15+
WORKDIR /helidon
16+
17+
# Create a first layer to cache the "Maven World" in the local repository.
18+
# Incremental docker builds will always resume after that, unless you update
19+
# the pom
20+
ADD pom.xml .
21+
RUN mvn package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipselink.weave.skip
22+
23+
# Do the Maven build!
24+
# Incremental docker builds will resume here when you change sources
25+
ADD src src
26+
RUN mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests
27+
28+
RUN echo "done!"
29+
30+
# 2nd stage, build the runtime image
31+
FROM scratch
32+
WORKDIR /helidon
33+
34+
# Copy the binary built in the 1st stage
35+
COPY --from=build /helidon/target/books .
36+
37+
ENTRYPOINT ["./books"]
38+
39+
EXPOSE 8080

0 commit comments

Comments
 (0)