Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (49 loc) · 2.46 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (49 loc) · 2.46 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
FROM eclipse-temurin:21-jdk AS build
WORKDIR /app
# Fetch Maven here instead of through ./mvnw. The wrapper's download produced a file that
# failed its own SHA-256 check inside this image, so every image build broke. Doing it
# explicitly keeps .mvn/wrapper/maven-wrapper.properties as the single source of truth and
# fails loudly if the artifact ever stops matching the pin.
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl unzip ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY .mvn/wrapper/maven-wrapper.properties /tmp/maven-wrapper.properties
RUN set -eux; \
URL="$(sed -n 's/^distributionUrl=//p' /tmp/maven-wrapper.properties | tr -d '[:space:]')"; \
SUM="$(sed -n 's/^distributionSha256Sum=//p' /tmp/maven-wrapper.properties | tr -d '[:space:]')"; \
test -n "$URL"; \
test -n "$SUM"; \
curl -fsSL --retry 3 -o /tmp/maven.zip "$URL"; \
echo "$SUM /tmp/maven.zip" | sha256sum -c -; \
unzip -q /tmp/maven.zip -d /opt; \
ln -sfn "$(echo /opt/apache-maven-*/bin/mvn)" /usr/local/bin/mvn; \
rm -f /tmp/maven.zip /tmp/maven-wrapper.properties; \
mvn -v
COPY pom.xml ./
COPY path-gateway/pom.xml path-gateway/pom.xml
COPY path-spring-ai/pom.xml path-spring-ai/pom.xml
RUN mvn -B -q -DskipTests dependency:go-offline
COPY path-gateway/src/ path-gateway/src/
# The gateway does not depend on the adapter, so the image build skips the Spring AI module.
RUN mvn -B -q -DskipTests -pl path-gateway package
FROM eclipse-temurin:21-jre
WORKDIR /app
# curl is here for the container health check below: Dokploy (and Docker) can act on it,
# and it is one small, patched package rather than the whole JDK toolchain.
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /app/path-gateway/target/path-*.jar app.jar
# Run as an unprivileged user (Trivy DS-0002) and keep ./data writable for the H2 file
# and the generated master key.
RUN groupadd --system --gid 1001 path \
&& useradd --system --uid 1001 --gid path --home-dir /app --shell /usr/sbin/nologin path \
&& chown -R path:path /app
USER path
ENV PORT=8080
EXPOSE 8080
# Readiness includes drain state: a shutting-down pod reports 503, which is what a rolling
# update should see. Uses the same endpoint the Helm chart probes.
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD curl -fsS http://127.0.0.1:8080/actuator/health || exit 1
ENTRYPOINT ["java", "-jar", "/app/app.jar"]