Skip to content

Commit b0c5e45

Browse files
authored
Merge pull request #1 from paulparkinson/main
init for "Build MultiCloud Devops using Azure CI/CD Pipelines with Oracle Database Cloud Services"
2 parents 932e12e + 4d8e243 commit b0c5e45

File tree

9 files changed

+441
-0
lines changed

9 files changed

+441
-0
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM openjdk:17-slim
2+
ADD target/oraclemulticloud-0.0.1-SNAPSHOT.jar oraclemulticloud-0.0.1-SNAPSHOT.jar
3+
EXPOSE 8080
4+
ENTRYPOINT ["java","-jar","oraclemulticloud-0.0.1-SNAPSHOT.jar"]

azure-pipelines-example.yaml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Deploy to Azure Kubernetes Service
2+
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
3+
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
4+
5+
trigger:
6+
- main
7+
8+
resources:
9+
- repo: self
10+
11+
variables:
12+
13+
# Container registry service connection established during pipeline creation
14+
dockerRegistryServiceConnection: 'ba554595-2da8-4cf6-88c4-a57c75966491'
15+
imageRepository: 'multicloudapp'
16+
containerRegistry: 'multicloud.azurecr.io'
17+
dockerfilePath: '**/Dockerfile'
18+
tag: '$(Build.BuildId)'
19+
imagePullSecret: 'multicloud2012b828-auth'
20+
21+
# Agent VM image name
22+
vmImageName: 'ubuntu-latest'
23+
24+
# Name of the new namespace being created to deploy the PR changes.
25+
k8sNamespaceForPR: 'review-app-$(System.PullRequest.PullRequestId)'
26+
27+
stages:
28+
- stage: Build
29+
displayName: Build stage
30+
jobs:
31+
- job: Build
32+
displayName: Build
33+
pool:
34+
vmImage: $(vmImageName)
35+
steps:
36+
- task: JavaToolInstaller@0
37+
inputs:
38+
versionSpec: '17'
39+
jdkArchitectureOption: 'x64'
40+
jdkSourceOption: 'PreInstalled'
41+
- task: Maven@4
42+
inputs:
43+
mavenPomFile: 'pom.xml'
44+
publishJUnitResults: true
45+
testResultsFiles: '**/surefire-reports/TEST-*.xml'
46+
javaHomeOption: 'JDKVersion'
47+
mavenVersionOption: '1.17'
48+
mavenAuthenticateFeed: false
49+
effectivePomSkip: false
50+
sonarQubeRunAnalysis: false
51+
- task: Docker@2
52+
displayName: Build and push an image to container registry
53+
inputs:
54+
command: buildAndPush
55+
repository: $(imageRepository)
56+
dockerfile: $(dockerfilePath)
57+
containerRegistry: $(dockerRegistryServiceConnection)
58+
tags: |
59+
$(tag)
60+
61+
- upload: manifests
62+
artifact: manifests
63+
64+
65+
66+
- stage: Deploy
67+
displayName: Deploy stage
68+
dependsOn: Build
69+
70+
jobs:
71+
72+
- deployment: Deploy
73+
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
74+
displayName: Deploy
75+
pool:
76+
vmImage: $(vmImageName)
77+
environment: 'paulparkinsonazuredevopsoracledatabase-8684.default'
78+
strategy:
79+
runOnce:
80+
deploy:
81+
steps:
82+
- task: KubernetesManifest@0
83+
displayName: Create imagePullSecret
84+
inputs:
85+
action: createSecret
86+
secretName: $(imagePullSecret)
87+
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
88+
89+
- script: |
90+
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
91+
displayName: 'Add Environment Variable with yq'
92+
- task: KubernetesManifest@0
93+
displayName: Deploy to Kubernetes cluster
94+
inputs:
95+
action: deploy
96+
manifests: |
97+
$(Pipeline.Workspace)/manifests/deployment.yml
98+
$(Pipeline.Workspace)/manifests/service.yml
99+
imagePullSecrets: |
100+
$(imagePullSecret)
101+
containers: |
102+
$(containerRegistry)/$(imageRepository):$(tag)
103+

