-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (47 loc) · 1.86 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (47 loc) · 1.86 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
# syntax=docker/dockerfile:1
########################################
# Stage 1 — build the application with Maven
########################################
FROM maven:3.9.9-eclipse-temurin-17 AS build
WORKDIR /build
# Cache dependencies separately from source so `docker build` doesn't
# re-download the whole internet every time a .java file changes.
COPY pom.xml .
RUN mvn -B -q dependency:go-offline
COPY src ./src
# Runs the full JUnit/Mockito suite (none of it needs a live database,
# see PostgresConnectionTest) and produces the shaded, self-contained
# target/library-console.jar (main class + postgresql driver bundled).
RUN mvn -B -q clean package
########################################
# Stage 2 — runtime image
########################################
# The UI (LanternaScreens) always opens a real Swing window
# (factory.setPreferTerminalEmulator(true)), so a plain headless JRE
# is not enough — the container needs a virtual X display. We start
# Xvfb + a tiny window manager + x11vnc + noVNC, so the app's window
# can be viewed and clicked from any web browser at http://host:6080.
FROM eclipse-temurin:17-jre-jammy
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
xvfb \
x11vnc \
fluxbox \
novnc \
websockify \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /build/target/library-console.jar ./library-console.jar
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Sensible defaults; override at `docker run`/compose time.
ENV LIBRARY_DB_URL=jdbc:postgresql://db:5432/library \
LIBRARY_DB_USER=postgres \
LIBRARY_DB_PASSWORD=admin1 \
DISPLAY=:99 \
SCREEN_RESOLUTION=1280x800x24 \
VNC_PORT=5900 \
NOVNC_PORT=6080
# noVNC (browser access) and raw VNC (for a native VNC client), respectively.
EXPOSE 6080 5900
ENTRYPOINT ["/entrypoint.sh"]