Skip to content

Commit 3935eef

Browse files
committed
update files.
1 parent d38269d commit 3935eef

2 files changed

Lines changed: 52 additions & 25 deletions

File tree

.github/workflows/build.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
name: Build and Push Docker Image
2-
32
on:
43
push:
54
branches:
65
- main
76
paths:
87
- 'Dockerfile'
98
- '.github/workflows/build.yml'
10-
119
jobs:
1210
build:
1311
runs-on: ubuntu-latest
14-
1512
steps:
1613
- name: Checkout code
1714
uses: actions/checkout@v4
18-
15+
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v3
18+
1919
- name: Set up Docker Buildx
2020
uses: docker/setup-buildx-action@v3
21-
21+
2222
- name: Login to Docker Hub
2323
uses: docker/login-action@v3
2424
with:
2525
username: ${{ secrets.DOCKERHUB_USERNAME }}
2626
password: ${{ secrets.DOCKERHUB_TOKEN }}
27-
27+
2828
- name: Build and push
2929
uses: docker/build-push-action@v6
3030
with:
3131
context: .
3232
platforms: linux/amd64,linux/arm64
3333
push: true
3434
tags: |
35-
freelabspace/java-local:8
35+
freelabspace/java-local:8
36+
freelabspace/java-local:latest

Dockerfile

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,52 @@
1-
FROM public.ecr.aws/amazoncorretto/amazoncorretto:8
1+
FROM --platform=$BUILDPLATFORM debian:12.12 AS builder
2+
ARG BUILDPLATFORM
3+
ARG TARGETPLATFORM
4+
ARG TARGETARCH
25

6+
ENV DEBIAN_FRONTEND=noninteractive \
7+
TZ=Asia/Shanghai
8+
9+
WORKDIR /tmp
10+
11+
# 根据目标架构下载对应的JDK
12+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
13+
14+
RUN if [ "$TARGETARCH" = "arm64" ]; then \
15+
curl -L -o jdk.tar.gz "https://github.com/hmsjy2017/get-jdk/releases/download/v8u231/jdk-8u231-linux-arm64-vfp-hflt.tar.gz"; \
16+
else \
17+
curl -L -o jdk.tar.gz "https://github.com/hmsjy2017/get-jdk/releases/download/v8u231/jdk-8u231-linux-x64.tar.gz"; \
18+
fi && \
19+
tar -xzf jdk.tar.gz && \
20+
mkdir -p /jdk8 && \
21+
mv /tmp/jdk1.8.0_231/* /jdk8/
22+
23+
# 最终镜像
24+
FROM debian:12.12
325
LABEL maintainer="https://github.com/freemankevin/java-local"
426

527
ENV DEBIAN_FRONTEND=noninteractive \
6-
TZ=Asia/Shanghai
28+
TZ=Asia/Shanghai \
29+
JAVA_HOME=/usr/local/jdk8 \
30+
PATH=/usr/local/jdk8/bin:$PATH
731

8-
RUN yum update -y && \
9-
yum install -y \
32+
# 复制JDK从builder阶段
33+
COPY --from=builder /jdk8 /usr/local/jdk8
34+
35+
# 安装依赖
36+
RUN apt-get update && apt-get install -y \
1037
tzdata \
1138
curl \
12-
wget \
13-
net-tools \
14-
iputils \
15-
telnet \
16-
bind-utils \
39+
iputils-ping \
40+
dnsutils \
1741
libreoffice \
18-
libreoffice-langpack-zh_CN \
19-
google-noto-sans-cjk-fonts \
20-
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
21-
&& echo $TZ > /etc/timezone \
22-
&& yum clean all && \
23-
rm -rf /var/cache/yum/*
24-
25-
# 确保 SSL 证书已更新
26-
RUN update-ca-trust
42+
libreoffice-l10n-zh-cn \
43+
libreoffice-help-zh-cn \
44+
fonts-noto-cjk \
45+
ca-certificates \
46+
&& ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
47+
&& echo Asia/Shanghai > /etc/timezone \
48+
&& rm -rf /var/lib/apt/lists/* \
49+
&& update-ca-certificates
50+
51+
# 验证Java安装
52+
RUN java -version && javac -version

0 commit comments

Comments
 (0)