-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (36 loc) · 1.91 KB
/
Dockerfile
File metadata and controls
49 lines (36 loc) · 1.91 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
###############################################################################
# ---------- 1️⃣ BUILD STAGE --------------------------------------------------
###############################################################################
# • Uses the official Eclipse-Temurin image that bundles Maven3+jdk17
# • Build steps are cached layer‑by‑layer to speed up “docker build” in CI as
# well as on your laptop (requires BuildKit, which is on by default in Docker
# Desktop and recent Docker engines).
FROM maven:3.9.6-eclipse-temurin-17 AS build
# Use an unprivileged user inside the builder for a tiny security boost
RUN useradd -ms /bin/bash builder
USER builder
WORKDIR /src
# -- 1. Copy only the pom.xml first and go offline. This creates a cache layer
# containing your dependencies so the costly "mvn dependency:go‑offline"
# runs only when pom.xml changes.
COPY --chown=builder:builder pom.xml .
RUN mvn -q dependency:go-offline
# -- 2. Now copy the actual source code
COPY --chown=builder:builder src ./src
# -- 3. Compile and package. -DskipTests is common in container builds;
# run tests in a separate CI step if you need them.
RUN mvn -q package -DskipTests
###############################################################################
# ---------- 2️⃣ RUNTIME STAGE -----------------------------------------------
###############################################################################
# • This layer contains nothing except the JAR and a JRE.
# • The resulting image is ~65MB on amd64 / arm64.
FROM eclipse-temurin:23-jre
WORKDIR /app
# Copy the shaded / normal jar produced by the build stage
# (the wildcard picks up whatever version number Maven generates).
COPY --from=build /src/target/vertx-proxy-1.0-SNAPSHOT.jar proxy.jar
# Basically a note - the image exposes this port
EXPOSE 4000
# Launch the proxy
ENTRYPOINT ["sh", "-c", "exec java -jar proxy.jar"]