Skip to content

Commit

Permalink
[INIT] Initial commit
Browse files Browse the repository at this point in the history
1. add Azul Zulu Builds of OpenJDK

Signed-off-by: Alan Yeh <[email protected]>
  • Loading branch information
alan-yeh committed Jul 30, 2023
0 parents commit 9ffcf4a
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: image=moby/buildkit:master
platforms: linux/amd64,linux/arm64
- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/bake-action@v3
with:
push: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
50 changes: 50 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
############################################################################
# Global inheritable target
############################################################################
group "default" {
targets = [
"openjdk"
]
}

############################################################################
# Global inheritable target
############################################################################
target "_platforms" {
platforms = [
"linux/arm64",
"linux/amd64"
]
}

############################################################################
# Azul Zulu Builds of OpenJDK
# https://www.azul.com
############################################################################
variable "OPENJDK_VERSION" {
default = "8.0.382"
}

variable "OPENJDK_SHORT_VERSION" {
default = "8"
}

target "openjdk" {
inherits = ["_platforms"]
dockerfile = "Dockerfile"
context = "./openjdk"
args = {
OPENJDK_SHORT_VERSION = "${OPENJDK_SHORT_VERSION}"
OPENJDK_VERSION = "${OPENJDK_VERSION}"

AMD64_PACKAGE = "zulu8.72.0.17-ca-jdk8.0.382-linux_musl_x64"
ARM64_PACKAGE = "zulu8.72.0.17-ca-jdk8.0.382-linux_musl_aarch64"
}
tags = [
"docker.io/centralx/openjdk:latest",
"docker.io/centralx/openjdk:${OPENJDK_SHORT_VERSION}",
"docker.io/centralx/openjdk:${OPENJDK_SHORT_VERSION}-alpine",
"docker.io/centralx/openjdk:${OPENJDK_VERSION}",
"docker.io/centralx/openjdk:${OPENJDK_VERSION}-alpine"
]
}
44 changes: 44 additions & 0 deletions openjdk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
########################################################
# Stage 1
# 获取构建需要用到的安装包
########################################################
FROM alpine:3.18.2 as builder
ARG AMD64_PACKAGE
ARG ARM64_PACKAGE

WORKDIR /workspace

# amd64 package
ADD https://cdn.azul.com/zulu/bin/$AMD64_PACKAGE.tar.gz ./linux/amd64/jdk.tar.gz
RUN tar -zxvf ./linux/amd64/jdk.tar.gz -C ./linux/amd64 && \
mkdir -p ./linux/amd64/jdk && \
mv ./linux/amd64/$AMD64_PACKAGE/* ./linux/amd64/jdk

# arm64 package
ADD https://cdn.azul.com/zulu/bin/$ARM64_PACKAGE.tar.gz ./linux/arm64/jdk.tar.gz
RUN tar -zxvf ./linux/arm64/jdk.tar.gz -C ./linux/arm64 && \
mkdir -p ./linux/arm64/jdk && \
mv ./linux/arm64/$ARM64_PACKAGE/* ./linux/arm64/jdk

########################################################
# Stage 2
# 只复制指定架构的包
# 设置相关环境变量
########################################################
FROM --platform=$TARGETPLATFORM alpine:3.18.2
MAINTAINER Alan Yeh "[email protected]"

ARG TARGETPLATFORM
ARG OPENJDK_VERSION

COPY --from=builder /workspace/$TARGETPLATFORM/jdk /usr/local/jdk

ENV JAVA_HOME=/usr/local/jdk
ENV JAVA_VERSION=$OPENJDK_VERSION
ENV PATH=/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV LANG C.UTF-8

ENV TZ "Asia/Shanghai"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

CMD ["jshell"]

0 comments on commit 9ffcf4a

Please sign in to comment.