diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..792335d --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..f9dafc1 --- /dev/null +++ b/docker-bake.hcl @@ -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" + ] +} \ No newline at end of file diff --git a/openjdk/Dockerfile b/openjdk/Dockerfile new file mode 100644 index 0000000..04b0492 --- /dev/null +++ b/openjdk/Dockerfile @@ -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 "alan@yeh.cn" + +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"] \ No newline at end of file