Skip to content

Commit b9ebb44

Browse files
committed
adding azure pipwline.yml and updating the docker and service names
1 parent c56a615 commit b9ebb44

File tree

12 files changed

+82
-37
lines changed

12 files changed

+82
-37
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
SERVER_PORT=4550
2+
FROM_IMAGE=openjdk:21-jdk-slim

.github/rulesets/master.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "master",
44
"target": "branch",
55
"source_type": "Repository",
6-
"source": "hmcts/api-cp-springboot-template",
6+
"source": "hmcts/service-cp-crime-schedulingandlisting-courtschedule",
77
"enforcement": "active",
88
"conditions": {
99
"ref_name": {

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# renovate: datasource=github-releases depName=microsoft/ApplicationInsights-Java
22
ARG APP_INSIGHTS_AGENT_VERSION=3.7.1
3-
FROM hmctspublic.azurecr.io/base/java:21-distroless
43

5-
COPY build/libs/api-cp-springboot-template.jar /opt/app/
4+
ARG BASE_IMAGE
5+
FROM ${BASE_IMAGE:-crmdvrepo01.azurecr.io/registry.hub.docker.com/library/openjdk:21-jdk-slim}
6+
7+
ENV JAR_FILE_NAME=service-cp-crime-schedulingandlisting-courtschedule.jar
8+
9+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
10+
11+
COPY build/libs/$JAR_FILE_NAME /opt/app/
612
COPY lib/applicationinsights.json /opt/app/
713

814
EXPOSE 4550
9-
CMD [ "api-cp-springboot-template.jar" ]
15+
RUN chmod 755 /opt/app/$JAR_FILE_NAME
16+
CMD sh -c "java -jar /opt/app/$JAR_FILE_NAME"

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ The project uses [Gradle](https://gradle.org) as a build tool. It already contai
9999
To build the project execute the following command:
100100

101101
```bash
102-
./gradlew build
102+
./gradlew clean build
103103
```
104104

105105
### Running the application
@@ -113,17 +113,10 @@ Create the image of the application by executing the following command:
113113
Note: Docker Compose V2 is highly recommended for building and running the application.
114114
In the Compose V2 old `docker-compose` command is replaced with `docker compose`.
115115

116-
Create docker image:
116+
Create docker image and run docker compose:
117117

118118
```bash
119-
docker compose build
120-
```
121-
122-
Run the distribution (created in `build/install/api-cp-springboot-template` directory)
123-
by executing the following command:
124-
125-
```bash
126-
docker compose up
119+
docker compose up --build
127120
```
128121

129122
This will start the API container exposing the application's port

azure-pipelines.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CPP Context Verify & Validation
2+
3+
# Need to update this for actual migration
4+
trigger:
5+
branches:
6+
include:
7+
- master
8+
- 'team/*'
9+
paths:
10+
include:
11+
- '*'
12+
13+
pr:
14+
- '*'
15+
16+
resources:
17+
repositories:
18+
- repository: cppAzureDevOpsTemplates
19+
type: github
20+
name: hmcts/cpp-azure-devops-templates
21+
endpoint: 'hmcts'
22+
ref: 'main'
23+
24+
pool:
25+
name: "MDV-ADO-AGENT-AKS-01"
26+
demands:
27+
- identifier -equals ubuntu-j21
28+
29+
stages:
30+
- template: pipelines/vp-build.yaml@cppAzureDevOpsTemplates
31+
parameters:
32+
repo: "$(Build.Repository.Name)"
33+

build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ project.tasks['check'].dependsOn integration
115115

116116
sonarqube {
117117
properties {
118-
property "sonar.projectName", "API CP :: api-cp-springboot-template"
119-
property "sonar.projectKey", "uk.gov.hmcts.cp:api-cp-springboot-template"
118+
property "sonar.projectName", "Service API CP :: service-cp-crime-schedulingandlisting-courtschedule"
119+
property "sonar.projectKey", "uk.gov.hmcts.cp:service-cp-crime-schedulingandlisting-courtschedule"
120120
}
121121
}
122122

@@ -187,12 +187,14 @@ tasks.named('compileJava') {
187187

188188
spotless {
189189
java {
190-
target 'build/generated/src/main/**/*.java'
190+
target 'build/generated/src/main/**/*.java', 'src/integrationTest/java/**/*.java'
191191
removeUnusedImports()
192192
eclipse().configFile('config/formatter/eclipse-formatter.xml')
193193
}
194194
}
195195

196+
197+
196198
tasks.named('spotlessJava') {
197199
dependsOn tasks.named('openApiGenerate')
198200
}

docker-compose.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
version: '2.1'
22

33
services:
4-
api-cp-springboot-template:
4+
service-cp-crime-schedulingandlisting-courtschedule:
55
build:
66
context: .
7+
dockerfile: Dockerfile
78
args:
8-
- http_proxy
9-
- https_proxy
10-
- no_proxy
11-
image: hmctspublic.azurecr.io/spring-boot/template
9+
http_proxy: ${http_proxy}
10+
https_proxy: ${https_proxy}
11+
no_proxy: ${no_proxy}
12+
FROM_IMAGE: ${FROM_IMAGE}
1213
environment:
1314
# these environment variables are used by java-logging library
1415
- ROOT_APPENDER
@@ -24,3 +25,9 @@ services:
2425
- LOGBACK_REQUIRE_ERROR_CODE=false
2526
ports:
2627
- $SERVER_PORT:$SERVER_PORT
28+
healthcheck:
29+
test: [ "CMD", "curl", "-f", "http://localhost:${SERVER_PORT}/health" ]
30+
interval: 30s
31+
timeout: 10s
32+
retries: 3
33+
start_period: 5s

src/integrationTest/java/uk/gov/hmcts/cp/controllers/CourtSceduleControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CourtSceduleControllerTest {
2525
@Test
2626
void shouldCallActuatorAndGet200() throws Exception {
2727
mockMvc.perform(get("/case/123/courtschedule"))
28-
.andDo(print())
29-
.andExpect(status().isOk());
28+
.andDo(print())
29+
.andExpect(status().isOk());
3030
}
3131
}

src/integrationTest/java/uk/gov/hmcts/cp/controllers/RootControllerIntegrationTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ class RootControllerIntegrationTest {
2828
@Test
2929
void shouldCallRootAndGet200() throws Exception {
3030
mockMvc.perform(get("/"))
31-
.andDo(print())
32-
.andExpect(status().isOk())
33-
.andExpect(content().string(containsString("Welcome to api-cp-springboot-template")));
31+
.andDo(print())
32+
.andExpect(status().isOk())
33+
.andExpect(content()
34+
.string(containsString("Welcome to service-cp-crime-schedulingandlisting-courtschedule")));
3435
}
3536

3637
@DisplayName("Actuator health status should be UP")
3738
@Test
3839
void shouldCallActuatorAndGet200() throws Exception {
3940
mockMvc.perform(get("/health"))
40-
.andDo(print())
41-
.andExpect(status().isOk())
42-
.andExpect(jsonPath("$.status").value("UP"));
41+
.andDo(print())
42+
.andExpect(status().isOk())
43+
.andExpect(jsonPath("$.status").value("UP"));
4344
}
4445
}

src/integrationTest/java/uk/gov/hmcts/cp/openapi/OpenAPIPublisherTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
/**
2020
* Built-in feature which saves service's swagger specs in temporary directory.
21-
* Each CI run on master should automatically save and upload (if updated) documentation.
21+
* Each CI run on master should automatically save and upload (if updated)
22+
* documentation.
2223
*/
2324
@ExtendWith(SpringExtension.class)
2425
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -33,10 +34,10 @@ class OpenAPIPublisherTest {
3334
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
3435
void generateDocs() throws Exception {
3536
byte[] specs = mvc.perform(get("/v3/api-docs"))
36-
.andExpect(status().isOk())
37-
.andReturn()
38-
.getResponse()
39-
.getContentAsByteArray();
37+
.andExpect(status().isOk())
38+
.andReturn()
39+
.getResponse()
40+
.getContentAsByteArray();
4041

4142
String tempDir = System.getProperty("java.io.tmpdir");
4243
String path = Paths.get(tempDir, "openapi-specs.json").toString();

0 commit comments

Comments
 (0)