generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
43 lines (31 loc) · 1.47 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM eclipse-temurin:21-jdk-jammy AS builder
ARG BUILD_NUMBER
ENV BUILD_NUMBER ${BUILD_NUMBER:-1_0_0}
WORKDIR /app
ADD . .
RUN ./gradlew assemble -Dorg.gradle.daemon=false
# Grab AWS RDS Root cert
RUN apt-get update && apt-get install -y curl
RUN curl https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem > root.crt
FROM eclipse-temurin:21-jdk-jammy
LABEL maintainer="HMPPS Digital Studio <[email protected]>"
ARG BUILD_NUMBER
ENV BUILD_NUMBER ${BUILD_NUMBER:-1_0_0}
RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y curl && \
rm -rf /var/lib/apt/lists/*
ENV TZ=Europe/London
RUN ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
RUN addgroup --gid 2000 --system appgroup && \
adduser --uid 2000 --system appuser --gid 2000
# Install AWS RDS Root cert into Java truststore
RUN mkdir /home/appuser/.postgresql
COPY --from=builder --chown=appuser:appgroup /app/root.crt /home/appuser/.postgresql/root.crt
WORKDIR /app
COPY --from=builder --chown=appuser:appgroup /app/build/libs/hmpps-allocations*.jar /app/app.jar
COPY --from=builder --chown=appuser:appgroup /app/build/libs/applicationinsights-agent*.jar /app/agent.jar
COPY --from=builder --chown=appuser:appgroup /app/applicationinsights.json /app
COPY --from=builder --chown=appuser:appgroup /app/applicationinsights.dev.json /app
USER 2000
ENTRYPOINT ["java", "-XX:+AlwaysActAsServerClassMachine", "-javaagent:/app/agent.jar", "-jar", "/app/app.jar"]