Skip to content

Commit 5fa8607

Browse files
committed
chore: remove certs from startup.sh the cert authority is now baked into the $BASE_IMAGE
1 parent ec53bdb commit 5fa8607

3 files changed

Lines changed: 11 additions & 43 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ jobs:
157157
tags: |
158158
ghcr.io/${{ github.repository }}:${{ needs.Artefact-Version.outputs.artefact_version }}
159159
build-args: |
160-
BASE_IMAGE=openjdk:21-jdk-slim
160+
BASE_IMAGE=eclipse-temurin:25
161161
JAR_FILENAME=${{ needs.Build.outputs.artefact_name }}.jar
162162
163163
Deploy:
@@ -179,5 +179,6 @@ jobs:
179179
"ARTIFACT_ID": "${{ env.REPO_NAME }}",
180180
"ARTIFACT_VERSION": "${{ needs.Artefact-Version.outputs.artefact_version }}",
181181
"TARGET_REPOSITORY": "${{ github.repository }}"
182+
"agentDemand": "ubuntu-j25",
183+
"baseImage": "hmcts/apm-services:25-jre"
182184
}
183-

Dockerfile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
# Dockerfile (project root)
1+
# See ci-build-publish.yml which sets baseImage=hmcts/apm-services:25-jre and agentDemand:ubuntu-j25
2+
# azure pipeline replaces $BASE_IMAGE with crmdvrepo01.azurecr.io + $baseImage
3+
# This image has the hmcts self signing certificate authority added to truststore so we dont need to worry about about the certs
4+
# If pulling this locally we need to authenticate to acr ... az login; az acr login -n crmdvrepo01
25
ARG BASE_IMAGE
36
FROM ${BASE_IMAGE:-eclipse-temurin:25-jre}
47

58
# install curl for debugging
69
RUN apt-get update \
7-
&& apt-get install -y --no-install-recommends curl \
10+
&& apt-get install -y curl \
811
&& rm -rf /var/lib/apt/lists/*
912

10-
# run as non-root
13+
# run as non-root ... group and user "app"
1114
RUN groupadd -r app && useradd -r -g app app
1215
WORKDIR /app
1316

14-
# copy startup script and app jar file
17+
# ---- Application files ----
1518
COPY docker/* /app/
1619
COPY build/libs/*.jar /app/
1720
COPY lib/applicationinsights.json /app/
1821

19-
# Not sure this does anything useful we can drop once we sort certificates
20-
RUN test -n "$JAVA_HOME" \
21-
&& test -f "$JAVA_HOME/lib/security/cacerts" \
22-
&& chmod 777 "$JAVA_HOME/lib/security/cacerts"
23-
2422
USER app
2523
ENTRYPOINT ["/bin/sh","./startup.sh"]

docker/startup.sh

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,10 @@
11
#!/usr/bin/env sh
2-
# Script to perform any custom docker startup actions
3-
# Allows local running where the jarfile is under ./build/lib
4-
# or dockerfile running where the app jarfile is under /app
5-
#
2+
# Add any startup requirements in here
63
logmsg() {
74
SCRIPTNAME=$(basename $0)
85
echo "$SCRIPTNAME : $1"
96
}
107

11-
logmsg "running and loading certificates ..."
12-
if [ -z "$JAVA_HOME" ]; then
13-
export JAVA_HOME="/usr/local/openjdk-21"
14-
fi
15-
export KEYSTORE="$JAVA_HOME/lib/security/cacerts"
16-
if [ -z "$CERTS_DIR" ]; then
17-
logmsg "Warning - expects \$CERTS_DIR to be set. i.e. export CERTS_DIR="/etc/certs
18-
logmsg "Defaulting to /etc/certs"
19-
export CERTS_DIR="/etc/certs"
20-
fi
21-
22-
if [ ! -f "$KEYSTORE" ]; then
23-
logmsg "Error - expects keystore $KEYSTORE to already exist"
24-
exit 1
25-
fi
26-
27-
export count=1
28-
logmsg "Loading certificates from $CERTS_DIR into keystore $KEYSTORE"
29-
for FILE in $(ls $CERTS_DIR)
30-
do
31-
alias="mojcert$count"
32-
logmsg "Adding $CERTS_DIR/$FILE to keystore with alias $alias"
33-
keytool -importcert -file $CERTS_DIR/$FILE -keystore $KEYSTORE -storepass changeit -alias $alias -noprompt
34-
count=$((count+1))
35-
done
36-
37-
keytool -list -keystore $KEYSTORE -storepass changeit | grep "Your keystore contains"
38-
398
export LOCALJARFILE=$(ls ./build/libs/*.jar 2>/dev/null | grep -v 'plain' | head -n1)
409
export DOCKERJARFILE=$(ls /app/*.jar 2>/dev/null | grep -v 'plain' | head -n1)
4110
if [ -f "$DOCKERJARFILE" ]; then

0 commit comments

Comments
 (0)