forked from jarvis2f/telegram-files
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (56 loc) · 2.03 KB
/
Copy pathDockerfile
File metadata and controls
75 lines (56 loc) · 2.03 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
FROM gradle:8.10-jdk23-alpine AS api-builder
WORKDIR /app
COPY ./api/build.gradle ./api/settings.gradle ./
COPY ./api/gradle ./gradle
RUN gradle dependencies --no-daemon
COPY ./api .
RUN gradle shadowJar --no-daemon && \
mkdir -p /app/build/libs && \
cp /app/build/libs/*.jar /app/api.jar && \
jdeps --print-module-deps --ignore-missing-deps /app/api.jar > /app/dependencies.txt
FROM eclipse-temurin:23-jdk-alpine AS runtime-builder
WORKDIR /custom-jre
COPY --from=api-builder /app/dependencies.txt .
RUN apk add --no-cache binutils && \
jlink \
--add-modules $(cat dependencies.txt) \
--output jre \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 && \
apk del binutils
FROM node:21-alpine AS web-builder
WORKDIR /web
ENV NEXT_PUBLIC_API_URL=/api \
NEXT_PUBLIC_WS_URL=/ws \
NEXT_TELEMETRY_DISABLED=1 \
SKIP_ENV_VALIDATION=1
COPY ./web/package*.json ./
RUN npm ci --frozen-lockfile
COPY ./web .
RUN npm run build
FROM alpine:3.18.12 AS final
WORKDIR /app
ARG TARGETARCH
ENV JAVA_HOME=/jre \
PATH="/jre/bin:$PATH" \
LANG=C.UTF-8 \
NGINX_PORT=80
RUN addgroup -S tf && \
adduser -S -G tf tf && \
apk add --no-cache nginx wget curl unzip tini su-exec gettext openssl3 libstdc++ gcompat libc6-compat && \
rm -rf /tmp/* /var/tmp/* && \
touch /run/nginx.pid && \
chown -R tf:tf /app /etc/nginx /var/lib/nginx /var/log/nginx /run/nginx.pid && \
printf '#!/bin/sh\njava -Djava.library.path=/app/tdlib -cp /app/api.jar telegram.files.Maintain "$@"\n' > /usr/bin/tfm && \
chmod +x /usr/bin/tfm
COPY --from=runtime-builder --chown=tf:tf /custom-jre/jre /jre
COPY --from=api-builder --chown=tf:tf /app/api.jar /app/api.jar
COPY --from=web-builder --chown=tf:tf /web/out /app/web/
COPY --chown=tf:tf ./tdlib/linux_$TARGETARCH /app/tdlib
COPY --chown=tf:tf ./entrypoint.sh .
COPY --chown=tf:tf ./nginx.conf.template /etc/nginx/nginx.conf.template
EXPOSE $NGINX_PORT
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/bin/sh", "./entrypoint.sh"]