azure-pipelines.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Deploy to Azure Kubernetes Service
2+
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
3+
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
4+
5+
trigger:
6+
- main
7+
8+
resources:
9+
- repo: self
10+
11+
variables:
12+
13+
# Container registry service connection established during pipeline creation
14+
dockerRegistryServiceConnection: 'ba554595-2da8-4cf6-88c4-a57c75966491'
15+
imageRepository: 'multicloudapp'
16+
containerRegistry: 'multicloud.azurecr.io'
17+
dockerfilePath: '**/Dockerfile'
18+
tag: '$(Build.BuildId)'
19+
imagePullSecret: 'multicloud2012b828-auth'
20+
21+
# Agent VM image name
22+
vmImageName: 'ubuntu-latest'
23+
24+
# Name of the new namespace being created to deploy the PR changes.
25+
k8sNamespaceForPR: 'review-app-$(System.PullRequest.PullRequestId)'
26+
27+
stages:
28+
- stage: Build
29+
displayName: Build stage
30+
jobs:
31+
- job: Build
32+
displayName: Build
33+
pool:
34+
vmImage: $(vmImageName)
35+
steps:
36+
- task: JavaToolInstaller@0
37+
inputs:
38+
versionSpec: '17'
39+
jdkArchitectureOption: 'x64'
40+
jdkSourceOption: 'PreInstalled'
41+
- task: Maven@4
42+
inputs:
43+
mavenPomFile: 'pom.xml'
44+
publishJUnitResults: true
45+
testResultsFiles: '**/surefire-reports/TEST-*.xml'
46+
javaHomeOption: 'JDKVersion'
47+
mavenVersionOption: '1.17'
48+
mavenAuthenticateFeed: false
49+
effectivePomSkip: false
50+
sonarQubeRunAnalysis: false
51+
- task: Docker@2
52+
displayName: Build and push an image to container registry
53+
inputs:
54+
command: buildAndPush
55+
repository: $(imageRepository)
56+
dockerfile: $(dockerfilePath)
57+
containerRegistry: $(dockerRegistryServiceConnection)
58+
tags: |
59+
$(tag)
60+
61+
- upload: manifests
62+
artifact: manifests
63+
64+
65+
66+
- stage: Deploy
67+
displayName: Deploy stage
68+
dependsOn: Build
69+
70+
jobs:
71+
72+
- deployment: Deploy
73+
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
74+
displayName: Deploy
75+
pool:
76+
vmImage: $(vmImageName)
77+
environment: 'paulparkinsonazuredevopsoracledatabase-8684.default'
78+
strategy:
79+
runOnce:
80+
deploy:
81+
steps:
82+
- task: KubernetesManifest@0
83+
displayName: Create imagePullSecret
84+
inputs:
85+
action: createSecret
86+
secretName: $(imagePullSecret)
87+
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
88+
89+
- script: |
90+
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
91+
displayName: 'Add Environment Variable with yq'
92+
- task: KubernetesManifest@0
93+
displayName: Deploy to Kubernetes cluster
94+
inputs:
95+
action: deploy
96+
manifests: |
97+
$(Pipeline.Workspace)/manifests/deployment.yml
98+
$(Pipeline.Workspace)/manifests/service.yml
99+
imagePullSecrets: |
100+
$(imagePullSecret)
101+
containers: |
102+
$(containerRegistry)/$(imageRepository):$(tag)
103+

manifests/deployment.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion : apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: multicloudapp
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: multicloudapp
10+
template:
11+
metadata:
12+
labels:
13+
app: multicloudapp
14+
spec:
15+
containers:
16+
- name: multicloudapp
17+
image: multicloud.azurecr.io/multicloudapp
18+
ports:
19+
- containerPort: 8080

manifests/service.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: multicloudapp
5+
spec:
6+
type: LoadBalancer
7+
ports:
8+
- port: 8080
9+
selector:
10+
app: multicloudapp

