-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (26 loc) · 1.13 KB
/
Copy pathDockerfile
File metadata and controls
36 lines (26 loc) · 1.13 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
# syntax=docker/dockerfile:1.7
# Note on base image variant: we use the non-Alpine images.
# eclipse-temurin:17-*-alpine has no linux/arm64 manifest, so on Apple Silicon
# `docker compose build` fails with "no match for platform in manifest". The
# Ubuntu-based images publish multi-arch (amd64 + arm64) and work everywhere.
# Trade-off: larger image (~440 MB vs ~210 MB).
# ---------- Build stage ----------
FROM eclipse-temurin:17-jdk AS build
WORKDIR /workspace
# Resolve dependencies in a cacheable layer.
COPY .mvn/ .mvn/
COPY mvnw pom.xml ./
RUN chmod +x mvnw && ./mvnw -B -q dependency:go-offline
# Copy sources and the OpenAPI spec (input to the generator plugin).
COPY src/ src/
COPY docs/api/ docs/api/
RUN ./mvnw -B -q -DskipTests package
# ---------- Runtime stage ----------
FROM eclipse-temurin:17-jre AS runtime
WORKDIR /app
# Run as a non-root user (Ubuntu uses adduser/addgroup with different flags than Alpine).
RUN groupadd --system app && useradd --system --gid app --shell /usr/sbin/nologin app
USER app
COPY --from=build --chown=app:app /workspace/target/*.jar /app/app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app/app.jar"]