Skip to content

Commit 304e0b3

Browse files
committed
完善架构
1 parent 887fc56 commit 304e0b3

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

Dockerfile

+29-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
FROM seleniarm/standalone-chromium:123.0
22

3-
# 安装OpenJDK 11
3+
# 安装OpenJDK 11和 node 20
44
USER root
55
RUN apt-get update && \
66
apt-get install -y openjdk-11-jdk curl ca-certificates && \
77
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
88
apt-get install -y nodejs && \
9-
apt-get clean && \
10-
rm -rf /var/lib/apt/lists/*
9+
# 检测架构并设置 URL 和 JAVA_HOME
10+
arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \
11+
case "$arch" in \
12+
'amd64') \
13+
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"; \
14+
;; \
15+
'arm64') \
16+
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-arm64"; \
17+
;; \
18+
*) \
19+
echo "Unsupported architecture: $arch" >&2; exit 1; \
20+
;; \
21+
esac; \
22+
# 将 JAVA_HOME 写入 shell 的默认环境
23+
echo "export JAVA_HOME=${JAVA_HOME}" >> /etc/profile.d/java.sh; \
24+
echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile.d/java.sh; \
25+
chmod +x /etc/profile.d/java.sh; \
26+
\
27+
# 清理
28+
rm -rf \
29+
/tmp/* \
30+
/usr/share/doc/* \
31+
/var/cache/* \
32+
/var/lib/apt/lists/* \
33+
/var/tmp/* \
34+
/var/log/*
1135

12-
# 设置JAVA_HOME环境变量
13-
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
14-
15-
# 添加JAVA_HOME到PATH
16-
ENV PATH $JAVA_HOME/bin:$PATH
36+
# 在启动时动态加载 JAVA_HOME
37+
ENTRYPOINT ["/bin/bash", "-c", "source /etc/profile && exec \"$@\"", "--"]

0 commit comments

Comments
 (0)