-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathDockerfile
92 lines (73 loc) · 2.79 KB
/
Dockerfile
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
FROM gradle:8.10-jdk21-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 openjdk:21-jdk-slim AS runtime-builder
WORKDIR /custom-jre
COPY --from=api-builder /app/dependencies.txt .
RUN apt-get update && \
apt-get install -y --no-install-recommends binutils && \
jlink \
--add-modules $(cat dependencies.txt) \
--output jre \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 && \
apt-get purge -y binutils && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
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 node:21-slim AS final
WORKDIR /app
ARG LIB_PATH=/app/tdlib
ENV JAVA_HOME=/jre \
PATH="/jre/bin:$PATH"
RUN npm install -g pm2 && \
apt-get update && \
apt-get install -y --no-install-recommends nginx wget curl unzip tini && \
mkdir -p $LIB_PATH && \
wget --no-check-certificate -q -O libs.zip https://github.com/p-vorobyev/spring-boot-starter-telegram/releases/download/1.15.0/libs.zip && \
unzip -q libs.zip -d /tmp/tdlib && \
if [ "$(uname -m)" = "x86_64" ]; then \
mv /tmp/tdlib/libs/linux_x64/* $LIB_PATH && \
wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.23_amd64.deb && \
dpkg -i libssl1.1_1.1.1f-1ubuntu2.23_amd64.deb && \
rm libssl1.1_1.1.1f-1ubuntu2.23_amd64.deb; \
elif [ "$(uname -m)" = "aarch64" ]; then \
mv /tmp/tdlib/libs/linux_arm64/* $LIB_PATH && \
wget http://ports.ubuntu.com/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_arm64.deb && \
dpkg -i libssl1.1_1.1.1f-1ubuntu2_arm64.deb && \
rm libssl1.1_1.1.1f-1ubuntu2_arm64.deb; \
else \
echo "Unsupported architecture: $(uname -m)" && \
exit 1; \
fi && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ./libs.zip
COPY --from=runtime-builder /custom-jre/jre /jre
COPY --from=api-builder /app/api.jar /app/api.jar
COPY --from=web-builder /web/public /app/web/public
COPY --from=web-builder /web/.next/standalone /app/web/
COPY --from=web-builder /web/.next/static /app/web/.next/static
COPY ./web/pm2.json /app/web/
COPY ./entrypoint.sh .
COPY ./nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/bin/sh", "./entrypoint.sh"]