Skip to content

Commit 779911d

Browse files
AMP-135 - addressed merge conflicts.
1 parent 39ce342 commit 779911d

File tree

16 files changed

+80
-113
lines changed

16 files changed

+80
-113
lines changed

.github/workflows/ci-build-publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,17 @@ jobs:
144144
path: build/libs
145145

146146
- name: Set up Docker Buildx
147-
uses: docker/setup-buildx-action@v3
147+
uses: setup-buildx-action@v3
148148

149149
- name: Log in to GitHub Packages
150-
uses: docker/login-action@v3
150+
uses: login-action@v3
151151
with:
152152
registry: ghcr.io
153153
username: ${{ github.actor }}
154154
password: ${{ secrets.GITHUB_TOKEN }}
155155

156156
- name: Build and Push Docker Image to GitHub
157-
uses: docker/build-push-action@v6
157+
uses: build-push-action@v6
158158
with:
159159
context: .
160160
file: Dockerfile

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ jobs:
9292
run: gradle build -x test -x api
9393

9494
- name: Set up Docker Buildx
95-
uses: docker/setup-buildx-action@v3
95+
uses: setup-buildx-action@v3
9696

9797
- name: DAST - Build and run containerised app
9898
run: |
99-
docker compose -f docker/docker-compose.api.yml up -d
99+
docker compose -f docker-compose.yml up -d
100100
101101
echo "Waiting for health endpoint..."
102102
for i in {1..30}; do

Dockerfile

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
FROM eclipse-temurin:21
2-
WORKDIR /opt/app
3-
COPY build/libs/*.jar /opt/app/app.jar
4-
CMD ["java", "-jar", "/opt/app/app.jar"]
1+
# Dockerfile (project root)
2+
FROM eclipse-temurin:21-jre-alpine
3+
4+
# minimal runtime tooling for healthcheck
5+
RUN apk add --no-cache curl
6+
7+
# run as non-root
8+
RUN addgroup -S app && adduser -S app -G app
9+
WORKDIR /app
10+
11+
# copy all jars (bootJar + plain). We'll run the non-plain jar.
12+
COPY build/libs/*.jar /app/
13+
14+
EXPOSE ${SERVER_PORT:-8082}
15+
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 -XX:+AlwaysActAsServerClassMachine"
16+
17+
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s --retries=15 \
18+
CMD curl -fsS http://localhost:${SERVER_PORT:-8082}/actuator/health | grep -q '"status":"UP"' || exit 1
19+
20+
USER app
21+
# pick the Boot fat jar (exclude '-plain.jar')
22+
ENTRYPOINT ["sh","-c","exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar $(ls /app/*.jar | grep -v 'plain' | head -n1)"]

docker-compose.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
version: '3.9'
2-
31
services:
4-
postgres:
2+
db:
3+
container_name: db
54
image: postgres:16-alpine
65
environment:
76
POSTGRES_DB: postgres
@@ -15,15 +14,18 @@ services:
1514
timeout: 5s
1615
retries: 5
1716

18-
service-hmcts-marketplace-springboot-template:
19-
env_file:
20-
- local.env
17+
app:
18+
container_name: app
2119
build:
2220
context: .
2321
dockerfile: Dockerfile
2422
depends_on:
25-
postgres:
23+
db:
2624
condition: service_healthy
25+
environment:
26+
APP_NAME_DATASOURCE_URL: jdbc:postgresql://db:5432/postgres
27+
APP_NAME_DATASOURCE_USERNAME: postgres
28+
APP_NAME_DATASOURCE_PASSWORD: postgres
2729
ports:
2830
- "8082:8082"
2931

docker/Dockerfile

Lines changed: 0 additions & 22 deletions
This file was deleted.

docker/docker-compose.api.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

docs/PIPELINE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ sequenceDiagram
5757
5858
note right of GH: All assurance workflow steps are complete
5959
GH->>Art: Publish artefact [DRAFT] (versioned via git tag & commit SHA)
60-
note right of GH: The build and publish of the image is one step via the<br/>custom action "docker/build-push-action" but is represented<br/>here as two steps for readability
60+
note right of GH: The build and publish of the image is one step via the<br/>custom action "build-push-action" but is represented<br/>here as two steps for readability
6161
GH->>GH: Build Docker image (versioned via git tag & commit SHA)
6262
GH->>ACR: Publish container
6363
```

gradle/github/docker.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dockerCompose {
2-
useComposeFiles = ['docker/docker-compose.api.yml']
2+
useComposeFiles = ['docker-compose.yml']
33
startedServices = ['app', 'db']
44

55
buildBeforeUp = true

src/apiTest/java/uk/gov/hmcts/cp/http/ActuatorHttpLiveTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
import org.junit.jupiter.api.Disabled;
44
import org.junit.jupiter.api.Test;
5-
import org.springframework.http.*;
5+
import org.springframework.http.HttpEntity;
6+
import org.springframework.http.HttpHeaders;
7+
import org.springframework.http.HttpMethod;
8+
import org.springframework.http.HttpStatus;
9+
import org.springframework.http.MediaType;
10+
import org.springframework.http.ResponseEntity;
611
import org.springframework.web.client.RestTemplate;
712

813
import static org.assertj.core.api.Assertions.assertThat;

src/main/java/uk/gov/hmcts/cp/controllers/ExampleController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import lombok.RequiredArgsConstructor;
55
import lombok.extern.slf4j.Slf4j;
66
import org.springframework.http.ResponseEntity;
7-
import org.springframework.web.bind.annotation.PathVariable;
87
import org.springframework.web.bind.annotation.RestController;
98
import uk.gov.hmcts.cp.openapi.api.ExamplesApi;
109
import uk.gov.hmcts.cp.openapi.model.ExampleResponse;
@@ -18,9 +17,10 @@ public class ExampleController implements ExamplesApi {
1817
private final ExampleService exampleService;
1918

2019
@Override
21-
public ResponseEntity<ExampleResponse> getExampleByExampleId(@PathVariable("example_id") @NotNull final Long exampleId) {
20+
public ResponseEntity<ExampleResponse> getExampleByExampleId(@NotNull final Long exampleId) {
2221

2322
log.info("getExampleByExampleId example for {}", exampleId);
2423
return ResponseEntity.ok(exampleService.getExampleById(exampleId));
2524
}
25+
2626
}

0 commit comments

Comments
 (0)