-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (31 loc) 路 1.63 KB
/
Copy pathDockerfile
File metadata and controls
41 lines (31 loc) 路 1.63 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
# --- Build Stage ---
# Use Ubuntu 24.04 as the base image (includes Java 21 in official repos)
FROM --platform=linux/x86_64 ubuntu:24.04 AS build
# 1. Install OpenJDK 21
RUN set -xe ; \
apt-get -yqq update ; \
apt-get -yqq install openjdk-21-jdk openjdk-21-jre-headless \
;
# 2. Re-generate ldconfig for Java 21
# Note: Ensure the path matches the Ubuntu directory structure
RUN ldconfig /usr/lib/jvm/java-21-openjdk-amd64/lib/server/
WORKDIR /src
COPY ./SimpleHttpServer.java /src/SimpleHttpServer.java
RUN javac SimpleHttpServer.java
# --- Runtime Stage (minimal) ---
FROM scratch
# --- Copy system libraries (glibc, libz, etc.) ---
# These paths are standard for Ubuntu/Debian x86_64
COPY --from=build /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6
COPY --from=build /lib/x86_64-linux-gnu/libstdc++.so.6 /lib/x86_64-linux-gnu/libstdc++.so.6
COPY --from=build /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/libm.so.6
COPY --from=build /usr/lib/x86_64-linux-gnu/libz.so.1 /usr/lib/x86_64-linux-gnu/libz.so.1
COPY --from=build /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/libgcc_s.so.1
COPY --from=build /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
COPY --from=build /etc/ld.so.cache /etc/ld.so.cache
# --- Copy Java 21 Runtime ---
COPY --from=build /usr/lib/jvm/java-21-openjdk-amd64/ /usr/lib/jvm/java-21-openjdk-amd64/
COPY --from=build /etc/ssl/certs/java/cacerts /etc/ssl/certs/java/cacerts
COPY --from=build /etc/java-21-openjdk/security/ /etc/java-21-openjdk/security/
# --- Copy the compiled application ---
COPY --from=build /src/SimpleHttpServer.class /usr/src/SimpleHttpServer.class