generated from oracle-devrel/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from paulparkinson/main
init for "Build MultiCloud Devops using Azure CI/CD Pipelines with Oracle Database Cloud Services"
- Loading branch information
Showing
9 changed files
with
441 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,4 @@ | ||
FROM openjdk:17-slim | ||
ADD target/oraclemulticloud-0.0.1-SNAPSHOT.jar oraclemulticloud-0.0.1-SNAPSHOT.jar | ||
EXPOSE 8080 | ||
ENTRYPOINT ["java","-jar","oraclemulticloud-0.0.1-SNAPSHOT.jar"] |
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,103 @@ | ||
# Deploy to Azure Kubernetes Service | ||
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service | ||
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker | ||
|
||
trigger: | ||
- main | ||
|
||
resources: | ||
- repo: self | ||
|
||
variables: | ||
|
||
# Container registry service connection established during pipeline creation | ||
dockerRegistryServiceConnection: 'ba554595-2da8-4cf6-88c4-a57c75966491' | ||
imageRepository: 'multicloudapp' | ||
containerRegistry: 'multicloud.azurecr.io' | ||
dockerfilePath: '**/Dockerfile' | ||
tag: '$(Build.BuildId)' | ||
imagePullSecret: 'multicloud2012b828-auth' | ||
|
||
# Agent VM image name | ||
vmImageName: 'ubuntu-latest' | ||
|
||
# Name of the new namespace being created to deploy the PR changes. | ||
k8sNamespaceForPR: 'review-app-$(System.PullRequest.PullRequestId)' | ||
|
||
stages: | ||
- stage: Build | ||
displayName: Build stage | ||
jobs: | ||
- job: Build | ||
displayName: Build | ||
pool: | ||
vmImage: $(vmImageName) | ||
steps: | ||
- task: JavaToolInstaller@0 | ||
inputs: | ||
versionSpec: '17' | ||
jdkArchitectureOption: 'x64' | ||
jdkSourceOption: 'PreInstalled' | ||
- task: Maven@4 | ||
inputs: | ||
mavenPomFile: 'pom.xml' | ||
publishJUnitResults: true | ||
testResultsFiles: '**/surefire-reports/TEST-*.xml' | ||
javaHomeOption: 'JDKVersion' | ||
mavenVersionOption: '1.17' | ||
mavenAuthenticateFeed: false | ||
effectivePomSkip: false | ||
sonarQubeRunAnalysis: false | ||
- task: Docker@2 | ||
displayName: Build and push an image to container registry | ||
inputs: | ||
command: buildAndPush | ||
repository: $(imageRepository) | ||
dockerfile: $(dockerfilePath) | ||
containerRegistry: $(dockerRegistryServiceConnection) | ||
tags: | | ||
$(tag) | ||
- upload: manifests | ||
artifact: manifests | ||
|
||
|
||
|
||
- stage: Deploy | ||
displayName: Deploy stage | ||
dependsOn: Build | ||
|
||
jobs: | ||
|
||
- deployment: Deploy | ||
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))) | ||
displayName: Deploy | ||
pool: | ||
vmImage: $(vmImageName) | ||
environment: 'paulparkinsonazuredevopsoracledatabase-8684.default' | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- task: KubernetesManifest@0 | ||
displayName: Create imagePullSecret | ||
inputs: | ||
action: createSecret | ||
secretName: $(imagePullSecret) | ||
dockerRegistryEndpoint: $(dockerRegistryServiceConnection) | ||
|
||
- script: | | ||
yq eval '.spec.template.spec.containers[0].env += [{"name": "AZURE_LOG_LEVEL", "value": "verbose"}, {"name": "AZURE_CLIENT_ID", "value": "$(AZURE_CLIENT_ID)"}, {"name": "AZURE_CLIENT_SECRET", "value": "$(AZURE_CLIENT_SECRET)"}, {"name": "AZURE_TENANT_ID", "value": "$(AZURE_TENANT_ID)"}]' -i $(Pipeline.Workspace)/manifests/deployment.yml | ||
displayName: 'Add Environment Variable with yq' | ||
- task: KubernetesManifest@0 | ||
displayName: Deploy to Kubernetes cluster | ||
inputs: | ||
action: deploy | ||
manifests: | | ||
$(Pipeline.Workspace)/manifests/deployment.yml | ||
$(Pipeline.Workspace)/manifests/service.yml | ||
imagePullSecrets: | | ||
$(imagePullSecret) | ||
containers: | | ||
$(containerRegistry)/$(imageRepository):$(tag) | ||
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,103 @@ | ||
# Deploy to Azure Kubernetes Service | ||
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service | ||
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker | ||
|
||
trigger: | ||
- main | ||
|
||
resources: | ||
- repo: self | ||
|
||
variables: | ||
|
||
# Container registry service connection established during pipeline creation | ||
dockerRegistryServiceConnection: 'ba554595-2da8-4cf6-88c4-a57c75966491' | ||
imageRepository: 'multicloudapp' | ||
containerRegistry: 'multicloud.azurecr.io' | ||
dockerfilePath: '**/Dockerfile' | ||
tag: '$(Build.BuildId)' | ||
imagePullSecret: 'multicloud2012b828-auth' | ||
|
||
# Agent VM image name | ||
vmImageName: 'ubuntu-latest' | ||
|
||
# Name of the new namespace being created to deploy the PR changes. | ||
k8sNamespaceForPR: 'review-app-$(System.PullRequest.PullRequestId)' | ||
|
||
stages: | ||
- stage: Build | ||
displayName: Build stage | ||
jobs: | ||
- job: Build | ||
displayName: Build | ||
pool: | ||
vmImage: $(vmImageName) | ||
steps: | ||
- task: JavaToolInstaller@0 | ||
inputs: | ||
versionSpec: '17' | ||
jdkArchitectureOption: 'x64' | ||
jdkSourceOption: 'PreInstalled' | ||
- task: Maven@4 | ||
inputs: | ||
mavenPomFile: 'pom.xml' | ||
publishJUnitResults: true | ||
testResultsFiles: '**/surefire-reports/TEST-*.xml' | ||
javaHomeOption: 'JDKVersion' | ||
mavenVersionOption: '1.17' | ||
mavenAuthenticateFeed: false | ||
effectivePomSkip: false | ||
sonarQubeRunAnalysis: false | ||
- task: Docker@2 | ||
displayName: Build and push an image to container registry | ||
inputs: | ||
command: buildAndPush | ||
repository: $(imageRepository) | ||
dockerfile: $(dockerfilePath) | ||
containerRegistry: $(dockerRegistryServiceConnection) | ||
tags: | | ||
$(tag) | ||
- upload: manifests | ||
artifact: manifests | ||
|
||
|
||
|
||
- stage: Deploy | ||
displayName: Deploy stage | ||
dependsOn: Build | ||
|
||
jobs: | ||
|
||
- deployment: Deploy | ||
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/'))) | ||
displayName: Deploy | ||
pool: | ||
vmImage: $(vmImageName) | ||
environment: 'paulparkinsonazuredevopsoracledatabase-8684.default' | ||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- task: KubernetesManifest@0 | ||
displayName: Create imagePullSecret | ||
inputs: | ||
action: createSecret | ||
secretName: $(imagePullSecret) | ||
dockerRegistryEndpoint: $(dockerRegistryServiceConnection) | ||
|
||
- script: | | ||
yq eval '.spec.template.spec.containers[0].env += [{"name": "AZURE_LOG_LEVEL", "value": "verbose"}, {"name": "AZURE_CLIENT_ID", "value": "$(AZURE_CLIENT_ID)"}, {"name": "AZURE_CLIENT_SECRET", "value": "$(AZURE_CLIENT_SECRET)"}, {"name": "AZURE_TENANT_ID", "value": "$(AZURE_TENANT_ID)"}]' -i $(Pipeline.Workspace)/manifests/deployment.yml | ||
displayName: 'Add Environment Variable with yq' | ||
- task: KubernetesManifest@0 | ||
displayName: Deploy to Kubernetes cluster | ||
inputs: | ||
action: deploy | ||
manifests: | | ||
$(Pipeline.Workspace)/manifests/deployment.yml | ||
$(Pipeline.Workspace)/manifests/service.yml | ||
imagePullSecrets: | | ||
$(imagePullSecret) | ||
containers: | | ||
$(containerRegistry)/$(imageRepository):$(tag) | ||
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,19 @@ | ||
apiVersion : apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: multicloudapp | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: multicloudapp | ||
template: | ||
metadata: | ||
labels: | ||
app: multicloudapp | ||
spec: | ||
containers: | ||
- name: multicloudapp | ||
image: multicloud.azurecr.io/multicloudapp | ||
ports: | ||
- containerPort: 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,10 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: multicloudapp | ||
spec: | ||
type: LoadBalancer | ||
ports: | ||
- port: 8080 | ||
selector: | ||
app: multicloudapp |
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,99 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.1.2</version> | ||
<relativePath/> | ||
</parent> | ||
<groupId>oraclemulticloud</groupId> | ||
<artifactId>oraclemulticloud</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>oraclemulticloud</name> | ||
<description>Oracle MultiCloud Demo App</description> | ||
|
||
<properties> | ||
<oracle.jdbc.version>23.3.0.23.09</oracle.jdbc.version> | ||
<spring.boot.version>3.1.2</spring.boot.version> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-jdbc</artifactId> | ||
<version>6.0.11</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<version>${spring.boot.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc11</artifactId> | ||
<version>${oracle.jdbc.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ucp</artifactId> | ||
<version>${oracle.jdbc.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oracle.database.security</groupId> | ||
<artifactId>oraclepki</artifactId> | ||
<version>${oracle.jdbc.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc-provider-azure</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<release>17</release> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>17</source> | ||
<target>17</target> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
|
||
</project> |
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 @@ | ||
package oraclemulticloud; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class MultiCloudApplication { | ||
|
||
public static final String COMPARTMENT_ID = System.getenv("COMPARTMENT_ID"); | ||
public static final String OBJECTSTORAGE_NAMESPACE = System.getenv("OBJECTSTORAGE_NAMESPACE"); | ||
public static final String OBJECTSTORAGE_BUCKETNAME = System.getenv("OBJECTSTORAGE_BUCKETNAME"); | ||
public static final String ORDS_ENDPOINT_URL = System.getenv("ORDS_ENDPOINT_URL"); | ||
public static final String OCI_VISION_SERVICE_ENDPOINT = System.getenv("OCI_VISION_SERVICE_ENDPOINT"); | ||
public static final String OCI_SPEECH_SERVICE_ENDPOINT = System.getenv("OCI_SPEECH_SERVICE_ENDPOINT"); | ||
public static final String OCI_GENAI_SERVICE_ENDPOINT = System.getenv("OCI_GENAI_SERVICE_ENDPOINT"); | ||
public static final String VISIONAI_XRAY_BREASTCANCER_MODEL_OCID = System.getenv("VISIONAI_XRAY_BREASTCANCER_MODEL_OCID"); | ||
public static final String VISIONAI_XRAY_LUNGCANCER_MODEL_OCID = System.getenv("VISIONAI_XRAY_LUNGCANCER_MODEL_OCID"); | ||
public static final String VISIONAI_XRAY_PNEUMONIA_MODEL_OCID = System.getenv("VISIONAI_XRAY_PNEUMONIA_MODEL_OCID"); | ||
public static final String AZURE_CLIENT_ID = System.getenv("AZURE_CLIENT_ID"); | ||
public static final String AZURE_CLIENT_SECRET = System.getenv("AZURE_CLIENT_SECRET"); | ||
public static final String AZURE_TENANT_ID = System.getenv("AZURE_TENANT_ID"); | ||
|
||
static { | ||
System.out.println("AIApplication.static initializer SPRING_DATASOURCE_USERNAME:" + System.getenv("SPRING_DATASOURCE_USERNAME")); | ||
System.out.println("AIApplication.static initializer spring.datasource.username:" + System.getenv("spring.datasource.username")); | ||
System.out.println("AIApplication.static initializer spring.datasource.url:" + System.getenv("spring.datasource.url")); | ||
System.out.println("AIApplication.static initializer COMPARTMENT_ID:" + COMPARTMENT_ID); | ||
System.out.println("AIApplication.static initializer VISIONAI_XRAY_BREASTCANCER_MODEL_OCID:" + VISIONAI_XRAY_BREASTCANCER_MODEL_OCID); | ||
System.out.println("AIApplication.static initializer VISIONAI_XRAY_LUNGCANCER_MODEL_OCID:" + VISIONAI_XRAY_LUNGCANCER_MODEL_OCID); | ||
System.out.println("AIApplication.static initializer VISIONAI_XRAY_PNEUMONIA_MODEL_OCID:" + VISIONAI_XRAY_PNEUMONIA_MODEL_OCID); | ||
System.out.println("AIApplication.static initializer OBJECTSTORAGE_NAMESPACE:" + OBJECTSTORAGE_NAMESPACE); | ||
System.out.println("AIApplication.static initializer OBJECTSTORAGE_BUCKETNAME:" + OBJECTSTORAGE_BUCKETNAME); | ||
System.out.println("AIApplication.static initializer ORDS_ENDPOINT_URL:" + ORDS_ENDPOINT_URL); | ||
System.out.println("AIApplication.static initializer OCI_VISION_SERVICE_ENDPOINT:" + OCI_VISION_SERVICE_ENDPOINT); | ||
System.out.println("AIApplication.static initializer AZURE_CLIENT_ID:" + AZURE_CLIENT_ID); | ||
System.out.println("AIApplication.static initializer AZURE_CLIENT_SECRET:" + AZURE_CLIENT_SECRET); | ||
System.out.println("AIApplication.static initializer AZURE_TENANT_ID:" + AZURE_TENANT_ID); | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(MultiCloudApplication.class, args); | ||
} | ||
|
||
} |
Oops, something went wrong.