-
-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathDockerfile
More file actions
134 lines (99 loc) · 4.73 KB
/
Copy pathDockerfile
File metadata and controls
134 lines (99 loc) · 4.73 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
FROM --platform=$BUILDPLATFORM node:24-alpine AS frontend-build
ENV PNPM_HOME="/pnpm"
ENV PATH="${PNPM_HOME}:${PATH}"
WORKDIR /workspace
RUN npm install -g pnpm@11.3.0
COPY pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,target=/pnpm/store \
pnpm config set store-dir /pnpm/store && \
pnpm fetch
COPY package.json ./
COPY frontend/package.json ./frontend/
COPY tools/release/package.json ./tools/release/
RUN --mount=type=cache,target=/pnpm/store \
pnpm install --offline --frozen-lockfile
COPY frontend/ ./frontend/
RUN --mount=type=cache,target=/workspace/frontend/.angular/cache \
CI=1 NG_CLI_ANALYTICS=false pnpm -C frontend run build:prod
FROM --platform=$BUILDPLATFORM gradle:9.5.1-jdk25-alpine AS backend-build
ARG TARGETARCH
ARG APP_VERSION=development
ARG APP_REVISION=unknown
WORKDIR /workspace/backend
COPY backend/gradlew backend/gradlew.bat backend/build.gradle.kts backend/settings.gradle.kts backend/gradle.lockfile ./
COPY backend/gradle ./gradle
RUN chmod +x ./gradlew
RUN --mount=type=cache,target=/home/gradle/.gradle \
./gradlew --no-daemon dependencies
COPY backend/ ./
COPY --from=frontend-build /workspace/frontend/dist/grimmory/browser /tmp/frontend-dist
RUN --mount=type=cache,target=/home/gradle/.gradle \
TARGETARCH=${TARGETARCH} ./gradlew --no-daemon -PfrontendDistDir=/tmp/frontend-dist bootJar
RUN set -eux; \
jar_path="$(find build/libs -maxdepth 1 -name '*.jar' ! -name '*plain.jar' | head -n 1)"; \
cp "$jar_path" /workspace/backend/app.jar
FROM mwader/static-ffmpeg:8.1 AS ffprobe-layer
FROM scratch AS kepubify-layer-amd64
ARG KEPUBIFY_VERSION="4.0.4"
ARG KEPUBIFY_AMD64_CHECKSUM="sha256:37d7628d26c5c906f607f24b36f781f306075e7073a6fe7820a751bb60431fc5"
ADD \
--checksum="${KEPUBIFY_AMD64_CHECKSUM}" \
--chmod=755 \
https://github.com/pgaskin/kepubify/releases/download/v${KEPUBIFY_VERSION}/kepubify-linux-64bit /kepubify
FROM scratch AS kepubify-layer-arm64
ARG KEPUBIFY_VERSION="4.0.4"
ARG KEPUBIFY_ARM64_CHECKSUM="sha256:5a15b8f6f6a96216c69330601bca29638cfee50f7bf48712795cff88ae2d03a3"
ADD \
--checksum="${KEPUBIFY_ARM64_CHECKSUM}" \
--chmod=755 \
https://github.com/pgaskin/kepubify/releases/download/v${KEPUBIFY_VERSION}/kepubify-linux-arm64 /kepubify
FROM kepubify-layer-${TARGETARCH} AS kepubify-layer
FROM eclipse-temurin:25-jre-alpine
ENV JAVA_TOOL_OPTIONS="-XX:+UseShenandoahGC \
-XX:ShenandoahGCHeuristics=compact \
-XX:+UseCompactObjectHeaders \
-XX:MaxRAMPercentage=60.0 \
-XX:InitialRAMPercentage=8.0 \
-XX:+ExitOnOutOfMemoryError \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=/tmp/heapdump.hprof \
-XX:MaxMetaspaceSize=256m \
-XX:ReservedCodeCacheSize=48m \
-Xss512k \
-XX:CICompilerCount=2 \
-XX:+UnlockExperimentalVMOptions \
-XX:+UseStringDeduplication \
-XX:ShenandoahUncommitDelay=5000 \
-XX:ShenandoahGuaranteedGCInterval=30000 \
-XX:MaxDirectMemorySize=256m \
--enable-native-access=ALL-UNNAMED \
--enable-preview"
RUN apk add --no-cache su-exec libstdc++ libgcc libarchive && \
mkdir -p /bookdrop
# Manually link `libarchive.so.13` so java and other libraries can see it
RUN ln -s /usr/lib/libarchive.so.13 /usr/lib/libarchive.so
COPY packaging/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
COPY --from=ffprobe-layer /ffprobe /usr/local/bin/ffprobe
COPY --from=kepubify-layer /kepubify /usr/local/bin/kepubify
COPY --from=backend-build /workspace/backend/app.jar /app/app.jar
ARG APP_VERSION=development
ARG APP_REVISION=unknown
LABEL org.opencontainers.image.title="Grimmory" \
org.opencontainers.image.description="Grimmory: a self-hosted, multi-user digital library with smart shelves, auto metadata, Kobo and KOReader sync, BookDrop imports, OPDS support, and a built-in reader for EPUB, PDF, and comics." \
org.opencontainers.image.source="https://github.com/grimmory-tools/grimmory" \
org.opencontainers.image.url="https://github.com/grimmory-tools/grimmory" \
org.opencontainers.image.documentation="https://grimmory.org/docs/getting-started" \
org.opencontainers.image.version=$APP_VERSION \
org.opencontainers.image.revision=$APP_REVISION \
org.opencontainers.image.licenses="AGPL-3.0" \
org.opencontainers.image.base.name="docker.io/library/eclipse-temurin:25-jre-alpine"
ENV APP_VERSION=${APP_VERSION} \
APP_REVISION=${APP_REVISION}
ARG BOOKLORE_PORT=6060
ENV BOOKLORE_PORT=${BOOKLORE_PORT}
EXPOSE ${BOOKLORE_PORT}
HEALTHCHECK --interval=60s --timeout=10s --start-period=60s --retries=5 \
CMD wget -q --spider http://localhost:${BOOKLORE_PORT}/api/v1/healthcheck
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["java", "--enable-native-access=ALL-UNNAMED", "--enable-preview", "-jar", "/app/app.jar"]