pom.xml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>3.1.2</version>
9+
<relativePath/>
10+
</parent>
11+
<groupId>oraclemulticloud</groupId>
12+
<artifactId>oraclemulticloud</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>oraclemulticloud</name>
15+
<description>Oracle MultiCloud Demo App</description>
16+
17+
<properties>
18+
<oracle.jdbc.version>23.3.0.23.09</oracle.jdbc.version>
19+
<spring.boot.version>3.1.2</spring.boot.version>
20+
<maven.compiler.source>17</maven.compiler.source>
21+
<maven.compiler.target>17</maven.compiler.target>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-web</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.springframework</groupId>
31+
<artifactId>spring-jdbc</artifactId>
32+
<version>6.0.11</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter-web</artifactId>
37+
<version>${spring.boot.version}</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-starter-test</artifactId>
42+
<version>${spring.boot.version}</version>
43+
<scope>test</scope>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>com.oracle.database.jdbc</groupId>
48+
<artifactId>ojdbc11</artifactId>
49+
<version>${oracle.jdbc.version}</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>com.oracle.database.jdbc</groupId>
53+
<artifactId>ucp</artifactId>
54+
<version>${oracle.jdbc.version}</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>com.oracle.database.security</groupId>
58+
<artifactId>oraclepki</artifactId>
59+
<version>${oracle.jdbc.version}</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>com.oracle.database.jdbc</groupId>
63+
<artifactId>ojdbc-provider-azure</artifactId>
64+
<version>1.0.0</version>
65+
</dependency>
66+
67+
</dependencies>
68+
<build>
69+
<plugins>
70+
<plugin>
71+
<groupId>org.springframework.boot</groupId>
72+
<artifactId>spring-boot-maven-plugin</artifactId>
73+
</plugin>
74+
<plugin>
75+
<groupId>org.apache.maven.plugins</groupId>
76+
<artifactId>maven-compiler-plugin</artifactId>
77+
<version>3.8.1</version>
78+
<configuration>
79+
<release>17</release>
80+
</configuration>
81+
</plugin>
82+
83+
<plugin>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-maven-plugin</artifactId>
86+
</plugin>
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-compiler-plugin</artifactId>
90+
<configuration>
91+
<source>17</source>
92+
<target>17</target>
93+
</configuration>
94+
</plugin>
95+
96+
</plugins>
97+
</build>
98+
99+
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package oraclemulticloud;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class MultiCloudApplication {
8+
9+
public static final String COMPARTMENT_ID = System.getenv("COMPARTMENT_ID");
10+
public static final String OBJECTSTORAGE_NAMESPACE = System.getenv("OBJECTSTORAGE_NAMESPACE");
11+
public static final String OBJECTSTORAGE_BUCKETNAME = System.getenv("OBJECTSTORAGE_BUCKETNAME");
12+
public static final String ORDS_ENDPOINT_URL = System.getenv("ORDS_ENDPOINT_URL");
13+
public static final String OCI_VISION_SERVICE_ENDPOINT = System.getenv("OCI_VISION_SERVICE_ENDPOINT");
14+
public static final String OCI_SPEECH_SERVICE_ENDPOINT = System.getenv("OCI_SPEECH_SERVICE_ENDPOINT");
15+
public static final String OCI_GENAI_SERVICE_ENDPOINT = System.getenv("OCI_GENAI_SERVICE_ENDPOINT");
16+
public static final String VISIONAI_XRAY_BREASTCANCER_MODEL_OCID = System.getenv("VISIONAI_XRAY_BREASTCANCER_MODEL_OCID");
17+
public static final String VISIONAI_XRAY_LUNGCANCER_MODEL_OCID = System.getenv("VISIONAI_XRAY_LUNGCANCER_MODEL_OCID");
18+
public static final String VISIONAI_XRAY_PNEUMONIA_MODEL_OCID = System.getenv("VISIONAI_XRAY_PNEUMONIA_MODEL_OCID");
19+
public static final String AZURE_CLIENT_ID = System.getenv("AZURE_CLIENT_ID");
20+
public static final String AZURE_CLIENT_SECRET = System.getenv("AZURE_CLIENT_SECRET");
21+
public static final String AZURE_TENANT_ID = System.getenv("AZURE_TENANT_ID");
22+
23+
static {
24+
System.out.println("AIApplication.static initializer SPRING_DATASOURCE_USERNAME:" + System.getenv("SPRING_DATASOURCE_USERNAME"));
25+
System.out.println("AIApplication.static initializer spring.datasource.username:" + System.getenv("spring.datasource.username"));
26+
System.out.println("AIApplication.static initializer spring.datasource.url:" + System.getenv("spring.datasource.url"));
27+
System.out.println("AIApplication.static initializer COMPARTMENT_ID:" + COMPARTMENT_ID);
28+
System.out.println("AIApplication.static initializer VISIONAI_XRAY_BREASTCANCER_MODEL_OCID:" + VISIONAI_XRAY_BREASTCANCER_MODEL_OCID);
29+
System.out.println("AIApplication.static initializer VISIONAI_XRAY_LUNGCANCER_MODEL_OCID:" + VISIONAI_XRAY_LUNGCANCER_MODEL_OCID);
30+
System.out.println("AIApplication.static initializer VISIONAI_XRAY_PNEUMONIA_MODEL_OCID:" + VISIONAI_XRAY_PNEUMONIA_MODEL_OCID);
31+
System.out.println("AIApplication.static initializer OBJECTSTORAGE_NAMESPACE:" + OBJECTSTORAGE_NAMESPACE);
32+
System.out.println("AIApplication.static initializer OBJECTSTORAGE_BUCKETNAME:" + OBJECTSTORAGE_BUCKETNAME);
33+
System.out.println("AIApplication.static initializer ORDS_ENDPOINT_URL:" + ORDS_ENDPOINT_URL);
34+
System.out.println("AIApplication.static initializer OCI_VISION_SERVICE_ENDPOINT:" + OCI_VISION_SERVICE_ENDPOINT);
35+
System.out.println("AIApplication.static initializer AZURE_CLIENT_ID:" + AZURE_CLIENT_ID);
36+
System.out.println("AIApplication.static initializer AZURE_CLIENT_SECRET:" + AZURE_CLIENT_SECRET);
37+
System.out.println("AIApplication.static initializer AZURE_TENANT_ID:" + AZURE_TENANT_ID);
38+
}
39+
40+
public static void main(String[] args) {
41+
SpringApplication.run(MultiCloudApplication.class, args);
42+
}
43+
44+
}

0 commit comments

Comments
 (0)