Skip to content

Commit a682f95

Browse files
feat: add jave runtime
1 parent 8612426 commit a682f95

6 files changed

Lines changed: 131 additions & 0 deletions

File tree

.github/workflows/java-release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build Java Image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
javaVersion:
7+
description: 'Java Version'
8+
default: '21'
9+
required: true
10+
javaVariant:
11+
description: 'Eclipse Temurin image variant'
12+
default: 'jdk-noble'
13+
required: true
14+
platforms:
15+
description: 'Platforms'
16+
default: 'linux/amd64,linux/arm64/v8'
17+
required: true
18+
jobs:
19+
docker:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v5
24+
25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@v3
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Login to Docker Hub
32+
uses: docker/login-action@v3
33+
with:
34+
username: ${{ secrets.DOCKERHUB_USERNAME }}
35+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
36+
37+
- name: Build Java Image and Push
38+
uses: docker/build-push-action@v6
39+
with:
40+
context: java
41+
file: java/Dockerfile
42+
platforms: ${{ github.event.inputs.platforms }}
43+
push: true
44+
build-args: |
45+
JAVA_VERSION=${{ github.event.inputs.javaVersion }}
46+
JAVA_VARIANT=${{ github.event.inputs.javaVariant }}
47+
tags: |
48+
1panel/java:${{ github.event.inputs.javaVersion }}-jdk
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Current images in this repository:
99
- `1panel/openclaw`
1010
- `1panel/node`
1111
- `1panel/php`
12+
- `1panel/java`
1213

1314
## OpenClaw
1415

@@ -31,3 +32,4 @@ Security is one of the main considerations for `1panel/openclaw`.
3132

3233
- `1panel/node`: Node.js runtime image
3334
- `1panel/php`: PHP-FPM runtime images for multiple versions
35+
- `1panel/java`: Java JDK runtime images based on Eclipse Temurin

README_zh.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- `1panel/openclaw`
1010
- `1panel/node`
1111
- `1panel/php`
12+
- `1panel/java`
1213

1314
## OpenClaw
1415

@@ -30,3 +31,4 @@
3031

3132
- `1panel/node`:Node.js 运行环境镜像
3233
- `1panel/php`:多个版本的 PHP-FPM 运行环境镜像
34+
- `1panel/java`:基于 Eclipse Temurin 的 Java JDK 运行环境镜像

java/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ARG JAVA_VERSION
2+
ARG JAVA_VARIANT=jdk-noble
3+
4+
FROM eclipse-temurin:${JAVA_VERSION}-${JAVA_VARIANT}
5+
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends \
8+
bash \
9+
ca-certificates \
10+
curl \
11+
fontconfig \
12+
procps \
13+
tzdata && \
14+
apt-get clean && \
15+
rm -rf /var/lib/apt/lists/*
16+
17+
COPY docker-entrypoint.sh /usr/local/bin/
18+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
19+
ENTRYPOINT ["docker-entrypoint.sh"]
20+
21+
WORKDIR /app
22+
23+
CMD ["java", "-version"]

java/docker-entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
printf '\033[1;32m%s\033[0m\n' 'This image is maintained by 1Panel.'
5+
printf '\033[1;33m%s\033[0m\n' 'For support or issue discussion, please visit:'
6+
printf '\033[1;36m%s\033[0m\n' 'https://github.com/1Panel-dev/1Panel/discussions'
7+
8+
exec "$@"

tests/check-java-runtime.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
6+
dockerfile="${repo_root}/java/Dockerfile"
7+
entrypoint="${repo_root}/java/docker-entrypoint.sh"
8+
workflow="${repo_root}/.github/workflows/java-release.yml"
9+
readme="${repo_root}/README.md"
10+
readme_zh="${repo_root}/README_zh.md"
11+
cnb="${repo_root}/.cnb.yml"
12+
cnb_trigger="${repo_root}/.cnb/web_trigger.yml"
13+
14+
test -f "${dockerfile}"
15+
test -f "${entrypoint}"
16+
test -f "${workflow}"
17+
18+
grep -q 'FROM eclipse-temurin:${JAVA_VERSION}-${JAVA_VARIANT}' "${dockerfile}"
19+
grep -q 'ARG JAVA_VERSION' "${dockerfile}"
20+
grep -q 'ARG JAVA_VARIANT=jdk-noble' "${dockerfile}"
21+
grep -q 'COPY docker-entrypoint.sh /usr/local/bin/' "${dockerfile}"
22+
grep -q 'chmod +x /usr/local/bin/docker-entrypoint.sh' "${dockerfile}"
23+
grep -q 'ENTRYPOINT \["docker-entrypoint.sh"\]' "${dockerfile}"
24+
25+
grep -q "This image is maintained by 1Panel." "${entrypoint}"
26+
grep -q "For support or issue discussion, please visit:" "${entrypoint}"
27+
grep -q "https://github.com/1Panel-dev/1Panel/discussions" "${entrypoint}"
28+
grep -q 'exec "$@"' "${entrypoint}"
29+
30+
grep -q 'name: Build Java Image' "${workflow}"
31+
grep -q 'javaVersion:' "${workflow}"
32+
grep -q 'javaVariant:' "${workflow}"
33+
grep -q 'platforms:' "${workflow}"
34+
grep -q 'context: java' "${workflow}"
35+
grep -q 'file: java/Dockerfile' "${workflow}"
36+
grep -q 'JAVA_VERSION=${{ github.event.inputs.javaVersion }}' "${workflow}"
37+
grep -q 'JAVA_VARIANT=${{ github.event.inputs.javaVariant }}' "${workflow}"
38+
grep -q '1panel/java:${{ github.event.inputs.javaVersion }}-jdk' "${workflow}"
39+
40+
grep -q '`1panel/java`' "${readme}"
41+
grep -q '`1panel/java`' "${readme_zh}"
42+
43+
if grep -q 'java' "${cnb}" "${cnb_trigger}"; then
44+
echo "CNB files should not include Java build wiring yet" >&2
45+
exit 1
46+
fi

0 commit comments

Comments
 (0)