diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 4b5ddf0..c87e415 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -4,7 +4,6 @@ on: push: branches: - master - - test-* # make it be easier for contributors to test tags: - 'v*.*.*' pull_request: @@ -12,33 +11,16 @@ on: - 'master' jobs: - BuildCentOSJava11: - runs-on: ubuntu-20.04 + BuildUbuntuJava11: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Docker meta for KubeSphere id: meta - if: github.repository_owner == 'kubesphere' - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: | - kubespheredev/java-11-centos7 - ghcr.io/${{ github.repository_owner }}/java-11-centos7 - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern=v{{version}} - type=semver,pattern=v{{major}}.{{minor}} - type=semver,pattern=v{{major}} - type=sha - - name: Docker meta for Contributors - id: metaContributors - if: github.repository_owner != 'kubesphere' - uses: docker/metadata-action@v3 - with: - images: | - ghcr.io/${{ github.repository_owner }}/java-11-centos7 + kubespheredev/java-11-ubuntu tags: | type=schedule type=ref,event=branch @@ -48,68 +30,34 @@ jobs: type=semver,pattern=v{{major}} type=sha - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_SECRETS }} - - name: Login to GHCR - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_TOKEN }} - name: Build and push Docker images - uses: docker/build-push-action@v2.4.0 - if: github.repository_owner == 'kubesphere' + uses: docker/build-push-action@v6 with: - context: java/images/centos-java11 + context: java/images/ubuntu-java11 tags: ${{ steps.meta.outputs.tags }} push: ${{ github.event_name != 'pull_request' }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 - - name: Build and push Docker images for Contributors - uses: docker/build-push-action@v2.4.0 - if: github.repository_owner != 'kubesphere' - with: - context: java/images/centos-java11 - tags: ${{ steps.metaContributors.outputs.tags }} - push: ${{ github.event_name != 'pull_request' }} - labels: ${{ steps.metaContributors.outputs.labels }} - platforms: linux/amd64,linux/arm64 - BuildCentOSJava8: - runs-on: ubuntu-20.04 + BuildUbuntuJava8: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Docker meta for KubeSphere id: meta - if: github.repository_owner == 'kubesphere' - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: | - kubespheredev/java-8-centos7 - ghcr.io/${{ github.repository_owner }}/java-8-centos7 - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern=v{{version}} - type=semver,pattern=v{{major}}.{{minor}} - type=semver,pattern=v{{major}} - type=sha - - name: Docker meta for Contributors - id: metaContributors - if: github.repository_owner != 'kubesphere' - uses: docker/metadata-action@v3 - with: - images: | - ghcr.io/${{ github.repository_owner }}/java-8-centos7 + kubespheredev/java-8-ubuntu tags: | type=schedule type=ref,event=branch @@ -119,69 +67,35 @@ jobs: type=semver,pattern=v{{major}} type=sha - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_SECRETS }} - - name: Login to GHCR - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_TOKEN }} - name: Build and push Docker images - uses: docker/build-push-action@v2.4.0 - if: github.repository_owner == 'kubesphere' + uses: docker/build-push-action@v6 with: - context: java/images/centos + context: java/images/ubuntu tags: ${{ steps.meta.outputs.tags }} push: ${{ github.event_name != 'pull_request' }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 - - name: Build and push Docker images for Contributors - uses: docker/build-push-action@v2.4.0 - if: github.repository_owner != 'kubesphere' - with: - context: java/images/centos - tags: ${{ steps.metaContributors.outputs.tags }} - push: ${{ github.event_name != 'pull_request' }} - labels: ${{ steps.metaContributors.outputs.labels }} - platforms: linux/amd64,linux/arm64 BuildTomcatJava8: - runs-on: ubuntu-20.04 - needs: BuildCentOSJava8 + runs-on: ubuntu-latest + needs: BuildUbuntuJava8 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Docker meta for KubeSphere id: meta - if: github.repository_owner == 'kubesphere' - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: | - kubespheredev/tomcat85-java8-centos7 - ghcr.io/${{ github.repository_owner }}/tomcat85-java8-centos7 - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern=v{{version}} - type=semver,pattern=v{{major}}.{{minor}} - type=semver,pattern=v{{major}} - type=sha - - name: Docker meta for Contributors - id: metaContributors - if: github.repository_owner != 'kubesphere' - uses: docker/metadata-action@v3 - with: - images: | - ghcr.io/${{ github.repository_owner }}/tomcat85-java8-centos7 + kubespheredev/tomcat85-java8-ubuntu tags: | type=schedule type=ref,event=branch @@ -191,69 +105,35 @@ jobs: type=semver,pattern=v{{major}} type=sha - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_SECRETS }} - - name: Login to GHCR - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_TOKEN }} - name: Build and push Docker images - uses: docker/build-push-action@v2.4.0 - if: github.repository_owner == 'kubesphere' + uses: docker/build-push-action@v6 with: - context: tomcat/images/tomcat85-java8-centos7 + context: tomcat/images/tomcat85-java8-ubuntu tags: ${{ steps.meta.outputs.tags }} push: ${{ github.event_name != 'pull_request' }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 - - name: Build and push Docker images for Contributors - uses: docker/build-push-action@v2.4.0 - if: github.repository_owner != 'kubesphere' - with: - context: tomcat/images/tomcat85-java8-centos7 - tags: ${{ steps.metaContributors.outputs.tags }} - push: ${{ github.event_name != 'pull_request' }} - labels: ${{ steps.metaContributors.outputs.labels }} - platforms: linux/amd64,linux/arm64 BuildTomcatJava11: - runs-on: ubuntu-20.04 - needs: BuildCentOSJava11 + runs-on: ubuntu-latest + needs: BuildUbuntuJava11 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Docker meta for KubeSphere id: meta - if: github.repository_owner == 'kubesphere' - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: | - kubespheredev/tomcat85-java11-centos7 - ghcr.io/${{ github.repository_owner }}/tomcat85-java11-centos7 - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern=v{{version}} - type=semver,pattern=v{{major}}.{{minor}} - type=semver,pattern=v{{major}} - type=sha - - name: Docker meta for Contributors - id: metaContributors - if: github.repository_owner != 'kubesphere' - uses: docker/metadata-action@v3 - with: - images: | - ghcr.io/${{ github.repository_owner }}/tomcat85-java11-centos7 + kubespheredev/tomcat85-java11-ubuntu tags: | type=schedule type=ref,event=branch @@ -263,37 +143,20 @@ jobs: type=semver,pattern=v{{major}} type=sha - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_SECRETS }} - - name: Login to GHCR - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_TOKEN }} - name: Build and push Docker images - uses: docker/build-push-action@v2.4.0 - if: github.repository_owner == 'kubesphere' + uses: docker/build-push-action@v6 with: - context: tomcat/images/tomcat85-java11-centos7 + context: tomcat/images/tomcat85-java11-ubuntu tags: ${{ steps.meta.outputs.tags }} push: ${{ github.event_name != 'pull_request' }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 - - name: Build and push Docker images for Contributors - uses: docker/build-push-action@v2.4.0 - if: github.repository_owner != 'kubesphere' - with: - context: tomcat/images/tomcat85-java11-centos7 - tags: ${{ steps.metaContributors.outputs.tags }} - push: ${{ github.event_name != 'pull_request' }} - labels: ${{ steps.metaContributors.outputs.labels }} - platforms: linux/amd64,linux/arm64 diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile deleted file mode 100644 index b0273e8..0000000 --- a/.gitpod.Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM gitpod/workspace-full - -# More information: https://www.gitpod.io/docs/config-docker/ -RUN sudo rm -rf /usr/bin/hd && \ - brew install linuxsuren/linuxsuren/hd && \ - hd install cli/cli && \ - hd install openshift/source-to-image v1.3.1 && \ - npm -g --unsafe-perm=true --allow-root install fish-pepper --build-from-source diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 7bdc220..0000000 --- a/.gitpod.yml +++ /dev/null @@ -1,9 +0,0 @@ -image: - file: .gitpod.Dockerfile - -tasks: - - init: | - git config --global user.name $GIT_AUTHOR_NAME - git config --global user.email $GIT_COMMITTER_EMAIL - echo Yes | gh repo fork - ./test.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index a4bba7f..f4d9a81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +# DEPRECATED: DO NOT UPDATE THIS FILE # Changelog All notable changes to this project will be documented in this file. diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 89c0607..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,73 +0,0 @@ -pipeline { - agent { - node { - label 'nodejs' - } - - } - stages { - stage('checkout scm') { - steps { - checkout(scm) - } - } - stage('get utils') { - steps { - container('nodejs') { - sh 'yum -y install openssl-devel libcurl-devel.x86_64' - sh 'npm -g --unsafe-perm=true --allow-root install fish-pepper --build-from-source' - sh '''wget -O s2i.tar.gz https://github.com/openshift/source-to-image/releases/download/v1.1.13/source-to-image-v1.1.13-b54d75d3-linux-amd64.tar.gz - tar -xvf s2i.tar.gz - cp ./s2i /usr/local/bin''' - sh 'yum install -y maven' - } - - } - } - stage('test') { - steps { - container('nodejs') { - sh './test.sh' - } - - } - } - stage('tag images') { - when { - branch 'master' - } - steps { - container('nodejs') { - sh '''docker tag s2i-java kubespheredev/java-8-centos7 -docker tag s2i-java-11 kubespheredev/java-11-centos7 -docker tag s2i-tomcat85-java8 kubespheredev/tomcat85-java8-centos7 -docker tag s2i-tomcat85-java11 kubespheredev/tomcat85-java11-centos7''' - sh '''docker tag s2i-java kubespheredev/java-8-centos7:2.1.0 -docker tag s2i-java-11 kubespheredev/java-11-centos7:2.1.0 -docker tag s2i-tomcat85-java8 kubespheredev/tomcat85-java8-centos7:2.1.0 -docker tag s2i-tomcat85-java11 kubespheredev/tomcat85-java11-centos7:2.1.0 -''' - } - - } - } - stage('push images') { - when { - branch 'master' - } - steps { - container('nodejs') { - withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : 'dockerhub-id' ,)]) { - sh 'echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin' - } - - sh '''docker push kubespheredev/java-8-centos7 -docker push kubespheredev/java-11-centos7 -docker push kubespheredev/tomcat85-java8-centos7 -docker push kubespheredev/tomcat85-java11-centos7''' - } - - } - } - } -} diff --git a/README.md b/README.md index dcba732..dabe749 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -[](https://gitpod.io/#https://github.com/kubesphere/s2i-java-container) -[](https://hub.docker.com/r/kubespheredev/java-8-centos7/) -[](https://hub.docker.com/r/kubespheredev/java-11-centos7/) +[](https://hub.docker.com/r/kubespheredev/java-8-ubuntu/) +[](https://hub.docker.com/r/kubespheredev/java-11-ubuntu/) ### Source-to-Image Builder images @@ -12,21 +11,14 @@ flat classpath applications. It supports flat-classpath and fat-jar packaged app #### Development -The project use [fish-pepper](https://github.com/fabric8io-images/fish-pepper) to generete images/Dockerfiles, so do not directly change `run-java.sh`. +The project use [fish-pepper](https://github.com/fabric8io-images/fish-pepper) to generate images/Dockerfiles, so do not directly change `run-java.sh`. Instead: - makes your change in [run-java-sh project](https://github.com/fabric8io-images/run-java-sh). - download and install [fish-pepper](https://github.com/fabric8io-images/fish-pepper) from `master`. - run it like `path/to/fishpepperrepo/fish-pepper.js` both in `./java` and `.karaf` directories. -If you have errors please remove `.fp-git-blocks/` direcoties under both `./java` and `.karaf`. +If you have errors please remove `.fp-git-blocks/` directories under both `./java` and `.karaf`. -##### Release Notes -Please keep the [CHANGELOG.md](CHANGELOG.md) up-to-date. - -##### Release Process - - -Jenkins auto push a release of [kubespheredev/java-*-centos7 to Docker Hub](https://hub.docker.com/u/kubespheredev/): diff --git a/java/examples/binary/README.md b/java/examples/binary/README.md index 2705d37..be42f56 100644 --- a/java/examples/binary/README.md +++ b/java/examples/binary/README.md @@ -9,7 +9,7 @@ If you have a project with Java sources, you are probably more interested in usi mvn -f ../maven/ clean package cp ../maven/target/*.jar deployments/ - s2i build --copy . kubespheredev/java-8-centos7 s2i-java-binary-example + s2i build --copy . kubespheredev/java-8-ubuntu s2i-java-binary-example docker run -p 8080:8080 s2i-java-binary-example See the [README of the Maven example](../maven/README.md) for more information. diff --git a/java/examples/gradle/README.md b/java/examples/gradle/README.md index 84b5368..04dc0f7 100644 --- a/java/examples/gradle/README.md +++ b/java/examples/gradle/README.md @@ -4,7 +4,7 @@ ### S2I - s2i build https://github.com/kubesphere/s2i-java-container --context-dir=java/examples/gradle/ kubespheredev/java-8-centos7 s2i-java-gradle-example + s2i build https://github.com/kubesphere/s2i-java-container --context-dir=java/examples/gradle/ kubespheredev/java-8-ubuntu s2i-java-gradle-example docker run -p 8080:8080 s2i-java-gradle-example diff --git a/java/examples/maven-wrapper/README.md b/java/examples/maven-wrapper/README.md index e063562..d64029e 100644 --- a/java/examples/maven-wrapper/README.md +++ b/java/examples/maven-wrapper/README.md @@ -6,6 +6,6 @@ This S2I example illustrates how to use the Maven wrapper when a newer version o ./mvnw test - s2i build https://github.com/kubesphere/s2i-java-container --context-dir=java/examples/maven-wrapper/ kubespheredev/java-8-centos7 s2i-java-maven-wrapper-example + s2i build https://github.com/kubesphere/s2i-java-container --context-dir=java/examples/maven-wrapper/ kubespheredev/java-8-ubuntu s2i-java-maven-wrapper-example See the [README of the Maven example](../maven/README.md) for more information. diff --git a/java/examples/maven/.s2i/environment b/java/examples/maven/.s2i/environment index c57eded..ff5de60 100644 --- a/java/examples/maven/.s2i/environment +++ b/java/examples/maven/.s2i/environment @@ -1,5 +1,5 @@ # Main class not really required as already in the pom.xml, # it's just for illustration. For all the optional available here, -# see https://github.com/kubesphere/s2i-java-container/tree/master/java/images/centos +# see https://github.com/kubesphere/s2i-java-container/tree/master/java/images/ubuntu JAVA_MAIN_CLASS=io.kubesphere.devops.s2i.example.Server diff --git a/java/examples/maven/README.md b/java/examples/maven/README.md index 646809f..6f4a824 100644 --- a/java/examples/maven/README.md +++ b/java/examples/maven/README.md @@ -10,7 +10,7 @@ For local building, install s2i either from source https://github.com/openshift/ sudo dnf install source-to-image - s2i build https://github.com/kubesphere/s2i-java-container --context-dir=java/examples/maven/ kubespheredev/java-8-centos7 s2i-java-maven-example + s2i build https://github.com/kubesphere/s2i-java-container --context-dir=java/examples/maven/ kubespheredev/java-8-ubuntu s2i-java-maven-example _NB The `--copy` ensures that the latest content of the current directory and not only it's commited .git content is used ([see S2I #418](https://github.com/openshift/source-to-image/issues/418))._ @@ -30,7 +30,7 @@ and see "hello, world" when accessing http://localhost:8080 - it works! ### Container options -All JVM options documented on https://github.com/kubesphere/s2i-java-container/tree/master/java/images/centos +All JVM options documented on https://github.com/kubesphere/s2i-java-container/tree/master/java/images/ubuntu are typically specified in [`.s2i/environment`](.s2i/environment), but for quick testing can obviously also be specified on the `docker run` CLI like so: docker run -e "JAVA_MAIN_CLASS=io.kubesphere.devops.s2i.example.Server" -p 8080:8080 s2i-java-example @@ -47,5 +47,5 @@ are typically specified in [`.s2i/environment`](.s2i/environment), but for quick ## More background * https://github.com/kubesphere/s2i-java-container -* https://github.com/kubesphere/s2i-java-container/tree/master/java/images/centos +* https://github.com/kubesphere/s2i-java-container/tree/master/java/images/ubuntu * https://github.com/kubesphere/s2ioperator diff --git a/java/examples/spring-boot-maven/readme.md b/java/examples/spring-boot-maven/readme.md index 9f7994a..a927170 100644 --- a/java/examples/spring-boot-maven/readme.md +++ b/java/examples/spring-boot-maven/readme.md @@ -27,5 +27,5 @@ Import as *Existing Maven Project* and run it as *Spring Boot App*. #### s2i - s2i build https://github.com/kubesphere/s2i-java-container --context-dir=java/examples/spring-boot-maven/ kubespheredev/java-8-centos7 s2i-java-spring-maven-example + s2i build https://github.com/kubesphere/s2i-java-container --context-dir=java/examples/spring-boot-maven/ kubespheredev/java-8-ubuntu s2i-java-spring-maven-example docker run -p 8080:8080 s2i-java-spring-maven-example diff --git a/java/examples/spring-boot-maven/target/classes/kubesphere/Application.class b/java/examples/spring-boot-maven/target/classes/kubesphere/Application.class new file mode 100644 index 0000000..09c14b9 Binary files /dev/null and b/java/examples/spring-boot-maven/target/classes/kubesphere/Application.class differ diff --git a/java/examples/spring-boot-maven/target/classes/kubesphere/controllers/MainController.class b/java/examples/spring-boot-maven/target/classes/kubesphere/controllers/MainController.class new file mode 100644 index 0000000..4a441d4 Binary files /dev/null and b/java/examples/spring-boot-maven/target/classes/kubesphere/controllers/MainController.class differ diff --git a/java/examples/spring-boot-maven/target/classes/static/hello.html b/java/examples/spring-boot-maven/target/classes/static/hello.html new file mode 100644 index 0000000..d602742 --- /dev/null +++ b/java/examples/spring-boot-maven/target/classes/static/hello.html @@ -0,0 +1,9 @@ + + +
++ By KubeSphere! +
+ + diff --git a/java/images/centos-java11/Dockerfile b/java/images/ubuntu-java11/Dockerfile similarity index 90% rename from java/images/centos-java11/Dockerfile rename to java/images/ubuntu-java11/Dockerfile index e13b572..08b8d34 100644 --- a/java/images/centos-java11/Dockerfile +++ b/java/images/ubuntu-java11/Dockerfile @@ -1,4 +1,6 @@ -FROM centos:7 +FROM ubuntu:24.04 + +ARG TARGETARCH ARG EXPOSE_PORT=8080 EXPOSE ${EXPOSE_PORT} @@ -32,25 +34,24 @@ USER root # Install Java package & download Maven from Apache -RUN yum -y update \ - && yum install -y --setopt=skip_missing_names_on_install=False \ - unzip rsync \ - java-11-openjdk \ - java-11-openjdk-devel \ - && yum clean all \ +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates curl unzip rsync openjdk-11-jdk \ + && apt-get clean \ && curl https://archive.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz | \ tar -xzf - -C /opt \ && ln -s /opt/apache-maven-3.6.0 /opt/maven \ && ln -s /opt/maven/bin/mvn /usr/bin/mvn \ - && groupadd -r jboss -g 1000 \ - && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss \ + && groupadd -r jboss -g 1001 \ + && useradd -u 1001 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss \ && chmod 755 /opt/jboss -ENV JAVA_HOME /etc/alternatives/jre +ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-${TARGETARCH} +ENV PATH=$PATH:${JAVA_HOME}/bin # Use /dev/urandom to speed up startups & Add jboss user to the root group -RUN echo securerandom.source=file:/dev/urandom >> /usr/lib/jvm/java/conf/security/java.security \ +RUN echo securerandom.source=file:/dev/urandom >> /usr/lib/jvm/java-11-openjdk-${TARGETARCH}/conf/security/java.security \ && usermod -g root -G jboss jboss # Prometheus JMX exporter agent @@ -118,7 +119,7 @@ WORKDIR /opt/jboss # S2I requires a numeric, non-0 UID. This is the UID for the jboss user in the base image -USER 1000 +USER 1001 RUN mkdir -p /opt/jboss/.m2 COPY settings.xml /opt/jboss/.m2/settings.xml diff --git a/java/images/centos/README.md b/java/images/ubuntu-java11/README.md similarity index 99% rename from java/images/centos/README.md rename to java/images/ubuntu-java11/README.md index 9979a4c..5527c59 100644 --- a/java/images/centos/README.md +++ b/java/images/ubuntu-java11/README.md @@ -1,4 +1,4 @@ -# CentOS 7.5 S2I Java builder image with OpenJDK 8 +# Ubuntu S2I Java builder image with OpenJDK 11 This is a S2I builder image for Java builds whose result can be run directly without any further application server.It's suited ideally for microservices with a flat classpath (including "far jars"). diff --git a/java/images/centos-java11/apache_software_license_version_2.0-apache-2.0.txt b/java/images/ubuntu-java11/apache_software_license_version_2.0-apache-2.0.txt similarity index 100% rename from java/images/centos-java11/apache_software_license_version_2.0-apache-2.0.txt rename to java/images/ubuntu-java11/apache_software_license_version_2.0-apache-2.0.txt diff --git a/java/images/centos-java11/jolokia-opts b/java/images/ubuntu-java11/jolokia-opts similarity index 100% rename from java/images/centos-java11/jolokia-opts rename to java/images/ubuntu-java11/jolokia-opts diff --git a/java/images/centos-java11/licenses.css b/java/images/ubuntu-java11/licenses.css similarity index 100% rename from java/images/centos-java11/licenses.css rename to java/images/ubuntu-java11/licenses.css diff --git a/java/images/centos-java11/licenses.html b/java/images/ubuntu-java11/licenses.html similarity index 100% rename from java/images/centos-java11/licenses.html rename to java/images/ubuntu-java11/licenses.html diff --git a/java/images/centos-java11/licenses.xml b/java/images/ubuntu-java11/licenses.xml similarity index 100% rename from java/images/centos-java11/licenses.xml rename to java/images/ubuntu-java11/licenses.xml diff --git a/java/images/centos-java11/prometheus-config.yml b/java/images/ubuntu-java11/prometheus-config.yml similarity index 100% rename from java/images/centos-java11/prometheus-config.yml rename to java/images/ubuntu-java11/prometheus-config.yml diff --git a/java/images/centos-java11/prometheus-opts b/java/images/ubuntu-java11/prometheus-opts similarity index 100% rename from java/images/centos-java11/prometheus-opts rename to java/images/ubuntu-java11/prometheus-opts diff --git a/java/images/centos-java11/run-env.sh b/java/images/ubuntu-java11/run-env.sh similarity index 100% rename from java/images/centos-java11/run-env.sh rename to java/images/ubuntu-java11/run-env.sh diff --git a/java/images/centos-java11/run-java.sh b/java/images/ubuntu-java11/run-java.sh similarity index 100% rename from java/images/centos-java11/run-java.sh rename to java/images/ubuntu-java11/run-java.sh diff --git a/java/images/centos-java11/s2i/assemble b/java/images/ubuntu-java11/s2i/assemble similarity index 100% rename from java/images/centos-java11/s2i/assemble rename to java/images/ubuntu-java11/s2i/assemble diff --git a/java/images/centos-java11/s2i/run b/java/images/ubuntu-java11/s2i/run similarity index 100% rename from java/images/centos-java11/s2i/run rename to java/images/ubuntu-java11/s2i/run diff --git a/java/images/centos-java11/s2i/s2i-setup b/java/images/ubuntu-java11/s2i/s2i-setup similarity index 100% rename from java/images/centos-java11/s2i/s2i-setup rename to java/images/ubuntu-java11/s2i/s2i-setup diff --git a/java/images/centos-java11/s2i/save-artifacts b/java/images/ubuntu-java11/s2i/save-artifacts similarity index 100% rename from java/images/centos-java11/s2i/save-artifacts rename to java/images/ubuntu-java11/s2i/save-artifacts diff --git a/java/images/centos-java11/s2i/usage b/java/images/ubuntu-java11/s2i/usage similarity index 100% rename from java/images/centos-java11/s2i/usage rename to java/images/ubuntu-java11/s2i/usage diff --git a/java/images/centos-java11/settings.xml b/java/images/ubuntu-java11/settings.xml similarity index 100% rename from java/images/centos-java11/settings.xml rename to java/images/ubuntu-java11/settings.xml diff --git a/java/images/centos/Dockerfile b/java/images/ubuntu/Dockerfile similarity index 90% rename from java/images/centos/Dockerfile rename to java/images/ubuntu/Dockerfile index 5fe96b3..fd56b8e 100644 --- a/java/images/centos/Dockerfile +++ b/java/images/ubuntu/Dockerfile @@ -1,4 +1,6 @@ -FROM centos:7 +FROM ubuntu:24.04 + +ARG TARGETARCH ARG EXPOSE_PORT=8080 EXPOSE ${EXPOSE_PORT} @@ -32,25 +34,23 @@ USER root # Install Java package & download Maven from Apache -RUN yum -y update \ - && yum install -y --setopt=skip_missing_names_on_install=False \ - unzip rsync \ - java-1.8.0-openjdk \ - java-1.8.0-openjdk-devel \ - && yum clean all \ +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates curl unzip rsync openjdk-8-jdk \ + && apt-get clean \ && curl https://archive.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz | \ tar -xzf - -C /opt \ && ln -s /opt/apache-maven-3.5.4 /opt/maven \ && ln -s /opt/maven/bin/mvn /usr/bin/mvn \ - && groupadd -r jboss -g 1000 \ - && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss \ + && groupadd -r jboss -g 1001 \ + && useradd -u 1001 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss \ && chmod 755 /opt/jboss -ENV JAVA_HOME /etc/alternatives/jre - +ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-${TARGETARCH} +ENV PATH=$PATH:${JAVA_HOME}/bin # Use /dev/urandom to speed up startups & Add jboss user to the root group -RUN echo securerandom.source=file:/dev/urandom >> /usr/lib/jvm/java/jre/lib/security/java.security \ +RUN echo securerandom.source=file:/dev/urandom >> /usr/lib/jvm/java-8-openjdk-${TARGETARCH}/jre/lib/security/java.security \ && usermod -g root -G jboss jboss # Prometheus JMX exporter agent @@ -118,7 +118,7 @@ WORKDIR /opt/jboss # S2I requires a numeric, non-0 UID. This is the UID for the jboss user in the base image -USER 1000 +USER 1001 RUN mkdir -p /opt/jboss/.m2 COPY settings.xml /opt/jboss/.m2/settings.xml diff --git a/java/images/centos-java11/README.md b/java/images/ubuntu/README.md similarity index 99% rename from java/images/centos-java11/README.md rename to java/images/ubuntu/README.md index b3e1c37..3d9ab22 100644 --- a/java/images/centos-java11/README.md +++ b/java/images/ubuntu/README.md @@ -1,4 +1,4 @@ -# CentOS 7.6 S2I Java builder image with OpenJDK 11 +# Ubuntu S2I Java builder image with OpenJDK 8 This is a S2I builder image for Java builds whose result can be run directly without any further application server.It's suited ideally for microservices with a flat classpath (including "far jars"). diff --git a/java/images/centos/apache_software_license_version_2.0-apache-2.0.txt b/java/images/ubuntu/apache_software_license_version_2.0-apache-2.0.txt similarity index 100% rename from java/images/centos/apache_software_license_version_2.0-apache-2.0.txt rename to java/images/ubuntu/apache_software_license_version_2.0-apache-2.0.txt diff --git a/java/images/centos/jolokia-opts b/java/images/ubuntu/jolokia-opts similarity index 100% rename from java/images/centos/jolokia-opts rename to java/images/ubuntu/jolokia-opts diff --git a/java/images/centos/licenses.css b/java/images/ubuntu/licenses.css similarity index 100% rename from java/images/centos/licenses.css rename to java/images/ubuntu/licenses.css diff --git a/java/images/centos/licenses.html b/java/images/ubuntu/licenses.html similarity index 100% rename from java/images/centos/licenses.html rename to java/images/ubuntu/licenses.html diff --git a/java/images/centos/licenses.xml b/java/images/ubuntu/licenses.xml similarity index 100% rename from java/images/centos/licenses.xml rename to java/images/ubuntu/licenses.xml diff --git a/java/images/centos/prometheus-config.yml b/java/images/ubuntu/prometheus-config.yml similarity index 100% rename from java/images/centos/prometheus-config.yml rename to java/images/ubuntu/prometheus-config.yml diff --git a/java/images/centos/prometheus-opts b/java/images/ubuntu/prometheus-opts similarity index 100% rename from java/images/centos/prometheus-opts rename to java/images/ubuntu/prometheus-opts diff --git a/java/images/centos/run-env.sh b/java/images/ubuntu/run-env.sh similarity index 100% rename from java/images/centos/run-env.sh rename to java/images/ubuntu/run-env.sh diff --git a/java/images/centos/run-java.sh b/java/images/ubuntu/run-java.sh similarity index 100% rename from java/images/centos/run-java.sh rename to java/images/ubuntu/run-java.sh diff --git a/java/images/centos/s2i/assemble b/java/images/ubuntu/s2i/assemble similarity index 100% rename from java/images/centos/s2i/assemble rename to java/images/ubuntu/s2i/assemble diff --git a/java/images/centos/s2i/run b/java/images/ubuntu/s2i/run similarity index 100% rename from java/images/centos/s2i/run rename to java/images/ubuntu/s2i/run diff --git a/java/images/centos/s2i/s2i-setup b/java/images/ubuntu/s2i/s2i-setup similarity index 100% rename from java/images/centos/s2i/s2i-setup rename to java/images/ubuntu/s2i/s2i-setup diff --git a/java/images/centos/s2i/save-artifacts b/java/images/ubuntu/s2i/save-artifacts similarity index 100% rename from java/images/centos/s2i/save-artifacts rename to java/images/ubuntu/s2i/save-artifacts diff --git a/java/images/centos/s2i/usage b/java/images/ubuntu/s2i/usage similarity index 100% rename from java/images/centos/s2i/usage rename to java/images/ubuntu/s2i/usage diff --git a/java/images/centos/settings.xml b/java/images/ubuntu/settings.xml similarity index 100% rename from java/images/centos/settings.xml rename to java/images/ubuntu/settings.xml diff --git a/java/templates/Dockerfile b/java/templates/Dockerfile index 09b8422..0ba7750 100644 --- a/java/templates/Dockerfile +++ b/java/templates/Dockerfile @@ -52,8 +52,8 @@ RUN yum -y update \ tar -xzf - -C /opt \ && ln -s /opt/apache-maven-{{= mavenVersion }} /opt/maven \ && ln -s /opt/maven/bin/mvn /usr/bin/mvn \ - && groupadd -r jboss -g 1000 \ - && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss \ + && groupadd -r jboss -g 1001 \ + && useradd -u 1001 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss \ && chmod 755 /opt/jboss ENV JAVA_HOME /etc/alternatives/jre @@ -114,7 +114,7 @@ USER 185 RUN mkdir -p /home/jboss/.m2 COPY settings.xml /home/jboss/.m2/settings.xml {{??}} -USER 1000 +USER 1001 RUN mkdir -p /opt/jboss/.m2 COPY settings.xml /opt/jboss/.m2/settings.xml {{?}} diff --git a/test.sh b/test.sh deleted file mode 100755 index d4764a1..0000000 --- a/test.sh +++ /dev/null @@ -1,243 +0,0 @@ -#!/bin/bash -set -ex - -# ================================================================================== - -function test_app() { - local name=$1 - local port="8080" - - local container_id=$(docker run --name ${name}-test -d -p ${port} ${name}) - - # sleep is required because after docker run returns, the container is up but our server may not quite be yet - sleep 10 - - local http_port="$(docker port ${container_id} ${port}|sed 's/0.0.0.0://')" - local http_reply=$(curl --silent --show-error http://localhost:$http_port) - - if [ "$http_reply" = 'hello, world' ]; then - echo "APP TEST PASSED" - docker rm -f ${container_id} - return 0 - else - echo "APP TEST FAILED" - docker logs ${container_id} - docker rm -f ${container_id} - return -123 - fi -} - -# ================================================================================== - -function test_metrics() { - local name=$1 - local port="9779" - - local container_id=$(docker run --name ${name}-test -d -p ${port} ${name}) - - # sleep is required because after docker run returns, the container is up but our server may not quite be yet - sleep 10 - - local metrics_port="$(docker port ${container_id} ${port}|sed 's/0.0.0.0://')" - local metrics_reply=$(curl --silent --show-error http://localhost:$metrics_port/metrics) - - case $metrics_reply in - *"jvm_threads_current"*) - echo "METRICS TEST PASSED" - docker rm -f ${container_id} - return 0 - ;; - *) - echo "METRICS TEST FAILED" - docker logs ${container_id} - docker rm -f ${container_id} - return -123 - ;; - esac -} - -# ================================================================================== - -function test_entrypoint() { - local name=$1 - local entrypoint=$2 - - local container_id=$(docker run --name ${name}-test -d \ - -e LANG=en_US.UTF-8 -e PARAMETER_THAT_MAY_NEED_ESCAPING="&'\"|< é\\(" ${name} \ - ${entrypoint} --commandLineArgValueThatMayNeedEscaping="&'\"|< é\\(" --killDelay=1 --exitCode=0) - - # sleep is required because after docker run returns, the container is up but our server may not quite be yet - local exitCode=$(docker wait ${container_id}) - - if [ "$exitCode" = '0' ]; then - echo "APP TEST PASSED (with entrypoint ${entrypoint})" - docker rm -f ${container_id} - return 0 - else - echo "APP TEST FAILED (with entrypoint ${entrypoint})" - docker logs ${container_id} - docker rm -f ${container_id} - return -123 - fi -} - -# ================================================================================== - -function test_container() { - test_app $1 -# test_metrics $1 -} - -# ================================================================================== - -function test_image() { - local dir=$1 - local name=$2 - - docker build ${dir} -t ${name} - - # ---------------------------------------------------------------------------------- - # Presence of any required tools - # * Issues #171 and #184: unzip is required for Spring Boot devtools support - # ---------------------------------------------------------------------------------- - - docker run --rm --name ${name}-test-unzip ${name} unzip - - # -------------------------------------------------------------------------------- - # Gradle Spring Boot WAR